/* ══════════════════════════════════════════════════════════════
   GammonBase Games — Arcade-feel styling
   ══════════════════════════════════════════════════════════════ */

/* ── Hub Page ── */
.games-hub { max-width:1100px; margin:0 auto; padding:2rem 1.2rem; }
.games-hub h1 { font-size:2rem; font-weight:800; letter-spacing:-.02em; margin-bottom:.3rem; }
.games-hub .hub-subtitle { color:var(--color-text-muted); font-size:.85rem; margin-bottom:2rem; }

.games-section { margin-bottom:2.5rem; }
.games-section h2 { font-size:.7rem; text-transform:uppercase; letter-spacing:.15em; font-weight:700; color:var(--color-accent); margin-bottom:1rem; padding-bottom:.4rem; border-bottom:1px solid var(--color-border); }

.games-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(280px, 1fr)); gap:1rem; }

/* ── Game Card ── */
.game-card { display:flex; align-items:flex-start; gap:1rem; padding:1rem 1.2rem; background:var(--color-surface-alt); border:1px solid var(--color-border); border-radius:var(--radius); text-decoration:none; color:var(--color-text); transition:all .2s ease; position:relative; overflow:hidden; }
.game-card:hover { border-color:var(--color-accent); background:var(--color-surface); transform:translateY(-2px); box-shadow:0 8px 24px -8px rgba(var(--color-accent-rgb),.2); }
.game-card:hover .gc-icon { transform:scale(1.1); }
.game-card--disabled { opacity:.5; pointer-events:none; }

.gc-icon { font-size:1.8rem; line-height:1; flex-shrink:0; transition:transform .2s ease; }
.gc-body { flex:1; min-width:0; }
.gc-title { font-size:.85rem; font-weight:700; margin:0 0 .25rem; letter-spacing:.01em; color:#fff; }
.gc-desc { font-size:.72rem; color:#a8b5c5; margin:0; line-height:1.4; }
.gc-badge { position:absolute; top:.6rem; right:.6rem; font-size:.55rem; font-weight:700; text-transform:uppercase; letter-spacing:.1em; color:var(--color-accent); background:rgba(var(--color-accent-rgb),.12); padding:.15rem .45rem; border-radius:3px; }
.gc-coming-soon { position:absolute; bottom:.6rem; right:.6rem; font-size:.55rem; font-weight:600; color:var(--color-text-muted); font-style:italic; }

/* ── Score Bar ── */
.game-score-bar { display:flex; align-items:center; justify-content:space-between; padding:.4rem 1rem; background:var(--color-surface); border:1px solid var(--color-border); border-radius:var(--radius-sm); margin-bottom:.4rem; gap:1rem; flex-wrap:wrap; }

.gsb-left, .gsb-center, .gsb-right { display:flex; align-items:center; gap:1.2rem; }
.gsb-label { display:block; font-size:.5rem; text-transform:uppercase; letter-spacing:.12em; font-weight:700; color:var(--color-text-muted); }
.gsb-value { display:block; font-size:1.3rem; font-weight:800; font-variant-numeric:tabular-nums; line-height:1.1; color:#fff; }

.gsb-score .gsb-value { color:var(--color-accent); }
.gsb-pop { animation:gsb-pop .3s ease; }
@keyframes gsb-pop { 0% { transform:scale(1); } 50% { transform:scale(1.25); } 100% { transform:scale(1); } }

.gsb-streak--active .gsb-value { color:var(--color-positive); }
.gsb-shake { animation:gsb-shake .4s ease; }
@keyframes gsb-shake { 0%,100% { transform:translateX(0); } 20% { transform:translateX(-6px); } 40% { transform:translateX(6px); } 60% { transform:translateX(-4px); } 80% { transform:translateX(4px); } }

.gsb-multiplier { font-size:.7rem; font-weight:800; color:var(--color-warning); background:rgba(255,200,90,.15); padding:.1rem .35rem; border-radius:3px; margin-left:.25rem; }

.gsb-timer--urgent .gsb-value { color:var(--color-danger); animation:gsb-pulse 1s ease infinite; }
@keyframes gsb-pulse { 0%,100% { opacity:1; } 50% { opacity:.5; } }

.gsb-heart { color:var(--color-danger); font-size:1.1rem; margin-right:.15rem; }

/* ── Result Overlay ── */
.game-result-overlay { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; z-index:50; pointer-events:none; animation:gro-fade .5s ease forwards; }
.gro--correct { background:rgba(76,205,123,.12); }
.gro--wrong { background:rgba(255,98,93,.12); }
@keyframes gro-fade { 0% { opacity:1; } 70% { opacity:1; } 100% { opacity:0; } }

.gro-icon { font-size:3rem; font-weight:900; line-height:1; }
.gro--correct .gro-icon { color:var(--color-positive); }
.gro--wrong .gro-icon { color:var(--color-danger); }

.gro-points { font-size:1.4rem; font-weight:800; color:var(--color-positive); margin-top:.3rem; }
.gro-speed { font-size:.65rem; color:var(--color-positive); opacity:.7; }
.gro-correct-answer { font-size:.85rem; font-weight:600; color:var(--color-text); margin-top:.4rem; }
.gro-diff { font-size:.7rem; color:var(--color-text-muted); }

/* ── End Screen ── */
.game-end-screen { max-width:480px; margin:2rem auto; text-align:center; padding:2rem; background:var(--color-surface-alt); border:1px solid var(--color-border); border-radius:var(--radius-lg); }

.ges-title { font-size:1.6rem; font-weight:800; margin-bottom:1.5rem; }

.ges-stats { display:grid; grid-template-columns:repeat(2,1fr); gap:1rem; margin-bottom:1.5rem; }
.ges-stat { padding:.8rem; background:var(--color-surface); border-radius:var(--radius-sm); }
.ges-stat--hero { grid-column:1 / -1; padding:1.2rem; }
.ges-stat-value { display:block; font-size:1.5rem; font-weight:800; font-variant-numeric:tabular-nums; }
.ges-stat--hero .ges-stat-value { font-size:2.4rem; color:var(--color-accent); }
.ges-stat-label { display:block; font-size:.55rem; text-transform:uppercase; letter-spacing:.12em; font-weight:700; color:var(--color-text-muted); margin-top:.2rem; }

.ges-pb { font-size:1rem; font-weight:800; color:var(--color-warning); margin-bottom:1rem; animation:ges-glow 1.5s ease infinite; }
@keyframes ges-glow { 0%,100% { text-shadow:0 0 8px rgba(255,200,90,.4); } 50% { text-shadow:0 0 20px rgba(255,200,90,.7); } }

.ges-prev-best { font-size:.75rem; color:var(--color-text-muted); margin-bottom:1rem; }

.ges-login-nudge { font-size:.75rem; color:var(--color-text-muted); margin-bottom:1.2rem; padding:.6rem; background:rgba(var(--color-accent-rgb),.08); border-radius:var(--radius-sm); }
.ges-login-nudge a { color:var(--color-accent); text-decoration:underline; font-weight:600; }

.ges-actions { display:flex; gap:.75rem; justify-content:center; }
.ges-play-again { font-size:.85rem; padding:.65rem 1.5rem; }

/* ── Game Page Layout ── */
.game-page { max-width:900px; margin:0 auto; padding:.5rem 1rem; }
.game-page h1 { font-size:1.5rem; font-weight:800; margin-bottom:.2rem; }
.game-page .game-subtitle { color:var(--color-text-muted); font-size:.78rem; margin-bottom:1.2rem; }

/* ── Timer bar ── */
.timer-bar { flex-shrink:0; height:6px; background:rgba(255,255,255,.06); border-radius:3px; overflow:hidden; }
.timer-bar__fill { height:100%; border-radius:3px; transition:width 1s linear; }

/* ── Stats panel ── */
.game-stats-panel { display:none; }
.gsp-item { text-align:center; }
.gsp-label { display:block; font-size:.4rem; text-transform:uppercase; letter-spacing:.1em; font-weight:700; color:var(--color-text-muted,#b9c4d3); }
.gsp-value { display:block; font-size:1rem; font-weight:800; font-variant-numeric:tabular-nums; color:#fff; }
.gsp-score { color:var(--color-accent,#ff8a3c); }
.gsp-streak { color:var(--color-positive,#4ccd7b); }
.gsp-time { font-size:1.4rem; }
.gsp-urgent { animation:gsp-blink .8s ease infinite; padding:.3rem .5rem; border-radius:6px; }
.gsp-urgent .gsp-value { color:#ff625d; }
@keyframes gsp-blink { 0%,100% { background:transparent; } 50% { background:rgba(255,50,50,.2); } }

/* Playing state: fill available space in GameLayout */
.game-page--playing { flex:1; display:flex; flex-direction:column; min-height:0; overflow:hidden; }
.game-page--playing .game-play-area { flex:1; display:flex; flex-direction:row; min-height:0; overflow:hidden; align-items:center; }
.game-page--playing .game-board-wrapper { flex:1; display:flex; justify-content:center; align-items:center; min-height:0; overflow:hidden; order:2; min-width:0; align-self:stretch; }
.game-page--playing .game-board-wrapper svg.backgammon-board-svg { max-width:100%; max-height:100%; display:block; width:auto; height:auto; }
.game-page--playing .game-stats-panel { display:flex !important; flex-direction:column; justify-content:center; align-items:center; gap:.8rem;
    order:1; flex:0 0 80px; padding:.5rem; }
.game-page--playing .game-controls { flex:0 0 auto; width:200px; display:flex; flex-direction:column; justify-content:center; padding:0 .5rem; order:3; align-self:stretch; }
.game-page--playing .game-score-bar { display:none; }

/* Landscape mobile: tighter spacing */
@media (orientation:landscape) and (max-height:500px) {
    .game-layout { padding:0; }
    .game-back-btn { display:none; }
    .timer-bar { position:fixed; top:0; left:0; right:0; z-index:10; height:4px; border-radius:0; }
    .game-page--playing .game-play-area { padding-top:4px; }
    .game-page--playing .game-stats-panel { flex:0 0 60px; gap:.5rem; padding:.2rem; }
    .gsp-time { font-size:1.1rem; }
    .game-page--playing .game-controls { width:28%; padding:0 .2rem; }
    .pip-choices { display:flex !important; flex-direction:column; gap:.2rem; }
    .app-theme .game-play-area button.pip-choice { min-width:unset !important; width:100%; padding:.3rem .5rem; font-size:1rem; }
    .pip-question { display:none; }
    .pip-choices--locked, .pip-choices--done { display:none !important; }
}
/* Left-hand mode: flip choices to left, stats to right */
.game-page--playing.left-hand .game-stats-panel { order:3; }
.game-page--playing.left-hand .game-controls { order:1; }

/* Portrait: stats top, board middle, answers bottom, timer bar on left edge */
@media (orientation:portrait) {
    .timer-bar { position:fixed; left:0; top:0; bottom:0; width:5px; height:auto; border-radius:0; z-index:10; display:flex; flex-direction:column; justify-content:flex-end; }
    .timer-bar__fill { width:100% !important; height:var(--timer-pct, 100%) !important; transition:height 1s linear; }
    .game-back-btn { display:none; }
    .game-layout { padding:0 !important; }
    .game-page--playing { padding:0 0 0 8px !important; max-width:100% !important; width:100% !important; height:100dvh !important; overflow:hidden !important; }
    .game-page--playing .game-score-bar { display:none; }
    .game-page--playing .game-play-area {
        display:grid !important; grid-template-rows:1fr auto 1fr; height:100% !important; width:100%; overflow:hidden !important;
    }
    /* Stats: 2x2, fills top 40dvh, matches buttons */
    .game-page--playing .game-stats-panel {
        display:grid !important; grid-template-columns:1fr 1fr; grid-template-rows:1fr 1fr;
        width:100%; height:100%; padding:0; gap:0; text-align:center;
        background:linear-gradient(180deg, #1a1208 0%, #0f1014 100%); border-bottom:1px solid rgba(255,138,60,.15);
    }
    .gsp-item { display:flex !important; flex-direction:column; align-items:center; justify-content:center;
        border:1px solid rgba(255,138,60,.12); }
    .gsp-label { font-size:.5rem; margin-bottom:.15rem; }
    .gsp-value { font-size:2rem; line-height:1; }
    .gsp-time { font-size:2.5rem; }
    /* Board: row 2, centered */
    .game-page--playing .game-board-wrapper {
        display:flex; justify-content:center; align-items:center; overflow:hidden; min-height:0; align-self:auto !important;
    }
    .game-page--playing .game-board-wrapper svg.backgammon-board-svg { max-height:100%; }
    .game-page--playing .game-controls { align-self:auto; }
    /* Buttons: 2x2, row 3, STRETCH to fill all available space */
    .game-page--playing .game-controls { width:100%; padding:0; height:100%; display:flex; flex-direction:column; }
    .game-page--playing .game-controls .pip-question { display:none; }
    .game-page--playing .game-controls .pip-choices {
        display:grid !important; grid-template-columns:1fr 1fr; grid-template-rows:1fr 1fr; gap:0; width:100%; height:100%; flex:1;
    }
    .app-theme .game-play-area button.pip-choice {
        font-size:2rem !important; width:100% !important; height:100% !important; min-height:0 !important;
        border-radius:0 !important; border:1px solid rgba(255,138,60,.3) !important;
        background:linear-gradient(180deg, #2a1f14 0%, #1a1208 100%) !important;
        color:#ffd080 !important; text-shadow:0 0 8px rgba(255,180,80,.3) !important;
        display:flex !important; align-items:center !important; justify-content:center !important;
        padding:0 !important; letter-spacing:0 !important; text-transform:none !important;
    }
    .app-theme .game-play-area button.pip-choice:hover:not(:disabled),
    .app-theme .game-play-area button.pip-choice:active:not(:disabled) {
        background:linear-gradient(180deg, #ff8a3c, #cc6a20) !important; color:#fff !important;
        text-shadow:0 0 12px rgba(255,255,255,.4) !important;
        border-color:#ffb347 !important;
    }
    .game-page--playing .game-controls .pip-choices--locked { display:none !important; }
    .game-page--playing .game-controls .pip-question--locked { display:none; }
}

.game-mode-picker { display:flex; gap:.5rem; margin-bottom:1.5rem; flex-wrap:wrap; }
.game-mode-btn { padding:.5rem 1rem; font-size:.72rem; font-weight:700; text-transform:uppercase; letter-spacing:.08em; border:1px solid var(--color-border); border-radius:var(--radius-sm); background:var(--color-surface-alt); color:var(--color-text-muted); cursor:pointer; transition:.18s ease; }
.game-mode-btn:hover { border-color:var(--color-accent); color:var(--color-text); }
.game-mode-btn--active { background:var(--gradient-accent); color:#121317; border-color:var(--color-accent); box-shadow:0 4px 14px -4px rgba(var(--color-accent-rgb),.4); }

.game-play-area { position:relative; }

.game-board-wrapper { display:flex; justify-content:center; margin-bottom:.25rem; }

.game-input-row { display:flex; gap:.75rem; align-items:flex-end; justify-content:center; margin-bottom:.5rem; }
.game-input-group { display:flex; flex-direction:column; align-items:center; }
.game-input-group label { font-size:.55rem; text-transform:uppercase; letter-spacing:.12em; font-weight:700; color:var(--color-text-muted); margin-bottom:.3rem; }
.game-input-group input { width:100px; text-align:center; font-size:1.2rem; font-weight:700; font-variant-numeric:tabular-nums; padding:.5rem; background:var(--color-input-bg,#b9c4d3); border:2px solid var(--color-input-border,#4a5568); border-radius:var(--radius-sm); color:var(--color-text); transition:.18s ease; }
.game-input-group input:focus { border-color:var(--color-accent); box-shadow:0 0 0 3px var(--color-focus); outline:none; }
.game-input-group input.input--correct { border-color:var(--color-positive); background:rgba(76,205,123,.08); }
.game-input-group input.input--wrong { border-color:var(--color-danger); background:rgba(255,98,93,.08); }

.game-submit-btn { padding:.55rem 1.5rem; font-size:.8rem; font-weight:700; }

.game-hint { text-align:center; font-size:.7rem; color:var(--color-text-muted); margin-top:.5rem; }

/* ── Game choice buttons — must beat .app-theme button specificity ── */
.app-theme .game-play-area button.pip-choice {
    min-width:90px; padding:.7rem 1.6rem; font-size:1.4rem; font-weight:800; font-variant-numeric:tabular-nums;
    letter-spacing:.02em; text-transform:none;
    border:1px solid rgba(180,150,100,.35); border-radius:6px;
    background:linear-gradient(180deg, #1c1a16 0%, #12100c 100%);
    color:#e8d5b0; cursor:pointer; transition:all .15s ease;
    text-align:center; justify-content:center; gap:0;
    box-shadow:inset 0 1px 0 rgba(255,220,160,.06), 0 2px 6px rgba(0,0,0,.4);
}
.app-theme .game-play-area button.pip-choice:hover:not(:disabled) {
    background:linear-gradient(180deg, #2a2418 0%, #1c1810 100%);
    color:#ffd98c; border-color:rgba(220,180,100,.5);
    transform:translateY(-1px);
    box-shadow:inset 0 1px 0 rgba(255,220,160,.1), 0 4px 14px rgba(0,0,0,.5), 0 0 8px rgba(255,200,120,.08);
}
.app-theme .game-play-area button.pip-choice.pip-choice--correct {
    background:linear-gradient(180deg, #1a2a1a, #0c1a0c); border-color:rgba(76,205,123,.5); color:#6eff9e;
    box-shadow:inset 0 1px 0 rgba(100,255,150,.08), 0 0 10px rgba(76,205,123,.2);
}
.app-theme .game-play-area button.pip-choice.pip-choice--wrong {
    background:linear-gradient(180deg, #2a1616, #1a0c0c); border-color:rgba(255,80,80,.4); color:#ff8888;
    box-shadow:inset 0 1px 0 rgba(255,100,100,.06), 0 0 10px rgba(255,50,50,.15);
}
.app-theme .game-play-area button.pip-choice.pip-choice--dim { opacity:.12; }
.app-theme .game-play-area button.pip-choice.pip-choice--bonus { border-color:rgba(200,170,100,.4); }
.app-theme .game-play-area button.pip-choice.pip-choice--locked { opacity:.18; pointer-events:none; border-color:rgba(80,70,50,.3); color:#4a4030; box-shadow:none; }

/* ── Shot Counter ── */
.shot-blot-label { text-align:center; font-size:.85rem; margin:.75rem 0 .5rem; color:var(--color-text); }
.shot-blot-label strong { color:var(--color-accent, #e67e22); font-weight:700; }

/* ── Responsive ── */
@media (max-width:600px) {
    .games-grid { grid-template-columns:1fr; }
    .game-layout { padding:.15rem .3rem 0; }
    .game-page--playing .game-board-wrapper .board-container { zoom:0.6; }
    .game-score-bar { padding:.15rem .4rem; gap:.3rem; }
    .gsb-value { font-size:.8rem; }
    .gsb-label { font-size:.32rem; }
    .ges-stats { grid-template-columns:1fr 1fr; }
    .pip-choices { gap:.3rem; }
    .app-theme .game-play-area button.pip-choice { min-width:50px; padding:.3rem .5rem; font-size:.9rem; }
    .pip-question { font-size:.7rem; margin:.1rem 0; }
    .game-back-btn { font-size:.55rem; }
}
