/* Forest Blackjack — Dark Forest Theme */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-dark: #0f2b1d;
    --bg-felt-start: #0d2317;
    --bg-felt-end: #06120b;
    --gold: #d4af37;
    --gold-dim: #b8942e;
    --cream: #f4f1ea;
    --cream-dim: #c8c4bb;
    --card-face: #faf8f5;
    --red: #c0392b;
    --dark-suit: #2c2c2c;
    --shadow: rgba(0, 0, 0, 0.35);
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    color: var(--cream);
    background: radial-gradient(ellipse at 50% 0%, var(--bg-felt-start) 0%, var(--bg-felt-end) 70%);
    background-color: var(--bg-dark);
    min-height: 100dvh;
    line-height: 1.5;
}

a {
    color: var(--gold);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 1.25rem 1rem 3rem;
}

.container-wide {
    max-width: 960px;
}

/* Header */

.app-header {
    text-align: center;
    margin-bottom: 1.5rem;
    padding-top: 0.5rem;
}

.app-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.logo-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: opacity 0.15s;
}

.logo-btn:hover,
.logo-btn:focus-visible {
    opacity: 0.85;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.subtitle {
    color: var(--cream-dim);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

/* Panels */

.panel {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 4px 20px var(--shadow);
}

.panel h2 {
    font-size: 1.15rem;
    color: var(--gold);
    margin-bottom: 0.75rem;
}

.panel-danger {
    border-color: rgba(192, 57, 43, 0.5);
}

/* Views */

.view {
    display: none;
}

.view.active {
    display: block;
}

.hidden {
    display: none !important;
}

/* Forms */

label {
    display: block;
    font-size: 0.85rem;
    color: var(--cream-dim);
    margin-bottom: 0.35rem;
    margin-top: 0.75rem;
}

label:first-child,
.admin-form > label:first-of-type {
    margin-top: 0;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1.1rem;
    border: 1px solid rgba(212, 175, 55, 0.4);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.3);
    color: var(--cream);
    outline: none;
    transition: border-color 0.2s;
}

input:focus {
    border-color: var(--gold);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    margin: 0.75rem 0;
}

.checkbox-label input {
    width: auto;
}

.hint {
    font-size: 0.85rem;
    color: var(--cream-dim);
    margin-top: 0.5rem;
}

.hint.warn {
    color: #e8a838;
    margin-top: 1rem;
}

.error-msg {
    color: #ff6b6b;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.25rem;
    min-height: 44px;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid var(--gold);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    font-family: inherit;
    text-decoration: none;
    color: var(--cream);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(180deg, #1a4d32 0%, #0f2b1d 100%);
    color: var(--cream);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #226040 0%, #143824 100%);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--cream-dim);
    border-color: rgba(212, 175, 55, 0.3);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--cream);
}

.btn-danger {
    background: rgba(192, 57, 43, 0.25);
    border-color: #c0392b;
    color: #ff8a80;
}

.btn-danger:hover {
    background: rgba(192, 57, 43, 0.4);
}

.btn-lg {
    width: 100%;
    min-height: 52px;
    font-size: 1.1rem;
    margin-top: 1rem;
}

.btn-sm {
    min-height: 36px;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

#entry-form .btn-lg {
    margin-top: 1.25rem;
}

/* Game Arena */

.game-arena {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.3);
}

.hand-section {
    padding: 0.5rem 0;
}

.hand-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.hand-header h3 {
    font-size: 0.95rem;
    color: var(--gold);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.score-badge {
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid rgba(212, 175, 55, 0.4);
    color: var(--gold);
    font-weight: 700;
    font-size: 1.1rem;
    padding: 0.2rem 0.75rem;
    border-radius: 20px;
    min-width: 2.5rem;
    text-align: center;
}

.game-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.3), transparent);
    margin: 0.5rem 0;
}

.card-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 90px;
    align-items: flex-start;
}

/* Playing Cards */

.card {
    width: 64px;
    height: 90px;
    border-radius: 8px;
    position: relative;
    flex-shrink: 0;
    animation: dealIn 0.35s ease-out both;
}

@keyframes dealIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.85);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.card-face {
    background: var(--card-face);
    border: 1px solid #ddd;
    box-shadow: 0 3px 8px var(--shadow), 0 1px 2px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
}

.card-rank {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
}

.card-suit {
    font-size: 1.5rem;
    line-height: 1;
    margin-top: 0.15rem;
}

.card-suit.red,
.card-rank.red {
    color: var(--red);
}

.card-suit.dark,
.card-rank.dark {
    color: var(--dark-suit);
}

.card-back {
    background: linear-gradient(135deg, #1a4d32 0%, #0f2b1d 50%, #1a4d32 100%);
    border: 2px solid var(--gold);
    box-shadow: 0 3px 8px var(--shadow);
}

.card-back::after {
    content: '♠';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: rgba(212, 175, 55, 0.4);
}

/* Game Controls */

.game-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.game-controls .btn-lg {
    margin-top: 0;
}

.game-controls.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* Result Overlay */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 18, 11, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.overlay-content {
    background: linear-gradient(180deg, rgba(15, 43, 29, 0.98) 0%, rgba(6, 18, 11, 0.98) 100%);
    border: 2px solid var(--gold);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    text-align: center;
    max-width: 380px;
    width: 100%;
    box-shadow: 0 8px 40px var(--shadow);
    position: relative;
    z-index: 2;
}

.result-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

#result-title {
    font-size: 1.5rem;
    color: var(--gold);
    margin-bottom: 0.5rem;
}

#result-message {
    color: var(--cream-dim);
    margin-bottom: 1rem;
}

.overlay-scores {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    font-size: 0.9rem;
    color: var(--cream-dim);
    margin-bottom: 1.25rem;
}

.overlay-scores strong {
    color: var(--cream);
}

/* Lock Code Display */

.lock-code-display {
    margin: 1rem 0;
}

.lock-label {
    font-size: 0.85rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.lock-digits {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.lock-digit {
    width: 52px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gold);
    background: rgba(212, 175, 55, 0.1);
    border: 2px solid var(--gold);
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 8px var(--shadow);
}

/* Confetti Canvas */

#confetti-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Footer */

.app-footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.8rem;
}

.app-footer a {
    color: rgba(212, 175, 55, 0.5);
}

/* Admin Styles */

.admin-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.flash.success {
    background: rgba(46, 125, 50, 0.2);
    border: 1px solid rgba(76, 175, 80, 0.4);
    color: #a5d6a7;
}

.flash.error {
    background: rgba(192, 57, 43, 0.2);
    border: 1px solid rgba(255, 107, 107, 0.4);
    color: #ff8a80;
}

.admin-form {
    max-width: 480px;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.form-actions .btn {
    flex: 1;
    min-width: 140px;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    white-space: nowrap;
}

.admin-table th,
.admin-table td {
    padding: 0.6rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid rgba(212, 175, 55, 0.15);
}

.admin-table th {
    color: var(--gold);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.admin-table td.empty {
    text-align: center;
    color: var(--cream-dim);
    padding: 1.5rem;
}

.admin-table code {
    color: var(--gold);
    font-size: 0.85em;
}

.actions-cell {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    align-items: center;
}

.inline-form {
    display: inline;
}

.setup-list {
    list-style: none;
    padding: 0;
}

.setup-list li {
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(212, 175, 55, 0.1);
}

.setup-list li:last-child {
    border-bottom: none;
}

.setup-list code {
    color: var(--gold);
}

/* Responsive */

@media (min-width: 400px) {
    .card {
        width: 72px;
        height: 100px;
    }

    .card-rank {
        font-size: 1.4rem;
    }

    .card-suit {
        font-size: 1.65rem;
    }
}

@media (max-width: 600px) {
    .admin-table {
        font-size: 0.75rem;
    }

    .actions-cell {
        flex-direction: column;
        align-items: flex-start;
    }
}
