:root {
    --bg: #07101d;
    --surface: rgba(16, 29, 49, .86);
    --surface-solid: #101d31;
    --surface-2: #152741;
    --text: #f6f8fc;
    --muted: #9eafc6;
    --primary: #7c5cff;
    --primary-2: #31d7c7;
    --danger: #ff6b83;
    --border: rgba(255, 255, 255, .09);
    --shadow: 0 24px 70px rgba(0, 0, 0, .28);
}

html[data-theme="light"] {
    --bg: #f4f6fb;
    --surface: rgba(255,255,255,.92);
    --surface-solid: #ffffff;
    --surface-2: #eef1f8;
    --text: #132033;
    --muted: #657287;
    --border: rgba(18, 31, 49, .10);
    --shadow: 0 24px 70px rgba(31, 49, 78, .12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 15% 8%, rgba(124, 92, 255, .20), transparent 28%),
        radial-gradient(circle at 86% 13%, rgba(49, 215, 199, .11), transparent 24%),
        var(--bg);
    transition: background .25s ease, color .25s ease;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { color: inherit; }

.navbar {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    min-height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid var(--border);
}
.brand { font-size: 1.24rem; font-weight: 950; letter-spacing: -.035em; }
.nav-links { display: flex; align-items: center; gap: 19px; }
.nav-links > a { color: var(--muted); font-weight: 750; font-size: .94rem; }
.nav-links > a:hover { color: var(--text); }
.theme-toggle {
    width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface); cursor: pointer;
}
.player-chip {
    padding: 9px 12px; border: 1px solid var(--border); background: var(--surface);
    border-radius: 999px; font-size: .88rem; font-weight: 800;
}

.hero {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    min-height: 625px;
    display: grid;
    grid-template-columns: 1.22fr .78fr;
    gap: 70px;
    align-items: center;
    padding: 70px 0;
}
.eyebrow {
    display: inline-block; color: #9f8cff; font-size: .76rem; font-weight: 950;
    letter-spacing: .16em; margin-bottom: 14px;
}
.hero h1, .section h2, .leaderboard-heading h1, .play-card h1, .content-hero h1 {
    margin: 0; letter-spacing: -.055em; line-height: .98;
}
.hero h1 { font-size: clamp(3.2rem, 7vw, 6.7rem); }
.hero h1 span { color: #9c88ff; }
.hero-copy > p {
    color: var(--muted); max-width: 650px; font-size: 1.14rem; line-height: 1.7;
    margin: 28px 0 32px;
}
.hero-actions, .player-actions, .content-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.primary-button, .secondary-button, .choice-button {
    border: 0; cursor: pointer; border-radius: 14px; font-weight: 850;
    transition: transform .18s ease, opacity .18s ease, border-color .18s ease;
}
.primary-button {
    display: inline-flex; justify-content: center; align-items: center; padding: 15px 22px;
    background: linear-gradient(135deg, var(--primary), #9b73ff); color: white;
    box-shadow: 0 12px 32px rgba(124, 92, 255, .24);
}
.secondary-button {
    display: inline-flex; align-items: center; justify-content: center; padding: 13px 17px;
    background: transparent; border: 1px solid var(--border); color: var(--muted);
}
.primary-button:hover, .choice-button:hover, .secondary-button:hover { transform: translateY(-2px); }

.hero-card, .play-card, .game-card, .about, .player-panel, .leaderboard-card, .mini-leader-card, .info-card, .content-card {
    border: 1px solid var(--border);
    background: linear-gradient(145deg, var(--surface), color-mix(in srgb, var(--surface-solid) 88%, transparent));
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}
.hero-card {
    min-height: 355px; border-radius: 32px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; text-align: center; gap: 11px; transform: rotate(1.5deg);
}
.hero-card strong { font-size: 1.45rem; }
.hero-card > span { color: var(--muted); }
.orb {
    width: 132px; height: 132px; border-radius: 34px; display: grid; place-items: center;
    font-size: 4rem; background: linear-gradient(145deg, rgba(124,92,255,.29), rgba(49,215,199,.15));
    margin-bottom: 18px;
}
.mini-stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.mini-stats span { padding: 7px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: .78rem; color: var(--muted); }

.section {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto; padding: 86px 0;
}
.section-heading { margin-bottom: 36px; }
.section h2 { font-size: clamp(2.2rem, 5vw, 4rem); }
.section-heading p, .about p, .player-panel p, .leaderboard-heading p {
    color: var(--muted); line-height: 1.7; max-width: 690px;
}

.player-panel {
    padding: 34px; border-radius: 24px; display: flex; align-items: center;
    justify-content: space-between; gap: 35px;
}
.player-panel h2 { font-size: clamp(1.8rem, 4vw, 3rem); }
.player-panel .eyebrow { margin-bottom: 8px; }
.player-panel p { margin-bottom: 0; }
.pseudo-form { display: flex; gap: 10px; width: min(100%, 430px); }
.pseudo-form input {
    flex: 1; min-width: 0; background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 14px; padding: 14px 15px; outline: none;
}
.pseudo-form input:focus { border-color: rgba(124,92,255,.75); }
.danger-link { color: var(--danger); font-weight: 800; align-self: center; }

.game-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
}
.game-card {
    border-radius: 24px; padding: 27px; min-height: 335px; display: flex; flex-direction: column;
    transition: transform .2s ease, border-color .2s ease;
}
.game-card:hover { transform: translateY(-6px); border-color: rgba(124,92,255,.48); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.game-icon {
    width: 62px; height: 62px; display: grid; place-items: center; border-radius: 18px;
    background: rgba(124,92,255,.13); font-size: 2rem;
}
.game-icon.big { width: 74px; height: 74px; font-size: 2.35rem; }
.game-tag {
    font-size: .72rem; font-weight: 900; letter-spacing: .08em; color: var(--muted);
    border: 1px solid var(--border); border-radius: 999px; padding: 7px 9px;
}
.game-card h3 { font-size: 1.55rem; margin: 28px 0 10px; }
.game-card p { color: var(--muted); line-height: 1.65; margin: 0 0 25px; }
.game-card > a { margin-top: auto; font-weight: 850; color: #a995ff; }
.game-card > a span { display: inline-block; transition: transform .18s ease; }
.game-card:hover > a span { transform: translateX(4px); }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; padding-top: 10px; }
.info-card { border-radius: 22px; padding: 28px; }
.info-card h3 { margin: 2px 0 10px; font-size: 1.35rem; }
.info-card p { margin: 0; color: var(--muted); line-height: 1.7; }

.about { padding: 54px; border-radius: 28px; margin-top: 55px; margin-bottom: 100px; }
.about h2 { max-width: 850px; }
.about .secondary-button { margin-top: 12px; }

.play-shell {
    width: min(850px, calc(100% - 40px)); margin: 0 auto;
    min-height: calc(100vh - 168px); padding: 54px 0 80px;
}
.back-link { color: var(--muted); font-weight: 750; display: inline-block; margin-bottom: 24px; }
.play-card { border-radius: 28px; padding: 36px; }
.play-title { display: flex; align-items: center; gap: 18px; margin-bottom: 30px; }
.play-card h1 { font-size: clamp(2.2rem, 7vw, 4.2rem); }
.play-title p { color: var(--muted); margin: 9px 0 0; }
.play-title .eyebrow { margin-bottom: 8px; }
.message {
    padding: 16px 18px; border: 1px solid rgba(124,92,255,.26);
    background: rgba(124,92,255,.09); border-radius: 16px; font-weight: 750; line-height: 1.5;
}
.stat-row, .memory-toolbar {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 22px 0;
}
.stat-row > div, .memory-toolbar > div {
    border: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 50%, transparent);
    border-radius: 16px; padding: 18px;
}
.stat-row span, .memory-toolbar span {
    display: block; color: var(--muted); font-size: .82rem; margin-bottom: 7px;
}
.stat-row strong, .memory-toolbar strong { font-size: 1.15rem; word-break: break-word; }

.game-form { margin-top: 26px; display: grid; gap: 12px; }
.game-form label { font-weight: 800; }
.game-form input {
    width: 100%; color: var(--text); background: var(--surface-2);
    border: 1px solid var(--border); outline: none; padding: 15px 16px; border-radius: 14px;
}
.game-form input:focus { border-color: rgba(124,92,255,.8); }
.word-display {
    text-align: center; font-size: clamp(1.7rem, 6vw, 3.2rem); letter-spacing: .17em;
    font-weight: 900; padding: 32px 10px 16px; word-break: break-word;
}
.question-box {
    font-size: clamp(1.3rem, 4vw, 2rem); font-weight: 850; line-height: 1.4; padding: 28px 0 18px;
}
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.quiz-grid { display: grid; gap: 10px; }
.choice-button {
    color: var(--text); padding: 17px; background: var(--surface-2); border: 1px solid var(--border);
}
.choice-button.positive:hover { border-color: rgba(49,215,199,.65); }
.choice-button.negative:hover { border-color: rgba(255,107,131,.65); }
.points-earned {
    margin-top: 22px; padding: 18px; text-align: center; border-radius: 16px;
    background: rgba(49,215,199,.10); border: 1px solid rgba(49,215,199,.28);
    font-size: 1.3rem; font-weight: 900;
}
.play-actions {
    display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border);
}

/* Memory */
.memory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 20px; }
.memory-card {
    aspect-ratio: 1; border: 1px solid var(--border); border-radius: 16px; cursor: pointer;
    background: linear-gradient(145deg, var(--surface-2), var(--surface-solid));
    font-size: clamp(1.6rem, 7vw, 2.8rem); display: grid; place-items: center;
    transition: transform .18s ease, border-color .18s ease;
}
.memory-card:hover { transform: translateY(-2px); }
.memory-card .face { opacity: 0; transform: scale(.6); transition: .16s ease; }
.memory-card.revealed .face, .memory-card.matched .face { opacity: 1; transform: scale(1); }
.memory-card.matched { border-color: rgba(49,215,199,.55); background: rgba(49,215,199,.08); cursor: default; }
.memory-result {
    margin-top: 18px; padding: 18px; border-radius: 16px; text-align: center; font-weight: 900;
    background: rgba(49,215,199,.10); border: 1px solid rgba(49,215,199,.28);
}

/* Leaderboard */
.leaderboard-shell { width: min(1050px, calc(100% - 40px)); margin: 0 auto; padding: 70px 0; }
.leaderboard-heading h1 { font-size: clamp(3rem, 7vw, 5.8rem); }
.leaderboard-card { border-radius: 24px; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 18px 20px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .09em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.me { background: rgba(124,92,255,.10); }
.empty { color: var(--muted); text-align: center; }
.game-leaders { width: 100%; padding-left: 0; padding-right: 0; }
.leader-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.mini-leader-card { border-radius: 20px; padding: 22px; }
.mini-leader-card h3 { margin: 0; }
.mini-leader-card ol { list-style: none; padding: 0; margin: 18px 0 0; }
.mini-leader-card li { display: flex; justify-content: space-between; gap: 15px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.mini-leader-card li:last-child { border-bottom: 0; }

/* Content pages */
.content-shell { width: min(980px, calc(100% - 40px)); margin: 0 auto; padding: 72px 0 100px; }
.content-hero { max-width: 850px; margin-bottom: 36px; }
.content-hero h1 { font-size: clamp(3rem, 7vw, 5.7rem); }
.content-hero > p { color: var(--muted); font-size: 1.12rem; line-height: 1.75; max-width: 760px; margin: 24px 0 0; }
.content-card { border-radius: 24px; padding: clamp(26px, 5vw, 48px); margin-bottom: 22px; }
.prose { line-height: 1.8; }
.prose h2 { font-size: clamp(1.45rem, 3vw, 2rem); margin: 38px 0 12px; letter-spacing: -.025em; }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose li { color: var(--muted); }
.prose p { margin: 0 0 18px; }
.prose ul, .prose ol { padding-left: 24px; margin: 8px 0 22px; }
.prose li { margin: 8px 0; }
.prose strong { color: var(--text); }
.prose a.text-link { color: #a995ff; font-weight: 800; }
.content-actions { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }
.rules-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin: 22px 0; }
.rule-card { margin-bottom: 0; }
.rule-card:last-child { grid-column: 1 / -1; }
.rule-title { display: flex; align-items: center; gap: 13px; }
.rule-title span { font-size: 2rem; }
.rule-title h2 { margin: 0; }
.faq-list { display: grid; gap: 18px; }
.faq-list .content-card { margin: 0; }
.faq-list h2 { margin: 0 0 10px; }
.updated-note { padding-bottom: 20px; border-bottom: 1px solid var(--border); }

footer {
    width: min(1180px, calc(100% - 40px)); margin: 0 auto; min-height: 120px;
    border-top: 1px solid var(--border); display: flex; justify-content: space-between;
    align-items: center; gap: 28px; color: var(--muted); font-size: .9rem;
}
.footer-copy { display: flex; flex-direction: column; gap: 7px; line-height: 1.5; }
.footer-links { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px 16px; max-width: 540px; }
.footer-links a { font-weight: 700; }
.footer-links a:hover { color: var(--text); }

@media (max-width: 900px) {
    .hero { grid-template-columns: 1fr; min-height: auto; gap: 30px; }
    .hero-card { min-height: 270px; transform: none; }
    .game-grid, .info-grid { grid-template-columns: repeat(2, 1fr); }
    .info-card:last-child { grid-column: 1 / -1; }
    .player-panel { flex-direction: column; align-items: stretch; }
    .nav-links { gap: 13px; }
    .nav-links > a { font-size: .86rem; }
}
@media (max-width: 650px) {
    .navbar, .hero, .section, .play-shell, footer, .leaderboard-shell, .content-shell { width: min(100% - 28px, 1180px); }
    .nav-links > a { display: none; }
    .player-chip { max-width: 115px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .hero { padding: 45px 0; }
    .hero h1 { font-size: clamp(3rem, 15vw, 4.8rem); }
    .section { padding: 62px 0; }
    .game-grid, .leader-grid, .info-grid, .rules-grid { grid-template-columns: 1fr; }
    .info-card:last-child, .rule-card:last-child { grid-column: auto; }
    .game-card { min-height: 285px; }
    .about { padding: 32px; }
    .pseudo-form { flex-direction: column; }
    .play-card { padding: 24px 18px; }
    .stat-row, .choice-grid { grid-template-columns: 1fr; }
    .play-title { align-items: flex-start; }
    .memory-grid { gap: 7px; }
    .memory-card { border-radius: 12px; }
    th, td { padding: 14px 12px; }
    .content-shell { padding: 50px 0 72px; }
    .content-hero h1 { font-size: clamp(2.65rem, 13vw, 4.2rem); }
    .content-card { padding: 25px 20px; }
    footer { flex-direction: column; align-items: flex-start; justify-content: center; padding: 28px 0; }
    .footer-links { justify-content: flex-start; }
}
