/* Word Bomb -- GameCMB (gamecmb.com)
   Dark neon arcade bomb theme: dark background, red/orange bomb glow,
   electric blue/purple accents, bright white type, glowing UI
   (concept section 4's own visual brief). Mobile-first, max content
   width ~560px, centered on larger screens (concept section 38). */

:root {
    --bg-0: #0a0b14;
    --bg-1: #10122099;
    --panel: #151829;
    --panel-2: #1c2036;
    --ink: #f5f6ff;
    --ink-dim: #9aa0c0;
    --accent-blue: #00e5ff;
    --accent-purple: #8b5cf6;
    --accent-gold: #ffd166;
    --danger: #ff4d67;
    --danger-2: #ff8a3d;
    --safe-glow: #00e5ff;
    --radius: 18px;
    --radius-sm: 10px;
    --shadow-glow: 0 0 24px rgba(0, 229, 255, 0.25);
}

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

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-0);
    color: var(--ink);
    font-family: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 50% -10%, rgba(139, 92, 246, 0.25), transparent 60%),
        radial-gradient(ellipse at 50% 110%, rgba(0, 229, 255, 0.12), transparent 55%),
        var(--bg-0);
}

.app {
    max-width: 560px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 0 16px;
}

#screen-game {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: 24px;
}
#screen-game #game-stage {
    flex: 1;
    display: flex;
    align-items: center;
}
#screen-game .bomb-wrap { width: 100%; }

a { color: var(--accent-blue); }

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    color: var(--ink);
    background: none;
}
button:focus-visible, input:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 1rem;
    min-height: 48px;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, var(--danger-2), var(--danger));
    color: #fff;
    box-shadow: 0 8px 24px rgba(255, 77, 103, 0.4);
}
.btn-secondary {
    background: var(--panel-2);
    color: var(--ink);
    border: 1px solid #2c3152;
}
.btn-ghost {
    background: transparent;
    color: var(--ink-dim);
    border: 1px solid #2c3152;
}
.btn-lg { width: 100%; padding: 18px; font-size: 1.15rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--panel-2);
    font-size: 1.1rem;
}
.icon-btn.active { background: var(--accent-purple); }

/* ---------------- Home ---------------- */
.home-hero {
    text-align: center;
    padding: 48px 0 16px;
}
.home-bomb-emoji {
    font-size: 4rem;
    filter: drop-shadow(0 0 20px rgba(255, 77, 103, 0.6));
    animation: float 3s ease-in-out infinite;
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
.home-title {
    font-size: 2.4rem;
    font-weight: 900;
    margin: 8px 0 4px;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #fff, var(--accent-blue));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.home-tagline {
    color: var(--ink-dim);
    font-size: 1rem;
    margin: 0 0 28px;
}
.home-actions { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.home-secondary { display: flex; gap: 10px; }
.home-secondary .btn { flex: 1; padding: 12px; font-size: 0.85rem; }
.home-best {
    text-align: center;
    color: var(--ink-dim);
    font-size: 0.9rem;
    margin-bottom: 24px;
}
.home-best strong { color: var(--accent-gold); }

.seo-content {
    border-top: 1px solid #22263f;
    padding: 28px 0 40px;
    color: var(--ink-dim);
    font-size: 0.92rem;
    line-height: 1.6;
}
.seo-content h2 { color: var(--ink); font-size: 1.15rem; margin: 24px 0 10px; }
.seo-content h2:first-child { margin-top: 0; }
.seo-content ul { padding-left: 20px; }
.related-games { display: flex; flex-wrap: wrap; gap: 8px; }
.related-games a {
    background: var(--panel-2);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    text-decoration: none;
}

.ad-slot {
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--panel);
    border: 1px dashed #2c3152;
    border-radius: var(--radius-sm);
    color: var(--ink-dim);
    font-size: 0.75rem;
    margin: 20px 0;
}

/* ---------------- Countdown ---------------- */
#screen-countdown {
    position: fixed;
    inset: 0;
    background: rgba(5, 6, 12, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}
#countdown-value {
    font-size: 6rem;
    font-weight: 900;
    color: var(--accent-blue);
    text-shadow: 0 0 40px var(--accent-blue);
}
#countdown-value.pop { animation: countdown-pop 0.4s ease; }
@keyframes countdown-pop {
    0% { transform: scale(0.4); opacity: 0; }
    50% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); }
}

/* ---------------- Game screen ---------------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0 8px;
}
.topbar-title { font-weight: 800; font-size: 1rem; display: flex; align-items: center; gap: 6px; }
.topbar-actions { display: flex; gap: 8px; }

.hud-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 6px 4px 14px;
}
.hud-block { display: flex; flex-direction: column; }
.hud-label { font-size: 0.7rem; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 1px; }
.hud-value { font-size: 1.6rem; font-weight: 800; }
#hud-combo {
    display: inline-block;
    margin-top: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--danger-2), var(--accent-gold));
    color: #1a1200;
    font-weight: 800;
    font-size: 0.85rem;
    animation: combo-pulse 0.6s ease infinite;
}
@keyframes combo-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}
#fever-banner {
    text-align: center;
    font-weight: 900;
    color: var(--danger);
    text-shadow: 0 0 16px var(--danger);
    letter-spacing: 2px;
    margin-bottom: 8px;
    animation: fever-flicker 0.5s ease infinite;
}
@keyframes fever-flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

#game-stage {
    position: relative;
    background: var(--panel);
    border-radius: var(--radius);
    padding: 24px 16px 20px;
    overflow: hidden;
    border: 1px solid #262b4a;
}
#fx-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.bomb-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.bomb {
    font-size: 4.5rem;
    line-height: 1;
    filter: drop-shadow(0 0 20px rgba(0, 229, 255, 0.35));
    transition: filter 0.2s ease;
}
.bomb-safe { animation: bomb-idle 2s ease-in-out infinite; }
.bomb-warning { animation: bomb-idle 1.2s ease-in-out infinite; filter: drop-shadow(0 0 24px rgba(255, 209, 102, 0.5)); }
.bomb-danger { animation: bomb-shake 0.35s ease-in-out infinite; filter: drop-shadow(0 0 30px rgba(255, 138, 61, 0.65)); }
.bomb-critical { animation: bomb-flash 0.18s ease-in-out infinite; filter: drop-shadow(0 0 40px rgba(255, 77, 103, 0.9)); }
@keyframes bomb-idle {
    0%, 100% { transform: translateY(0) rotate(0); }
    50% { transform: translateY(-4px) rotate(-2deg); }
}
@keyframes bomb-shake {
    0%, 100% { transform: translateX(0) rotate(0); }
    25% { transform: translateX(-3px) rotate(-3deg); }
    75% { transform: translateX(3px) rotate(3deg); }
}
@keyframes bomb-flash {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.75; transform: scale(1.08); }
}

#timer-value {
    font-size: 1.8rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}
.timer-bar {
    width: 100%;
    max-width: 220px;
    height: 8px;
    border-radius: 999px;
    background: #262b4a;
    overflow: hidden;
    margin: 4px 0 8px;
}
#timer-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--danger));
    transition: width 0.1s linear;
}

.target-label { color: var(--ink-dim); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 2px; margin-top: 10px; }
#target-letters {
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: 6px;
    color: var(--accent-gold);
    text-shadow: 0 0 20px rgba(255, 209, 102, 0.5);
    margin: 4px 0 14px;
}

.input-row { display: flex; gap: 8px; width: 100%; }
#word-input {
    flex: 1;
    min-width: 0; /* allow shrinking below content width in a flex row */
    padding: 14px 12px;
    border-radius: var(--radius-sm);
    border: 2px solid #2c3152;
    background: var(--panel-2);
    color: var(--ink);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
}
#word-input:focus { border-color: var(--accent-blue); }
#word-input.shake { animation: input-shake 0.3s ease; border-color: var(--danger); }
@keyframes input-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}
#btn-submit {
    flex-shrink: 0;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    font-weight: 800;
    white-space: nowrap;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}
@media (max-width: 360px) {
    #btn-submit { padding: 14px 12px; font-size: 0.85rem; }
}

.word-feedback { min-height: 22px; margin-top: 10px; font-weight: 700; text-align: center; }
.word-feedback.good { color: var(--accent-blue); }
.word-feedback.bad { color: var(--danger); }

.footer-row {
    display: flex;
    justify-content: space-between;
    color: var(--ink-dim);
    font-size: 0.8rem;
    margin-top: 14px;
}

.score-popup {
    position: absolute;
    left: 50%;
    top: 40%;
    transform: translate(-50%, 0);
    font-weight: 900;
    font-size: 1.4rem;
    color: var(--accent-gold);
    text-shadow: 0 0 12px rgba(255, 209, 102, 0.7);
    opacity: 0;
    pointer-events: none;
}
.score-popup.rise {
    animation: popup-rise 0.9s ease forwards;
}
@keyframes popup-rise {
    0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); }
    20% { opacity: 1; transform: translate(-50%, -10px) scale(1.1); }
    100% { opacity: 0; transform: translate(-50%, -60px) scale(1); }
}

.shake-subtle { animation: stage-shake-subtle 0.3s ease infinite; }
.shake-strong { animation: stage-shake-strong 0.2s ease infinite; }
@keyframes stage-shake-subtle {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(1.5px); }
}
@keyframes stage-shake-strong {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-2px, 1px); }
    75% { transform: translate(2px, -1px); }
}
.flash-white::after {
    content: '';
    position: absolute;
    inset: 0;
    background: #fff;
    animation: flash-out 0.25s ease forwards;
    pointer-events: none;
}
@keyframes flash-out {
    0% { opacity: 0.95; }
    100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .bomb-safe, .bomb-warning, .bomb-danger, .bomb-critical,
    .home-bomb-emoji, #hud-combo, #fever-banner, .shake-subtle, .shake-strong {
        animation: none !important;
    }
}

/* ---------------- Game over ---------------- */
.gameover-panel {
    text-align: center;
    padding: 20px 0 8px;
}
.go-boom { font-size: 3rem; margin-bottom: 4px; }
.go-title { font-size: 1.6rem; font-weight: 900; color: var(--danger); margin: 0 0 20px; }
.newbest-banner {
    background: linear-gradient(135deg, var(--accent-gold), var(--danger-2));
    color: #201200;
    font-weight: 900;
    padding: 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}
.stat-card {
    background: var(--panel);
    border: 1px solid #262b4a;
    border-radius: var(--radius-sm);
    padding: 12px;
}
.stat-card .hud-label { text-align: left; }
.stat-card .hud-value { text-align: left; }
.rank-row, .top-row {
    display: flex;
    justify-content: space-between;
    background: var(--panel);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}
.nickname-section { margin: 18px 0; }
.nickname-row { display: flex; gap: 8px; margin-top: 8px; }
#nickname-input {
    flex: 1;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 2px solid #2c3152;
    background: var(--panel-2);
    color: var(--ink);
    font-size: 1rem;
}
#nickname-result { color: var(--accent-blue); font-weight: 700; margin: 10px 0; }
.go-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.go-actions-row { display: flex; gap: 10px; }
.go-actions-row .btn { flex: 1; }

/* ---------------- Modals ---------------- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(4, 5, 10, 0.75);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 60;
}
@media (min-width: 480px) {
    .modal { align-items: center; }
}
.modal-card {
    background: var(--panel);
    border: 1px solid #262b4a;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 20px;
}
@media (min-width: 480px) {
    .modal-card { border-radius: 20px; }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.modal-header h2 { margin: 0; font-size: 1.2rem; }
.modal-close { font-size: 1.4rem; width: 36px; height: 36px; border-radius: 50%; background: var(--panel-2); }

.howto-steps { list-style: none; padding: 0; margin: 0 0 16px; }
.howto-steps li { padding: 8px 0; border-bottom: 1px solid #22263f; }
.howto-steps li:last-child { border-bottom: none; }

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #22263f;
}
.switch { position: relative; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; inset: 0; background: #2c3152; border-radius: 999px; transition: 0.2s;
}
.switch .slider::before {
    content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--accent-blue); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.lb-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.lb-tab {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--panel-2);
    font-weight: 700;
    font-size: 0.85rem;
}
.lb-tab.active { background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple)); }
#leaderboard-list { list-style: none; padding: 0; margin: 0; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid #22263f; }
.lb-rank { width: 36px; color: var(--ink-dim); font-weight: 700; }
.lb-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 800; color: var(--accent-gold); }
.lb-loading, .lb-empty { text-align: center; color: var(--ink-dim); padding: 20px 0; }

/* ---------------- Pause overlay ---------------- */
#modal-pause .modal-card { text-align: center; }
.pause-icon { font-size: 2.5rem; }

/* ---------------- Toast ---------------- */
#toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(20px);
    background: var(--panel-2);
    border: 1px solid #2c3152;
    color: var(--ink);
    padding: 12px 20px;
    border-radius: 999px;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 80;
    max-width: 90vw;
    text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

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