/* Word Chain — GameCMB (gamecmb.com)
   Modern Casual Arcade: dark navy background, neon blue/purple/cyan
   accents, glassmorphism cards, soft glow, minimal childish color noise
   (concept section 41). */

:root {
    --bg-0: #070a14;
    --bg-1: #0d1226;
    --bg-2: #131a36;
    --cyan: #7ef9ff;
    --violet: #a855f7;
    --pink: #ff5cf4;
    --amber: #ffd23f;
    --danger: #ff4d6d;
    --text: #f4f6ff;
    --text-dim: #9aa3c7;
    --glass: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.12);
    --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
    background: radial-gradient(circle at 50% -10%, var(--bg-2), var(--bg-0) 60%);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

button {
    font-family: inherit;
    cursor: pointer;
}

a { color: var(--cyan); }

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------------------------------------------------------------- */
/* Layout shell                                                      */
/* ---------------------------------------------------------------- */
.app-shell {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 16px 32px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
}

.topbar-brand {
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    font-size: 13px;
}

.topbar-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text);
    font-size: 18px;
}
.icon-btn.active {
    border-color: var(--cyan);
    box-shadow: 0 0 12px rgba(126, 249, 255, 0.5);
}

.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ---------------------------------------------------------------- */
/* Glass card / buttons                                              */
/* ---------------------------------------------------------------- */
.glass-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 12px 20px;
    border-radius: 14px;
    border: none;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.02em;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.96); }

.btn-primary {
    background: linear-gradient(135deg, var(--cyan), var(--violet));
    color: #0a0e1a;
    box-shadow: 0 6px 24px rgba(168, 85, 247, 0.45);
}
.btn-huge {
    width: 100%;
    padding: 18px 20px;
    font-size: 20px;
    border-radius: 18px;
}
.btn-secondary {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text);
}
.btn-ghost {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
}

/* ---------------------------------------------------------------- */
/* Home screen                                                       */
/* ---------------------------------------------------------------- */
#screen-home {
    align-items: center;
    text-align: center;
    padding-top: 4vh;
    gap: 18px;
}

.home-logo {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: var(--text-dim);
}

.home-title {
    font-size: clamp(40px, 12vw, 64px);
    font-weight: 900;
    margin: 0;
    background: linear-gradient(135deg, var(--cyan), var(--violet) 60%, var(--pink));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: 0.01em;
    text-shadow: 0 0 40px rgba(126, 249, 255, 0.15);
}

.home-subtitle {
    color: var(--text-dim);
    font-size: 16px;
    max-width: 320px;
    margin: 0 auto;
}

.home-play-wrap {
    width: 100%;
    max-width: 320px;
    margin-top: 8px;
}

.home-best {
    font-size: 14px;
    color: var(--amber);
    font-weight: 700;
}

.home-hint {
    color: var(--text-dim);
    font-size: 13px;
}

.seo-section {
    text-align: left;
    margin-top: 40px;
    width: 100%;
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.6;
}
.seo-section h2 {
    color: var(--text);
    font-size: 18px;
    margin: 28px 0 8px;
}
.seo-section h3 {
    color: var(--text);
    font-size: 15px;
    margin: 16px 0 4px;
}
.related-games {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.related-games a {
    padding: 8px 14px;
    border-radius: 10px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    text-decoration: none;
    font-size: 13px;
}

/* ---------------------------------------------------------------- */
/* Game screen                                                       */
/* ---------------------------------------------------------------- */
#game-stage {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding-top: 12px;
    transition: box-shadow 0.3s ease;
}

#fx-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.hud-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}
.hud-score-block { text-align: left; }
.hud-label {
    font-size: 11px;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    text-transform: uppercase;
}
.hud-score {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
}
.hud-words {
    font-size: 12px;
    color: var(--text-dim);
}

.badge-row {
    display: flex;
    gap: 8px;
    min-height: 30px;
}
.combo-badge, .fever-badge {
    padding: 4px 12px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 14px;
}
.combo-badge {
    background: rgba(255, 210, 63, 0.15);
    color: var(--amber);
    border: 1px solid rgba(255, 210, 63, 0.4);
}
.fever-badge {
    background: rgba(255, 92, 244, 0.18);
    color: var(--pink);
    border: 1px solid rgba(255, 92, 244, 0.5);
    animation: pulse 0.6s ease-in-out infinite alternate;
}
@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.08); }
}

.current-word-wrap {
    text-align: center;
    margin-top: 4px;
}
.current-word {
    font-size: clamp(30px, 9vw, 46px);
    font-weight: 900;
    letter-spacing: 0.04em;
    word-break: break-all;
}
.next-letter-label {
    font-size: 11px;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-top: 6px;
}
.next-letter-badge {
    width: 76px;
    height: 76px;
    margin: 8px auto 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    font-weight: 900;
    color: var(--bg-0);
    background: radial-gradient(circle at 35% 30%, var(--cyan), var(--violet));
    box-shadow: 0 0 30px rgba(126, 249, 255, 0.55), 0 0 60px rgba(168, 85, 247, 0.35);
}
.next-letter-badge.letter-pop {
    animation: letterPop 0.32s ease;
}
@keyframes letterPop {
    0% { transform: scale(0.8); }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.chain-history {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 6px 4px;
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
}
.chain-history::-webkit-scrollbar { display: none; }
.chain-word {
    padding: 3px 8px;
    border-radius: 8px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    flex: 0 0 auto;
}
.chain-arrow { flex: 0 0 auto; opacity: 0.6; }

.input-row {
    width: 100%;
    margin-top: auto;
}
#word-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}
#word-input {
    width: 100%;
    min-height: 52px;
    min-width: 0;
    padding: 14px 16px;
    font-size: 18px; /* >=16px so iOS doesn't auto-zoom */
    border-radius: 14px;
    border: 2px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#word-input:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(126, 249, 255, 0.2);
}
#word-input.input-success {
    border-color: #3ddc97;
    box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.25);
}
#word-input.input-error {
    border-color: var(--danger);
    animation: shake 0.28s ease;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.feedback-text {
    min-height: 20px;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
}
.feedback-success { color: #3ddc97; }
.feedback-error { color: var(--danger); }

.timer-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
}
.timer-bar-track {
    flex: 1;
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}
.timer-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--cyan), var(--violet));
    transition: width 0.1s linear;
}
.timer-bar-fill.timer-danger {
    background: linear-gradient(90deg, var(--danger), var(--amber));
}
#timer-text {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 14px;
    min-width: 46px;
    text-align: right;
}
#game-stage.timer-danger-pulse {
    animation: screenPulse 0.5s ease-in-out infinite alternate;
}
@keyframes screenPulse {
    from { box-shadow: inset 0 0 0 rgba(255, 77, 109, 0); }
    to { box-shadow: inset 0 0 60px rgba(255, 77, 109, 0.18); }
}
#screen-game.fever-active #game-stage {
    box-shadow: inset 0 0 90px rgba(255, 92, 244, 0.18);
}

@media (prefers-reduced-motion: reduce) {
    .fever-badge, #game-stage.timer-danger-pulse, .next-letter-badge.letter-pop, #word-input.input-error {
        animation: none !important;
    }
}

/* Countdown overlay */
#countdown-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(7, 10, 20, 0.75);
    backdrop-filter: blur(6px);
    border-radius: var(--radius);
}
#countdown-value {
    font-size: 96px;
    font-weight: 900;
    color: var(--cyan);
    text-shadow: 0 0 40px rgba(126, 249, 255, 0.6);
}
.countdown-pop {
    animation: countdownPop 0.65s ease;
}
@keyframes countdownPop {
    0% { transform: scale(0.6); opacity: 0; }
    40% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

#pause-overlay {
    position: absolute;
    inset: 0;
    z-index: 9;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(7, 10, 20, 0.85);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.08em;
    border-radius: var(--radius);
}

/* ---------------------------------------------------------------- */
/* Result screen                                                     */
/* ---------------------------------------------------------------- */
#screen-result {
    align-items: center;
    text-align: center;
    gap: 14px;
    padding-top: 6vh;
}
.result-card {
    width: 100%;
    max-width: 380px;
    padding: 28px 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}
.result-label {
    font-size: 13px;
    color: var(--text-dim);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.result-score {
    font-size: 48px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--cyan), var(--violet));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
#new-best-banner {
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(255, 210, 63, 0.15);
    border: 1px solid rgba(255, 210, 63, 0.5);
    color: var(--amber);
    font-weight: 800;
    font-size: 13px;
}
.result-pending-note {
    color: var(--text-dim);
    font-size: 13px;
}

.result-actions {
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.result-actions-row {
    display: flex;
    gap: 10px;
}
.result-actions-row .btn { flex: 1; }

#share-result {
    font-size: 12px;
    color: var(--text-dim);
    min-height: 16px;
}

.nickname-section {
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 6px;
}
.nickname-row {
    display: flex;
    gap: 8px;
}
#nickname-input {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-size: 16px;
}
.nickname-result {
    font-size: 13px;
    min-height: 16px;
}

/* ---------------------------------------------------------------- */
/* Modals                                                             */
/* ---------------------------------------------------------------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(5, 7, 14, 0.7);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}
@media (min-width: 600px) {
    .modal-backdrop { align-items: center; }
}
.modal-panel {
    width: 100%;
    max-width: 440px;
    max-height: 82vh;
    overflow-y: auto;
    border-radius: 24px 24px 0 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
@media (min-width: 600px) {
    .modal-panel { border-radius: 24px; }
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-title { font-size: 18px; font-weight: 800; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 22px;
    min-height: 44px;
    min-width: 44px;
}

.leaderboard-tabs {
    display: flex;
    gap: 6px;
}
.leaderboard-tab {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-dim);
    font-weight: 700;
    font-size: 13px;
    min-height: 44px;
}
.leaderboard-tab.active {
    background: var(--glass);
    color: var(--cyan);
    border-color: var(--cyan);
}
#leaderboard-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.leaderboard-row {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--glass);
}
.leaderboard-row.top-rank.rank-1 { border: 1px solid var(--amber); }
.leaderboard-row.top-rank.rank-2 { border: 1px solid #c8d0e0; }
.leaderboard-row.top-rank.rank-3 { border: 1px solid #d3894f; }
.lb-rank { font-weight: 800; color: var(--text-dim); }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 800; color: var(--cyan); }
.leaderboard-loading, .leaderboard-empty {
    text-align: center;
    color: var(--text-dim);
    padding: 20px 0;
}

.how-to-content { font-size: 14px; line-height: 1.6; color: var(--text-dim); }
.how-to-content strong { color: var(--text); }

/* ---------------------------------------------------------------- */
/* Ad slots (concept section 52 — never overlapping Play/Submit)      */
/* ---------------------------------------------------------------- */
.ad-slot {
    width: 100%;
    min-height: 90px;
    margin: 16px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--glass-border);
    border-radius: 12px;
    color: var(--text-dim);
    font-size: 12px;
    letter-spacing: 0.05em;
}

/* Footer watermark */
.site-footer {
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
    padding: 18px 0 4px;
}
