/* Letters Bingo — Schoolbook / Scrabble style */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    /* Color palette */
    --paper:         #f7efd7;        /* warm cream paper */
    --paper-edge:    #ead8a8;
    --paper-shade:   #efe2b8;
    --ink:           #1f2348;        /* deep ink-navy */
    --ink-soft:      #3a3f6f;
    --ink-muted:     #6b6f9a;
    --board-green:   #2d6644;        /* chalkboard green accent */
    --board-light:   #3d8559;
    --chalk:         #f0f5e8;
    --tile-wood:     #d9a35c;        /* scrabble tile wood */
    --tile-wood-dk:  #b27c3a;
    --tile-wood-lt:  #f0c585;
    --tile-marked:   #2d6644;
    --tile-marked-2: #1f4a30;
    --tile-win:      #c83a3a;        /* red ink for win */
    --gold:          #c89c3a;
    --shadow-strong: rgba(31, 35, 72, 0.35);
    --shadow-soft:   rgba(31, 35, 72, 0.12);

    /* Spacing in rem */
    --radius-tile:   0.5rem;
    --radius-card:   0.875rem;
    --radius-btn:    0.625rem;
}

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    font-family: 'Georgia', 'Times New Roman', serif;
    color: var(--ink);
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.45) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 80%, rgba(45, 102, 68, 0.06) 0%, transparent 55%),
        var(--paper);
    min-height: calc(100dvh - 3.5rem);
    overflow-y: auto;
}

/* ============ PAPER BACKGROUND ============ */
#paper-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        repeating-linear-gradient(
            0deg,
            transparent 0,
            transparent 1.5rem,
            rgba(31, 35, 72, 0.045) 1.5rem,
            rgba(31, 35, 72, 0.045) calc(1.5rem + 1px)
        ),
        radial-gradient(circle at 12% 18%, rgba(31, 35, 72, 0.04) 0, transparent 0.5rem),
        radial-gradient(circle at 88% 65%, rgba(31, 35, 72, 0.05) 0, transparent 0.75rem),
        radial-gradient(circle at 60% 35%, rgba(31, 35, 72, 0.03) 0, transparent 1rem);
    opacity: 0.7;
}

/* ============ SCREENS ============ */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--paper);
    color: var(--ink);
    z-index: 1000;
}

.screen.hidden, .hidden { display: none !important; }

.loading-spinner {
    width: 3.25rem;
    height: 3.25rem;
    border: 0.1875rem solid rgba(45, 102, 68, 0.15);
    border-top-color: var(--board-green);
    border-radius: 50%;
    animation: spinAnim 1s linear infinite;
}

@keyframes spinAnim { to { transform: rotate(360deg); } }

#loading-screen p {
    margin-top: 1rem;
    color: var(--board-green);
    font-size: 0.9375rem;
    letter-spacing: 0.0625rem;
    font-weight: 600;
}

.login-content { text-align: center; }

.login-icon {
    font-size: 3.5rem;
    color: var(--board-green);
    margin-bottom: 1rem;
    font-weight: 800;
    font-family: 'Georgia', serif;
    text-shadow: 0.125rem 0.125rem 0 rgba(45, 102, 68, 0.15);
}

.login-content h2 {
    color: var(--ink);
    margin-bottom: 0.5rem;
    font-family: 'Georgia', serif;
}
.login-content p { color: var(--ink-muted); }

/* ============ GAME CONTAINER ============ */
#game-container {
    width: 100%;
    max-width: 28.75rem;
    min-height: calc(100dvh - 3.5rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0.75rem 1rem;
    position: relative;
    z-index: 1;
}

#game-container.hidden { display: none; }

/* ============ HEADER ============ */
#game-header {
    width: 100%;
    padding: 0.375rem 0;
    display: flex;
    justify-content: center;
}

.balance-display {
    background:
        linear-gradient(180deg, var(--paper-shade) 0%, var(--paper-edge) 100%);
    border: 0.125rem solid var(--board-green);
    border-radius: 1.25rem;
    padding: 0.4375rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.4375rem;
    box-shadow:
        0 0.125rem 0 var(--board-green),
        0 0.25rem 0.625rem var(--shadow-soft);
}

.balance-label {
    color: var(--ink-muted);
    font-size: 0.75rem;
    letter-spacing: 0.03125rem;
    font-weight: 600;
}

#balance-value {
    color: var(--board-green);
    font-size: 1.25rem;
    font-weight: 800;
    min-width: 4.375rem;
    text-align: right;
    font-family: 'Georgia', serif;
}

.balance-currency {
    color: var(--gold);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.0625rem;
}

/* ============ PRIZE STRIP ============ */
.prize-strip {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0.4375rem 0.5rem;
    background: linear-gradient(180deg, var(--board-green) 0%, #234f37 100%);
    border-radius: var(--radius-btn);
    margin: 0.25rem 0 0.5rem;
    box-shadow:
        0 0.25rem 0.5rem var(--shadow-soft),
        inset 0 0.0625rem 0 rgba(255, 255, 255, 0.08);
    border: 0.125rem solid #1a3a26;
}

.prize-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.0625rem;
    padding: 0 0.5rem;
    flex: 1;
}

.prize-name {
    color: var(--chalk);
    font-size: 0.625rem;
    letter-spacing: 0.0625rem;
    text-transform: uppercase;
    font-weight: 600;
    opacity: 0.85;
}

.prize-mult {
    color: var(--gold);
    font-size: 0.9375rem;
    font-weight: 800;
    font-family: 'Georgia', serif;
}

.prize-sep {
    width: 1px;
    height: 1.5rem;
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.25), transparent);
}

/* ============ CALLED LETTER STAMP ============ */
.called-stamp-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    margin: 0.5rem 0 0.75rem;
    position: relative;
}

.called-stamp {
    position: relative;
    width: 5.5rem;
    height: 5.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background:
        radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.15), transparent 50%),
        linear-gradient(160deg, var(--ink) 0%, #14172f 100%);
    border-radius: 50%;
    border: 0.1875rem solid var(--ink);
    box-shadow:
        0 0.5rem 1rem var(--shadow-strong),
        inset 0 0.0625rem 0 rgba(255, 255, 255, 0.12);
}

.called-stamp::before {
    content: '';
    position: absolute;
    inset: 0.25rem;
    border: 0.125rem dashed rgba(247, 239, 215, 0.25);
    border-radius: 50%;
    pointer-events: none;
}

#called-letter {
    color: var(--paper);
    font-size: 3rem;
    font-weight: 800;
    font-family: 'Georgia', serif;
    text-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.45);
    line-height: 1;
}

.ink-splash {
    position: absolute;
    background: var(--ink);
    border-radius: 50%;
    opacity: 0.7;
    pointer-events: none;
}

.ink-splash-1 {
    width: 0.5rem;
    height: 0.5rem;
    top: -0.25rem;
    right: 0.5rem;
}

.ink-splash-2 {
    width: 0.375rem;
    height: 0.375rem;
    bottom: 0.25rem;
    left: -0.125rem;
}

.ink-splash-3 {
    width: 0.25rem;
    height: 0.25rem;
    bottom: -0.125rem;
    right: 1.25rem;
}

.called-stamp.stamp-anim {
    animation: stampPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes stampPop {
    0%   { transform: scale(0.6) rotate(-8deg); opacity: 0.4; }
    60%  { transform: scale(1.12) rotate(2deg); opacity: 1; }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* ===== Word Badge ===== */
.word-badge {
    background: linear-gradient(160deg, var(--gold) 0%, #a07820 100%);
    color: var(--paper);
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.125rem;
    text-transform: uppercase;
    box-shadow: 0 0.125rem 0.375rem var(--shadow-strong);
    border: 0.0625rem solid #7d5e17;
}

.word-badge.badge-anim {
    animation: badgeIn 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes badgeIn {
    0%   { transform: scale(0.4) translateY(-0.5rem); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* ============ CARD AREA ============ */
#card-area {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 0.5rem 0;
}

.card-frame {
    background:
        linear-gradient(180deg, var(--paper-shade) 0%, var(--paper-edge) 100%);
    border: 0.1875rem solid var(--ink);
    border-radius: var(--radius-card);
    padding: 0.75rem;
    box-shadow:
        0 0.5rem 1.25rem var(--shadow-strong),
        inset 0 0.125rem 0 rgba(255, 255, 255, 0.35);
    position: relative;
}

.card-frame::before {
    content: '';
    position: absolute;
    inset: 0.25rem;
    border: 0.0625rem dashed rgba(31, 35, 72, 0.2);
    border-radius: calc(var(--radius-card) - 0.25rem);
    pointer-events: none;
}

.bingo-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4375rem;
}

/* ===== Scrabble tile ===== */
.tile {
    width: 3.5rem;
    height: 3.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background:
        radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.35), transparent 55%),
        linear-gradient(160deg, var(--tile-wood-lt) 0%, var(--tile-wood) 55%, var(--tile-wood-dk) 100%);
    border-radius: var(--radius-tile);
    color: var(--ink);
    font-family: 'Georgia', serif;
    font-size: 1.75rem;
    font-weight: 800;
    border: 0.125rem solid #8a5a26;
    box-shadow:
        0 0.1875rem 0 #8a5a26,
        0 0.375rem 0.5rem var(--shadow-soft),
        inset 0 0.0625rem 0 rgba(255, 255, 255, 0.4);
    text-shadow: 0 0.0625rem 0 rgba(255, 255, 255, 0.35);
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease, color 0.25s ease;
    user-select: none;
}

.tile.placeholder {
    background: repeating-linear-gradient(
        45deg,
        rgba(31, 35, 72, 0.06) 0,
        rgba(31, 35, 72, 0.06) 0.25rem,
        transparent 0.25rem,
        transparent 0.5rem
    );
    color: transparent;
    border: 0.125rem dashed rgba(31, 35, 72, 0.2);
    box-shadow: none;
    text-shadow: none;
}

.tile.marked {
    background:
        radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.15), transparent 55%),
        linear-gradient(160deg, var(--board-light) 0%, var(--tile-marked) 55%, var(--tile-marked-2) 100%);
    color: var(--chalk);
    border-color: #1a3a26;
    box-shadow:
        0 0.1875rem 0 #1a3a26,
        0 0.375rem 0.625rem rgba(45, 102, 68, 0.4),
        inset 0 0.0625rem 0 rgba(255, 255, 255, 0.18);
    text-shadow: 0 0.0625rem 0.125rem rgba(0, 0, 0, 0.35);
    animation: tileMark 0.3s ease;
}

@keyframes tileMark {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.15) rotate(-3deg); }
    100% { transform: scale(1) rotate(0); }
}

.tile.winning {
    background:
        radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.25), transparent 55%),
        linear-gradient(160deg, #e16d6d 0%, var(--tile-win) 55%, #8a1f1f 100%);
    color: var(--paper);
    border-color: #6e1818;
    box-shadow:
        0 0.1875rem 0 #6e1818,
        0 0.375rem 0.75rem rgba(200, 58, 58, 0.5);
    animation: tileWin 0.7s ease infinite;
}

@keyframes tileWin {
    0%, 100% { box-shadow: 0 0.1875rem 0 #6e1818, 0 0 0 0 rgba(200, 58, 58, 0.5); }
    50%       { box-shadow: 0 0.1875rem 0 #6e1818, 0 0 1rem 0.25rem rgba(200, 58, 58, 0.4); }
}

/* ============ DRAWN INFO ============ */
.drawn-info {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    color: var(--ink-muted);
    font-weight: 600;
    letter-spacing: 0.03125rem;
}

.drawn-label, .timer-label { margin-right: 0.25rem; }
.drawn-total, .timer-unit { color: var(--ink-muted); }
.timer-sep { margin: 0 0.5rem; color: var(--ink-muted); opacity: 0.5; }

#drawn-count, #timer-value {
    color: var(--board-green);
    font-weight: 800;
    font-family: 'Georgia', serif;
}

/* ============ RESULT DISPLAY ============ */
#result-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background:
        linear-gradient(180deg, var(--paper) 0%, var(--paper-shade) 100%);
    padding: 1.25rem 2rem;
    border-radius: 1rem;
    border: 0.1875rem solid var(--ink);
    box-shadow:
        0 0.75rem 2rem var(--shadow-strong),
        inset 0 0.125rem 0 rgba(255, 255, 255, 0.4);
    z-index: 200;
    text-align: center;
    min-width: 14rem;
    animation: resultIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#result-display.hidden { display: none; }

@keyframes resultIn {
    0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}

.result-icon {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--board-green);
    font-family: 'Georgia', serif;
    margin-bottom: 0.375rem;
}

.result-title {
    font-size: 1.5rem;
    font-weight: 800;
    font-family: 'Georgia', serif;
    letter-spacing: 0.125rem;
    margin-bottom: 0.375rem;
}

.result-title.win { color: var(--board-green); }
.result-title.lose { color: var(--ink-muted); }

.result-pattern {
    font-size: 0.8125rem;
    color: var(--ink-soft);
    margin-bottom: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.0625rem;
    font-weight: 600;
}

.result-multiplier {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--gold);
    font-family: 'Georgia', serif;
    margin-bottom: 0.25rem;
}

.result-amount {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--board-green);
    font-family: 'Georgia', serif;
}

/* ============ MESSAGE DISPLAY ============ */
#message-display {
    position: fixed;
    bottom: 8rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: var(--paper);
    padding: 0.5rem 1.375rem;
    border-radius: 0.5rem;
    z-index: 150;
    white-space: nowrap;
    box-shadow: 0 0.25rem 0.75rem var(--shadow-strong);
}

#message-display.hidden { display: none; }

#message-text {
    font-size: 0.8125rem;
    font-weight: 600;
}

/* ============ BET CONTROLS ============ */
#bet-controls {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.25rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.bet-label {
    color: var(--ink-muted);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.0625rem;
    text-transform: uppercase;
}

.bet-buttons {
    display: flex;
    gap: 0.375rem;
}

.bet-btn {
    width: 3rem;
    height: 2rem;
    background: var(--paper-shade);
    border: 0.125rem solid var(--ink-muted);
    border-radius: var(--radius-btn);
    color: var(--ink);
    font-size: 0.8125rem;
    font-weight: 800;
    font-family: 'Georgia', serif;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 0.125rem 0 var(--ink-muted);
}

.bet-btn:hover:not(:disabled) {
    border-color: var(--board-green);
    color: var(--board-green);
    background: var(--paper);
    box-shadow: 0 0.125rem 0 var(--board-green);
}

.bet-btn.active {
    background: linear-gradient(160deg, var(--board-light) 0%, var(--board-green) 100%);
    color: var(--chalk);
    border-color: #1a3a26;
    box-shadow: 0 0.125rem 0 #1a3a26;
}

.bet-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.current-bet {
    background: var(--paper);
    padding: 0.25rem 0.875rem;
    border-radius: var(--radius-btn);
    border: 0.125rem solid var(--board-green);
}

#current-bet-value {
    color: var(--board-green);
    font-size: 1rem;
    font-weight: 800;
    font-family: 'Georgia', serif;
}

/* ============ ACTION BUTTON ============ */
#action-button {
    width: 11.25rem;
    height: 3.25rem;
    background: linear-gradient(160deg, var(--board-light) 0%, var(--board-green) 55%, #1a3a26 100%);
    border: 0.1875rem solid #1a3a26;
    border-radius: 1.625rem;
    cursor: pointer;
    box-shadow:
        0 0.25rem 0 #1a3a26,
        0 0.5rem 1rem var(--shadow-soft);
    transition: all 0.15s ease;
    margin: 0.5rem 0;
}

#action-button:hover:not(:disabled) {
    transform: translateY(-0.125rem);
    box-shadow:
        0 0.375rem 0 #1a3a26,
        0 0.75rem 1.25rem var(--shadow-strong);
}

#action-button:active:not(:disabled) {
    transform: translateY(0.125rem);
    box-shadow: 0 0.125rem 0 #1a3a26;
}

#action-button:disabled {
    background: linear-gradient(160deg, #8a8a8a 0%, #5a5a5a 100%);
    border-color: #3a3a3a;
    box-shadow: 0 0.125rem 0 #3a3a3a;
    cursor: not-allowed;
}

#action-button.pulse {
    animation: buttonPulse 2s ease-in-out infinite;
}

@keyframes buttonPulse {
    0%, 100% { box-shadow: 0 0.25rem 0 #1a3a26, 0 0.5rem 1rem rgba(45, 102, 68, 0.3); }
    50%       { box-shadow: 0 0.25rem 0 #1a3a26, 0 0.5rem 1.5rem rgba(45, 102, 68, 0.7); }
}

#action-text {
    color: var(--chalk);
    font-size: 1.125rem;
    font-weight: 800;
    letter-spacing: 0.1875rem;
    font-family: 'Georgia', serif;
}

#action-button:disabled #action-text { color: #ccc; }

/* ============ GAME TITLE ============ */
.game-title {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.25rem 0 0.375rem;
}

.title-letters {
    color: var(--ink-muted);
    font-size: 0.6875rem;
    letter-spacing: 0.1875rem;
    text-transform: uppercase;
    font-weight: 700;
}

.title-bingo {
    color: var(--board-green);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.1875rem;
    font-family: 'Georgia', serif;
    text-shadow: 0.0625rem 0.0625rem 0 rgba(45, 102, 68, 0.2);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 400px) {
    .tile { width: 3rem; height: 3rem; font-size: 1.5rem; }
    .bingo-grid { gap: 0.375rem; }
    .called-stamp { width: 4.75rem; height: 4.75rem; }
    #called-letter { font-size: 2.5rem; }
    .bet-btn { width: 2.625rem; height: 1.875rem; font-size: 0.75rem; }
    #action-button { width: 9.5rem; height: 2.875rem; }
    #action-text { font-size: 1rem; }
    .prize-name { font-size: 0.5625rem; }
    .prize-mult { font-size: 0.8125rem; }
}

@media (max-height: 720px) {
    .called-stamp { width: 4.5rem; height: 4.5rem; }
    #called-letter { font-size: 2.25rem; }
    .tile { width: 3rem; height: 3rem; font-size: 1.5rem; }
    .card-frame { padding: 0.5rem; }
    .called-stamp-wrap { margin: 0.25rem 0 0.5rem; }
    #action-button { height: 2.875rem; }
}
