/* ============================================================
   Forbiddle — sleek, sultry redesign
   Two themes driven by [data-theme] on <body>:
     • velvet  → Velvet & Gold
     • haze    → Purple Haze
   ============================================================ */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

/* Stop iOS double-tap-to-zoom on rapid taps of buttons/keys/tiles, and remove
   the grey tap flash. Pinch-to-zoom is still allowed for accessibility. */
button,
.key,
.tile {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* ---------- Theme tokens ---------- */
:root,
body[data-theme="velvet"] {
    --bg-1: #2a0e16;
    --bg-2: #140509;
    --glow-color: rgba(212, 175, 106, 0.16);
    --text: #f6ece0;
    --text-muted: #c2a892;
    --surface: rgba(64, 26, 38, 0.55);
    --surface-solid: #2a131c;
    --surface-border: rgba(212, 175, 106, 0.22);
    --accent: #d4af6a;
    --accent-2: #eccf8c;
    --accent-contrast: #1a0508;
    --accent-soft: rgba(212, 175, 106, 0.18);
    --tile-empty: rgba(255, 255, 255, 0.03);
    --tile-border: rgba(212, 175, 106, 0.22);
    --tile-filled-border: rgba(212, 175, 106, 0.6);
    --key-bg: rgba(255, 255, 255, 0.06);
    --key-hover: rgba(255, 255, 255, 0.12);
    --correct: #5f8f4e;
    --present: #c89b3c;
    --absent: #46303a;
    --shadow: rgba(0, 0, 0, 0.45);
    --swatch: linear-gradient(135deg, #eccf8c 0%, #d4af6a 45%, #5c1f2c 100%);
}

body[data-theme="haze"] {
    --bg-1: #2a1745;
    --bg-2: #110820;
    --glow-color: rgba(176, 106, 212, 0.18);
    --text: #efe6ff;
    --text-muted: #b3a3cf;
    --surface: rgba(46, 28, 74, 0.55);
    --surface-solid: #1f1336;
    --surface-border: rgba(176, 106, 212, 0.24);
    --accent: #b06ad4;
    --accent-2: #ff86d3;
    --accent-contrast: #190a2b;
    --accent-soft: rgba(176, 106, 212, 0.2);
    --tile-empty: rgba(255, 255, 255, 0.04);
    --tile-border: rgba(176, 106, 212, 0.26);
    --tile-filled-border: rgba(176, 106, 212, 0.6);
    --key-bg: rgba(255, 255, 255, 0.06);
    --key-hover: rgba(255, 255, 255, 0.13);
    --correct: #4e9a6a;
    --present: #c89b3c;
    --absent: #34244c;
    --shadow: rgba(0, 0, 0, 0.5);
    --swatch: linear-gradient(135deg, #ff86d3 0%, #b06ad4 50%, #3a1d6b 100%);
}

/* ---------- Base ---------- */
body {
    font-family: 'Poppins', system-ui, -apple-system, sans-serif;
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    background:
        radial-gradient(1200px 600px at 50% -10%, var(--glow-color), transparent 60%),
        linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 100%);
    background-attachment: fixed;
    transition: background 0.5s ease, color 0.5s ease;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---------- Header ---------- */
header {
    text-align: center;
    margin-bottom: 26px;
}

.game-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 3.4rem;
    font-weight: 700;
    letter-spacing: 1px;
    line-height: 1;
    margin-bottom: 12px;
}

.brand-accent {
    font-style: italic;
    background: linear-gradient(135deg, var(--accent-2), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 28px var(--glow-color);
}

.brand-plain {
    color: var(--text);
}

.tagline {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 18px;
}

/* ---------- Theme switch ---------- */
.theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 22px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    backdrop-filter: blur(10px);
}

.theme-switch-label {
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.theme-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.theme-swatch-velvet {
    background: linear-gradient(135deg, #eccf8c 0%, #d4af6a 45%, #5c1f2c 100%);
}

.theme-swatch-haze {
    background: linear-gradient(135deg, #ff86d3 0%, #b06ad4 50%, #3a1d6b 100%);
}

.theme-swatch:hover {
    transform: scale(1.12);
}

.theme-swatch.active {
    border-color: var(--text);
    box-shadow: 0 0 0 2px var(--bg-2), 0 0 14px var(--glow-color);
}

/* ---------- Navigation ---------- */
.game-nav {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nav-btn {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    color: var(--text);
    padding: 9px 16px;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.25s ease;
    backdrop-filter: blur(10px);
}

.nav-btn:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.nav-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-contrast);
    font-weight: 600;
    box-shadow: 0 6px 22px var(--glow-color);
}

/* ---------- Game info card ---------- */
.game-info {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 18px;
    padding: 20px;
    margin: 22px 0 26px;
    text-align: center;
    box-shadow: 0 10px 40px var(--shadow);
    backdrop-filter: blur(14px);
}

.mode-info {
    display: none;
}

.mode-info.active {
    display: block;
}

.mode-info h3 {
    color: var(--accent);
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.mode-info p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.countdown {
    margin-top: 14px;
    font-weight: 600;
    color: var(--text);
}

.countdown span {
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.new-game-btn {
    background: var(--accent);
    color: var(--accent-contrast);
    border: none;
    padding: 12px 26px;
    border-radius: 999px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-top: 14px;
}

.new-game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 26px var(--glow-color);
}

/* ---------- Game board ---------- */
.game-board {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 26px;
}

.guess-grid {
    display: grid;
    grid-auto-rows: 1fr;
    gap: 8px;
    margin-bottom: 24px;
}

.guess-row {
    display: grid;
    grid-auto-flow: column;
    gap: 8px;
}

.tile {
    width: 54px;
    height: 54px;
    border: 2px solid var(--tile-border);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text);
    background: var(--tile-empty);
    transition: border-color 0.2s ease, background 0.2s ease;
    text-transform: uppercase;
    user-select: none;
    -webkit-user-select: none;
}

.tile.filled {
    border-color: var(--tile-filled-border);
    animation: pop 0.12s ease-in-out;
}

.tile.correct {
    background: var(--correct);
    border-color: var(--correct);
    color: #fff;
    animation: flip 0.6s ease-in-out;
}

.tile.present {
    background: var(--present);
    border-color: var(--present);
    color: #fff;
    animation: flip 0.6s ease-in-out;
}

.tile.absent {
    background: var(--absent);
    border-color: var(--absent);
    color: var(--text-muted);
    animation: flip 0.6s ease-in-out;
}

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

@keyframes flip {
    0% { transform: rotateX(0); }
    50% { transform: rotateX(90deg); }
    100% { transform: rotateX(0); }
}

/* ---------- Message area ---------- */
.message-area {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
}

.game-message {
    background: var(--surface-solid);
    border: 1px solid var(--surface-border);
    padding: 11px 20px;
    border-radius: 999px;
    font-weight: 500;
    color: var(--text);
    box-shadow: 0 6px 20px var(--shadow);
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.game-message.show {
    opacity: 1;
    transform: translateY(0);
}

.game-message.error {
    background: #b23a48;
    border-color: #b23a48;
    color: #fff;
    animation: shake 0.5s ease-in-out;
}

.game-message.success {
    background: var(--correct);
    border-color: var(--correct);
    color: #fff;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* ---------- Keyboard ---------- */
.keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.keyboard-row {
    display: flex;
    gap: 6px;
}

.key {
    background: var(--key-bg);
    border: 1px solid var(--surface-border);
    border-radius: 9px;
    padding: 14px 10px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.15s ease;
    min-width: 38px;
    color: var(--text);
    user-select: none;
    -webkit-user-select: none;
}

.key:hover {
    background: var(--key-hover);
    transform: translateY(-2px);
}

.key:active {
    transform: translateY(0);
}

.key.wide {
    padding: 14px 16px;
    min-width: 62px;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.key.correct {
    background: var(--correct);
    border-color: var(--correct);
    color: #fff;
}

.key.present {
    background: var(--present);
    border-color: var(--present);
    color: #fff;
}

.key.absent {
    background: var(--absent);
    border-color: var(--absent);
    color: var(--text-muted);
}

/* ---------- Ad spaces (kept, blended into theme) ---------- */
.ad-space {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 14px;
    padding: 16px;
    text-align: center;
    backdrop-filter: blur(10px);
}

.ad-placeholder {
    color: var(--text-muted);
    font-size: 0.8rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.ad-top {
    margin-bottom: 22px;
}

.ad-bottom {
    margin-top: 22px;
}

/* ---------- Modals ---------- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
}

.modal-content {
    background: var(--surface-solid);
    border: 1px solid var(--surface-border);
    margin: 6% auto;
    padding: 32px;
    border-radius: 22px;
    width: 90%;
    max-width: 500px;
    position: relative;
    color: var(--text);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
    max-height: 82vh;
    overflow-y: auto;
}

.modal-content h2 {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    margin-bottom: 6px;
}

.modal-content.celebration {
    background: linear-gradient(150deg, var(--accent) 0%, var(--bg-1) 90%);
    border-color: var(--accent);
    text-align: center;
}

.close {
    color: var(--text-muted);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 22px;
    top: 18px;
    line-height: 1;
}

.close:hover {
    color: var(--text);
}

/* ---------- Stats ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin: 26px 0;
}

.stat {
    text-align: center;
    background: var(--accent-soft);
    border: 1px solid var(--surface-border);
    padding: 18px;
    border-radius: 14px;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.guess-distribution {
    margin-top: 26px;
}

.guess-distribution h3 {
    color: var(--text);
    margin-bottom: 18px;
    font-size: 1.1rem;
}

.distribution-bar {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.bar-label {
    width: 20px;
    font-weight: 600;
    color: var(--text-muted);
}

.bar {
    height: 26px;
    background: var(--accent);
    margin-left: 10px;
    border-radius: 6px;
    min-width: 22px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 9px;
    color: var(--accent-contrast);
    font-weight: 600;
    font-size: 0.85rem;
}

/* ---------- Buttons ---------- */
.share-btn,
.play-again-btn {
    background: var(--accent);
    color: var(--accent-contrast);
    border: none;
    padding: 14px 28px;
    border-radius: 999px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.25s ease;
    margin: 8px;
}

.play-again-btn {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--surface-border);
}

.share-btn:hover,
.play-again-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 26px var(--glow-color);
}

/* ---------- Instructions ---------- */
.instructions p {
    color: var(--text);
    margin: 12px 0;
}

.instructions ul {
    text-align: left;
    margin: 18px 0;
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 10px;
    color: var(--text-muted);
}

.example-tiles {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 14px 0;
    padding: 14px;
    background: var(--accent-soft);
    border-radius: 12px;
}

.tile-label {
    color: var(--text-muted);
    font-size: 0.88rem;
}

/* ---------- Win / Lose ---------- */
.win-stats,
.lose-stats {
    margin: 20px 0;
    padding: 18px;
    background: rgba(0, 0, 0, 0.22);
    border-radius: 14px;
}

.win-actions,
.lose-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    .game-title {
        font-size: 2.6rem;
    }

    .tile {
        width: 46px;
        height: 46px;
        font-size: 1.35rem;
    }

    .key {
        padding: 12px 7px;
        font-size: 0.85rem;
        min-width: 30px;
    }

    .modal-content {
        margin: 12% auto;
        padding: 22px;
    }
}

@media (max-width: 350px) {
    .tile {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .guess-grid,
    .guess-row {
        gap: 5px;
    }
}
