/* =========================================================
   YBOX Arcade — design system
   Palette: graphite grays + green & yellow accents
   ========================================================= */

:root {
    color-scheme: dark;

    /* grayscale core */
    --bg-0: #0b0d10;
    --bg-1: #101317;
    --bg-2: #161a20;
    --bg-3: #1c2129;
    --bg-4: #242a34;
    --line: #2c333d;
    --line-strong: #3a434f;
    --line-soft: rgba(255, 255, 255, 0.07);

    /* text */
    --text: #e9edf1;
    --text-muted: #9aa5b1;
    --text-dim: #6b7683;

    /* accents */
    --green: #46e08a;
    --green-bright: #6ef0a8;
    --green-deep: #1f9d5a;
    --green-soft: rgba(70, 224, 138, 0.12);
    --green-line: rgba(70, 224, 138, 0.32);
    --yellow: #f6c945;
    --yellow-bright: #ffe28a;
    --yellow-deep: #c99a1e;
    --yellow-soft: rgba(246, 201, 69, 0.12);
    --yellow-line: rgba(246, 201, 69, 0.3);
    --danger: #f07171;

    --font-sans: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-mono: "Cascadia Mono", "Consolas", "SFMono-Regular", ui-monospace, monospace;

    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;

    --shadow-card: 0 30px 60px -40px rgba(0, 0, 0, 0.9);

    /* legacy aliases (legal pages, old inline styles) */
    --primary: var(--green);
    --secondary: var(--text-muted);
    --accent: var(--green);
    --neon-pink: var(--danger);
    --neon-blue: var(--text-muted);
    --dark-bg: var(--bg-0);
    --darker-bg: var(--bg-1);
    --card-bg: var(--bg-2);
}

/* ---------- reset ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    min-height: 100vh;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg-0);
    background-image:
        radial-gradient(1100px 540px at 88% -8%, rgba(70, 224, 138, 0.09), transparent 62%),
        radial-gradient(900px 480px at -6% 4%, rgba(246, 201, 69, 0.06), transparent 58%),
        linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
    background-size: auto, auto, 44px 44px, 44px 44px;
    background-attachment: fixed;
    overflow-x: hidden;
}

img,
svg,
canvas {
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

[hidden] {
    display: none !important;
}

ul,
ol {
    list-style: none;
}

a {
    color: inherit;
}

::selection {
    background: rgba(70, 224, 138, 0.3);
    color: #fff;
}

:focus-visible {
    outline: 2px solid var(--yellow);
    outline-offset: 3px;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-1);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-4);
    border-radius: 99px;
    border: 2px solid var(--bg-1);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--line-strong);
}

.container {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 24px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 20px;
    z-index: 300;
    padding: 10px 16px;
    border-radius: 0 0 10px 10px;
    background: var(--green);
    color: #07130c;
    font-weight: 700;
    text-decoration: none;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
}

/* ---------- header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 60;
    border-bottom: 1px solid var(--line-soft);
    background: rgba(11, 13, 16, 0.82);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 76px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 13px;
    text-decoration: none;
    border-radius: 14px;
    padding: 4px;
    margin: -4px;
}

.brand-mark {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: linear-gradient(150deg, var(--bg-4), #12151a);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 18px -10px #000;
}

.brand-mark svg {
    width: 30px;
    height: 30px;
}

.brand-name {
    display: block;
    font-size: 1.06rem;
    font-weight: 800;
    letter-spacing: -0.015em;
    line-height: 1.2;
}

.brand-tag {
    display: block;
    margin-top: 2px;
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.header-tools {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lang-switch {
    display: flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg-2);
}

.lang-btn {
    border: 0;
    border-radius: 9px;
    padding: 7px 12px;
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    transition: color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.lang-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.lang-btn.active {
    color: var(--green);
    background: var(--bg-4);
    box-shadow: inset 0 0 0 1px rgba(70, 224, 138, 0.22);
}

/* ---------- buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 15px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.btn svg {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
}

.btn--primary {
    border-color: rgba(255, 255, 255, 0.14);
    background: linear-gradient(180deg, var(--green-bright), var(--green));
    color: #07130c;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 10px 24px -14px rgba(70, 224, 138, 0.8);
}

.btn--primary:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.btn--primary:active {
    transform: translateY(0);
}

.btn--ghost {
    border-color: var(--line);
    background: var(--bg-3);
    color: var(--text);
}

.btn--ghost:hover {
    border-color: var(--line-strong);
    background: var(--bg-4);
}

.btn--icon {
    width: 42px;
    height: 42px;
    padding: 0;
}

.btn--icon svg {
    width: 18px;
    height: 18px;
}

.btn--scores:hover {
    color: var(--yellow);
    border-color: var(--yellow-line);
}

.btn--back {
    color: var(--text-muted);
}

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

.btn--back svg {
    transition: transform 0.2s ease;
}

.btn--back:hover svg {
    transform: translateX(-2px);
}

/* ---------- screens ---------- */
.screen {
    display: none;
}

.screen.active {
    display: block;
    animation: fadeIn 0.35s ease both;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.94) translateY(6px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes bump {
    0% {
        transform: scale(1);
    }
    40% {
        transform: scale(1.22);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes pulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(70, 224, 138, 0.45);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(70, 224, 138, 0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- hero ---------- */
.hero {
    position: relative;
    margin: 32px 0 46px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background:
        radial-gradient(700px 340px at 92% 8%, rgba(70, 224, 138, 0.14), transparent 68%),
        radial-gradient(560px 300px at 8% 100%, rgba(246, 201, 69, 0.08), transparent 65%),
        linear-gradient(150deg, rgba(32, 38, 47, 0.9), rgba(16, 19, 23, 0.97) 60%, rgba(12, 14, 17, 0.99));
    box-shadow: var(--shadow-card);
}

.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.032) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.032) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: radial-gradient(ellipse at 60% 20%, #000 10%, transparent 72%);
    pointer-events: none;
}

.hero-inner {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.9fr);
    align-items: center;
    gap: clamp(26px, 4vw, 48px);
    padding: clamp(26px, 5vw, 54px);
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 8px 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.025);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.eyebrow .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 2.4s ease-out infinite;
}

.hero-title {
    margin: 20px 0 16px;
    font-size: clamp(2.1rem, 5vw, 3.7rem);
    font-weight: 800;
    line-height: 1.02;
    letter-spacing: -0.045em;
    text-wrap: balance;
}

.hero-title .accent {
    color: var(--green);
    background: linear-gradient(180deg, var(--green-bright), var(--green) 70%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-sub {
    max-width: 48ch;
    color: var(--text-muted);
    font-size: 0.98rem;
    line-height: 1.65;
}

.hero-stats {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(20px, 4vw, 38px);
    margin-top: 30px;
    padding-top: 22px;
    border-top: 1px dashed var(--line);
}

.hero-stat strong {
    display: block;
    font-family: var(--font-mono);
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--green);
    font-variant-numeric: tabular-nums;
}

.hero-stat:nth-child(2) strong {
    color: var(--yellow);
}

.hero-stat:nth-child(3) strong {
    color: var(--text);
}

.hero-stat span {
    display: block;
    margin-top: 3px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* record board */
.record-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(9, 11, 14, 0.55);
    backdrop-filter: blur(8px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.record-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 13px;
}

.record-title {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.record-badge {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--yellow-line);
    border-radius: 9px;
    background: var(--yellow-soft);
    color: var(--yellow);
}

.record-badge svg {
    width: 15px;
    height: 15px;
}

.record-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.record-row {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.022);
}

.record-row:hover {
    border-color: var(--line);
    background: rgba(255, 255, 255, 0.04);
}

.record-rank {
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
}

.record-name {
    overflow: hidden;
    color: var(--text);
    font-size: 0.84rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.record-score {
    color: var(--yellow);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.record-empty {
    padding: 16px 4px;
    color: var(--text-dim);
    font-size: 0.8rem;
    line-height: 1.6;
}

.record-foot {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 13px;
    padding-top: 12px;
    border-top: 1px solid var(--line-soft);
    color: var(--text-dim);
    font-size: 0.68rem;
}

.record-foot svg {
    width: 12px;
    height: 12px;
    flex: 0 0 auto;
    color: var(--green);
}

/* ---------- section head / filters ---------- */
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 22px;
}

.section-title {
    font-size: clamp(1.2rem, 2.4vw, 1.55rem);
    font-weight: 700;
    letter-spacing: -0.025em;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-btn {
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg-2);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.filter-btn:hover {
    color: var(--text);
    border-color: var(--line-strong);
}

.filter-btn.active {
    border-color: var(--green-line);
    background: var(--green-soft);
    color: var(--green);
}

/* ---------- game cards ---------- */
.games-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    padding-bottom: 72px;
}

.game-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 11px;
    min-height: 252px;
    padding: 22px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: linear-gradient(165deg, var(--bg-3), var(--bg-2) 55%, var(--bg-1));
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
    cursor: pointer;
    outline: none;
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.game-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--green), var(--yellow));
    opacity: 0;
    transition: opacity 0.25s ease;
}

.game-card::after {
    content: "";
    position: absolute;
    top: -120px;
    right: -90px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(70, 224, 138, 0.16), transparent 68%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.game-card:hover,
.game-card:focus-visible {
    transform: translateY(-5px);
    border-color: rgba(70, 224, 138, 0.4);
    box-shadow: 0 24px 50px -30px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(70, 224, 138, 0.08);
}

.game-card:hover::before,
.game-card:focus-visible::before,
.game-card:hover::after,
.game-card:focus-visible::after {
    opacity: 1;
}

.game-card__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.game-icon {
    display: grid;
    place-items: center;
    width: 50px;
    height: 50px;
    border: 1px solid rgba(70, 224, 138, 0.18);
    border-radius: 14px;
    background: rgba(70, 224, 138, 0.07);
    color: var(--green);
    transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.game-icon svg {
    width: 26px;
    height: 26px;
}

.game-card:hover .game-icon {
    border-color: rgba(70, 224, 138, 0.4);
    background: rgba(70, 224, 138, 0.13);
    box-shadow: 0 0 26px -8px rgba(70, 224, 138, 0.6);
}

.game-tag {
    padding: 5px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    white-space: nowrap;
}

.game-card[data-category="puzzle"] .game-tag {
    border-color: var(--yellow-line);
    color: var(--yellow);
}

.game-card[data-category="reflex"] .game-tag {
    color: var(--text-muted);
}

.game-name {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.game-desc {
    flex: 1;
    color: var(--text-muted);
    font-size: 0.845rem;
    line-height: 1.55;
}

.game-stats {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    margin-top: 4px;
    padding-top: 13px;
    border-top: 1px solid var(--line-soft);
}

.best {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.best-label {
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.best-value {
    color: var(--yellow);
    font-family: var(--font-mono);
    font-size: 0.92rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.best-value.is-empty {
    color: var(--text-dim);
}

.play-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 11px;
    border: 1px solid rgba(70, 224, 138, 0.22);
    border-radius: 999px;
    background: rgba(70, 224, 138, 0.07);
    color: var(--green);
    font-size: 0.77rem;
    font-weight: 700;
    white-space: nowrap;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.play-btn svg {
    width: 12px;
    height: 12px;
    transition: transform 0.2s ease;
}

.game-card:hover .play-btn {
    border-color: transparent;
    background: var(--green);
    color: #07130c;
}

.game-card:hover .play-btn svg {
    transform: translateX(2px);
}

/* ---------- game screen ---------- */
.game-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin: 24px 0 18px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(22, 26, 32, 0.85);
    backdrop-filter: blur(10px);
}

.game-title-wrap {
    display: flex;
    flex: 1 1 200px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 0;
}

.game-title-wrap::before {
    content: "";
    flex: 0 0 auto;
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: var(--green);
    box-shadow: 0 0 12px rgba(70, 224, 138, 0.9);
    transform: rotate(45deg);
}

.game-title {
    overflow: hidden;
    font-size: 1.18rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.game-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.score-chip {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 8px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg-1);
}

.score-chip__label {
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.score-chip__value {
    display: inline-block;
    min-width: 2ch;
    color: var(--green);
    font-family: var(--font-mono);
    font-size: 1.18rem;
    font-weight: 800;
    line-height: 1;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.score-chip.is-bump .score-chip__value {
    animation: bump 0.24s ease;
}

.game-stage {
    position: relative;
}

.game-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: clamp(340px, 56vh, 620px);
    padding: clamp(12px, 3vw, 28px);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background:
        radial-gradient(800px 380px at 50% -10%, rgba(70, 224, 138, 0.055), transparent 65%),
        linear-gradient(180deg, rgba(28, 33, 41, 0.6), rgba(13, 15, 18, 0.75));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.game-container::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
    background-size: 38px 38px;
    mask-image: radial-gradient(ellipse at center, #000 20%, transparent 78%);
    pointer-events: none;
}

.game-container > * {
    position: relative;
    z-index: 1;
}

.game-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    margin: 13px 0 40px;
    color: var(--text-dim);
    font-size: 0.8rem;
    text-align: center;
}

.game-controls::before {
    content: "↳";
    color: var(--green);
    font-family: var(--font-mono);
    font-size: 0.95rem;
}

.game-controls:empty {
    display: none;
}

/* game over overlay */
.game-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    place-items: center;
    padding: 20px;
    border-radius: var(--radius-lg);
    background: rgba(7, 9, 11, 0.78);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.2s ease both;
}

.game-overlay[hidden] {
    display: none;
}

.game-over-card {
    width: min(100%, 380px);
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
    box-shadow: 0 40px 90px -40px #000, inset 0 1px 0 rgba(255, 255, 255, 0.05);
    text-align: center;
    animation: popIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}

.game-over-kicker {
    display: inline-block;
    padding: 6px 11px;
    border: 1px solid var(--green-line);
    border-radius: 999px;
    background: var(--green-soft);
    color: var(--green);
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.game-over-kicker.is-record {
    border-color: transparent;
    background: var(--yellow);
    color: #171204;
}

.game-over-label {
    margin-top: 18px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.game-over-score {
    display: block;
    margin: 2px 0 4px;
    color: var(--green);
    font-family: var(--font-mono);
    font-size: clamp(2.4rem, 7vw, 3.4rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.05em;
    font-variant-numeric: tabular-nums;
}

.game-over-best {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.game-over-best b {
    color: var(--yellow);
    font-family: var(--font-mono);
}

.game-over-actions {
    display: flex;
    gap: 9px;
    margin-top: 22px;
}

.game-over-actions .btn {
    flex: 1;
}

.game-over-link {
    margin-top: 14px;
    padding: 4px;
    border: 0;
    background: none;
    color: var(--text-muted);
    font-size: 0.76rem;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s ease;
}

.game-over-link:hover {
    color: var(--yellow);
}

.game-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    color: var(--text-muted);
    font-size: 0.86rem;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--line);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ---------- modal ---------- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    padding: 20px;
    overflow-y: auto;
    background: rgba(5, 6, 8, 0.74);
    backdrop-filter: blur(7px);
}

.modal.active {
    display: grid;
    place-items: center;
    animation: fadeIn 0.2s ease both;
}

.modal-content {
    position: relative;
    width: min(100%, 440px);
    padding: 25px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--bg-2);
    box-shadow: 0 50px 120px -50px #000, inset 0 1px 0 rgba(255, 255, 255, 0.05);
    animation: popIn 0.25s ease both;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line-soft);
}

.modal-head h2 {
    font-size: 1.1rem;
    letter-spacing: -0.02em;
}

.modal-close {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg-3);
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.modal-close:hover {
    border-color: var(--line-strong);
    background: var(--bg-4);
    color: var(--text);
}

.modal-sub {
    margin-top: 11px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

#scores-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: min(52vh, 400px);
    margin-top: 12px;
    overflow-y: auto;
}

.score-item {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.025);
}

.score-item:hover {
    border-color: var(--line);
}

.score-item .rank {
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
}

.score-item .pts-label {
    color: var(--text-dim);
    font-size: 0.75rem;
}

.score-item .points {
    color: var(--yellow);
    font-family: var(--font-mono);
    font-size: 0.98rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.score-item:nth-child(1) {
    border-color: var(--yellow-line);
    background: var(--yellow-soft);
}

.score-item:nth-child(1) .rank,
.score-item:nth-child(1) .points {
    color: var(--yellow);
}

.empty-state {
    padding: 26px 10px;
    color: var(--text-dim);
    font-size: 0.83rem;
    line-height: 1.6;
    text-align: center;
}

/* ---------- cookie notice ---------- */
.cookie-notice {
    position: fixed;
    left: 20px;
    right: 20px;
    bottom: 20px;
    z-index: 150;
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 540px;
    margin: 0 auto;
    padding: 15px 17px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(22, 26, 32, 0.97);
    box-shadow: 0 28px 70px -25px #000;
    backdrop-filter: blur(12px);
    animation: slideUp 0.4s ease both;
}

.cookie-notice.hidden {
    display: none;
}

.cookie-notice p {
    flex: 1;
    margin: 0;
    color: var(--text-muted);
    font-size: 0.76rem;
    line-height: 1.55;
}

.cookie-notice a {
    color: var(--yellow);
    text-underline-offset: 2px;
}

.cookie-btn {
    flex: 0 0 auto;
    padding: 9px 16px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    background: linear-gradient(180deg, var(--green-bright), var(--green));
    color: #07130c;
    font-size: 0.78rem;
    font-weight: 800;
    transition: filter 0.2s ease, transform 0.2s ease;
}

.cookie-btn:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
}

/* ---------- footer ---------- */
.footer {
    margin-top: 40px;
    border-top: 1px solid var(--line-soft);
    background: linear-gradient(180deg, rgba(16, 19, 23, 0.55), rgba(10, 12, 15, 0.98));
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.6fr 0.9fr 0.9fr 1.2fr;
    gap: clamp(24px, 4vw, 44px);
    padding: 52px 0 34px;
}

.footer .brand {
    margin-bottom: 14px;
}

.footer h4 {
    margin-bottom: 15px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.footer p {
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.65;
}

.footer ul {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.footer-games-list {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px 12px !important;
}

.footer-games-list .footer-link {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.footer-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--text-muted);
    font-size: 0.82rem;
    text-align: left;
    text-decoration: none;
    transition: color 0.18s ease;
}

.footer-link:hover {
    color: var(--green);
}

.footer-note {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 15px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text-dim);
    font-size: 0.68rem;
}

.footer-note .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--green);
}

.socials {
    display: flex;
    gap: 8px;
}

.socials a {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg-2);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 800;
    text-decoration: none;
    transition: transform 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.socials a:hover {
    transform: translateY(-2px);
    border-color: var(--green-line);
    color: var(--green);
}

.footer-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 18px 0 26px;
    border-top: 1px solid var(--line-soft);
    color: var(--text-dim);
    font-size: 0.72rem;
}

.footer-bottom .sep {
    display: inline-block;
    width: 3px;
    height: 3px;
    margin: 0 8px;
    border-radius: 50%;
    background: var(--line-strong);
    vertical-align: middle;
}

/* ---------- legal / static pages ---------- */
.page-shell {
    max-width: 920px;
    margin: 0 auto;
    padding: 0 24px 80px;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 0;
}

.page-card {
    margin-top: 16px;
    padding: clamp(24px, 5vw, 52px);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
    box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.page-card h1 {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 800;
    letter-spacing: -0.035em;
    line-height: 1.1;
}

.page-card .meta {
    margin: 8px 0 28px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.page-card h2 {
    margin: 28px 0 8px;
    color: var(--green);
    font-size: 1.08rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.page-card p,
.page-card li {
    margin-bottom: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.78;
}

.page-card ul {
    margin: 0 0 16px;
    padding-left: 20px;
    list-style: disc;
}

.page-card ul li::marker {
    color: var(--green);
}

.page-card strong {
    color: var(--text);
}

.page-card a {
    color: var(--yellow);
    text-underline-offset: 2px;
}

.page-card a.btn {
    color: #07130c;
    text-decoration: none;
}

.page-card a.btn--ghost {
    color: var(--text);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-decoration: none;
    transition: color 0.18s ease;
}

.back-link:hover {
    color: var(--green);
}

.page-actions {
    display: grid;
    gap: 10px;
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid var(--line-soft);
}

.contact-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 15px;
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.02);
}

.contact-icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border: 1px solid var(--green-line);
    border-radius: 11px;
    background: var(--green-soft);
    color: var(--green);
}

.contact-card strong {
    display: block;
    font-size: 0.88rem;
}

.contact-card span {
    display: block;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ---------- 404 ---------- */
.error-page {
    display: grid;
    place-items: center;
    min-height: calc(100vh - 76px);
    padding: 40px 20px;
    text-align: center;
}

.error-card {
    width: min(100%, 560px);
    padding: clamp(30px, 6vw, 56px);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background:
        radial-gradient(400px 220px at 50% 0%, rgba(70, 224, 138, 0.12), transparent 70%),
        linear-gradient(180deg, var(--bg-2), var(--bg-1));
    box-shadow: var(--shadow-card);
}

.error-code {
    font-family: var(--font-mono);
    font-size: clamp(5rem, 17vw, 8.5rem);
    font-weight: 800;
    line-height: 0.9;
    letter-spacing: -0.07em;
    background: linear-gradient(180deg, var(--green-bright), rgba(246, 201, 69, 0.5));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.error-card h1 {
    margin: 18px 0 8px;
    font-size: clamp(1.4rem, 4vw, 2rem);
    letter-spacing: -0.03em;
}

.error-card p {
    margin-bottom: 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* =========================================================
   In-game UI
   ========================================================= */

.game-shell {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
}

.game-shell--narrow {
    max-width: 480px;
}

.game-hud {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 8px;
}

.hud {
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: rgba(9, 11, 14, 0.55);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.hud__label {
    display: block;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.hud__value {
    display: block;
    margin-top: 2px;
    color: var(--green);
    font-family: var(--font-mono);
    font-size: clamp(1.05rem, 2.5vw, 1.3rem);
    font-weight: 800;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.hud--yellow .hud__value {
    color: var(--yellow);
}

.hud--muted .hud__value {
    color: var(--text);
}

/* canvases */
.game-canvas {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--bg-1);
    box-shadow: 0 24px 50px -30px #000, inset 0 0 0 1px rgba(255, 255, 255, 0.02);
    touch-action: manipulation;
}

.game-canvas--snake {
    max-width: 520px;
    touch-action: none;
}

.game-canvas--flappy {
    max-width: 450px;
    touch-action: none;
}

.game-canvas--tetris {
    width: 100%;
    max-width: 300px;
}

/* tetris layout */
.tetris-layout {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 14px;
}

.tetris-side {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 118px;
}

.tetris-side .hud {
    padding: 9px 11px;
}

.next-preview {
    display: block;
    width: 100%;
    height: auto;
    margin-top: 6px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--bg-1);
}

/* touch pad */
.touch-pad {
    display: none;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}

.touch-pad button {
    display: grid;
    place-items: center;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg-3);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 700;
    user-select: none;
    touch-action: manipulation;
}

.touch-pad button:active {
    border-color: var(--green-line);
    background: var(--green-soft);
    color: var(--green);
}

/* 2048 */
.board {
    display: grid;
    gap: 9px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--bg-1);
    box-shadow: 0 24px 50px -30px #000, inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.board--2048 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 9px;
    touch-action: none;
    user-select: none;
}

.tile {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    border: 1px solid var(--line-soft);
    border-radius: 11px;
    background: var(--bg-3);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: clamp(1rem, 4.2vw, 1.6rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
    transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
    font-variant-numeric: tabular-nums;
}

.tile.is-new {
    animation: tileIn 0.16s ease both;
}

.tile.is-empty {
    border-color: rgba(255, 255, 255, 0.035);
    background: rgba(255, 255, 255, 0.018);
}

@keyframes tileIn {
    from {
        transform: scale(0.4);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.tile--2 {
    background: #2b323d;
    color: #e4eaf0;
}

.tile--4 {
    background: #353e4a;
    color: #f1f5f9;
}

.tile--8 {
    background: #1d3b2e;
    border-color: rgba(70, 224, 138, 0.2);
    color: #8ff0b9;
}

.tile--16 {
    background: #234a38;
    border-color: rgba(70, 224, 138, 0.26);
    color: #a9f5cb;
}

.tile--32 {
    background: #2b5c45;
    border-color: rgba(70, 224, 138, 0.32);
    color: #c8fadf;
}

.tile--64 {
    background: #347052;
    border-color: rgba(70, 224, 138, 0.4);
    color: #ecfff4;
}

.tile--128 {
    background: #4a3d1a;
    border-color: rgba(246, 201, 69, 0.28);
    color: #f7dc85;
}

.tile--256 {
    background: #63501f;
    border-color: rgba(246, 201, 69, 0.36);
    color: #ffe9a3;
}

.tile--512 {
    background: #7f6624;
    border-color: rgba(246, 201, 69, 0.45);
    color: #fff3c4;
}

.tile--1024 {
    background: #a5832a;
    border-color: rgba(246, 201, 69, 0.55);
    color: #14150f;
}

.tile--2048 {
    border-color: transparent;
    background: linear-gradient(135deg, var(--green), var(--yellow));
    color: #0d1a12;
    box-shadow: 0 0 28px -6px rgba(70, 224, 138, 0.55);
}

.tile--super {
    border-color: transparent;
    background: linear-gradient(135deg, var(--yellow), var(--green));
    color: #10130d;
    box-shadow: 0 0 30px -6px rgba(246, 201, 69, 0.5);
}

/* memory */
.memory-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 9px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--bg-1);
    box-shadow: 0 24px 50px -30px #000, inset 0 1px 0 rgba(255, 255, 255, 0.03);
    perspective: 900px;
}

.mcard {
    position: relative;
    aspect-ratio: 1;
    padding: 0;
    border: 0;
    background: none;
    perspective: 700px;
}

.mcard__inner {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
    transition: transform 0.42s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.mcard.is-flipped .mcard__inner,
.mcard.is-matched .mcard__inner {
    transform: rotateY(180deg);
}

.mcard__face {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 11px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.mcard__face--front {
    background: linear-gradient(150deg, var(--bg-4), var(--bg-2));
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: clamp(0.9rem, 3.4vw, 1.25rem);
    font-weight: 800;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.mcard:hover .mcard__face--front {
    border-color: var(--line-strong);
    color: var(--text-muted);
}

.mcard__face--back {
    transform: rotateY(180deg);
    border-color: var(--green-line);
    background:
        radial-gradient(circle at 30% 25%, rgba(70, 224, 138, 0.16), transparent 60%),
        linear-gradient(150deg, #1d2a24, #171c21);
    font-size: clamp(1.3rem, 5vw, 1.9rem);
}

.mcard.is-matched .mcard__face--back {
    border-color: var(--yellow-line);
    box-shadow: inset 0 0 22px rgba(246, 201, 69, 0.1);
}

.sym-0 {
    color: var(--green);
}
.sym-1 {
    color: var(--yellow);
}
.sym-2 {
    color: #a7f3c8;
}
.sym-3 {
    color: #cfd6dd;
}
.sym-4 {
    color: var(--yellow-bright);
}
.sym-5 {
    color: #7fd1a8;
}
.sym-6 {
    color: #e7edf2;
}
.sym-7 {
    color: #d6b04a;
}

/* minesweeper */
.ms-board {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 3px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--bg-1);
    box-shadow: 0 24px 50px -30px #000, inset 0 1px 0 rgba(255, 255, 255, 0.03);
    user-select: none;
    touch-action: none;
}

.ms-cell {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.055);
    border-radius: 4px;
    background: var(--bg-3);
    color: transparent;
    font-family: var(--font-mono);
    font-size: clamp(0.6rem, 2.1vw, 0.85rem);
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.ms-cell:hover:not(.is-open):not(.is-flag) {
    border-color: rgba(70, 224, 138, 0.4);
    background: var(--bg-4);
}

.ms-cell.is-flag {
    border-color: var(--yellow-line);
    background: rgba(246, 201, 69, 0.1);
    color: var(--yellow);
}

.ms-cell.is-open {
    border-color: rgba(255, 255, 255, 0.035);
    background: rgba(8, 10, 13, 0.55);
    color: var(--text-muted);
    cursor: default;
}

.ms-cell.is-mine {
    border-color: rgba(240, 113, 113, 0.35);
    background: rgba(240, 113, 113, 0.16);
    color: var(--danger);
}

.ms-cell.is-boom {
    background: var(--danger);
    color: #170808;
}

.ms-cell.is-wrong {
    color: var(--danger);
    text-decoration: line-through;
}

.ms-cell.n1 {
    color: var(--green);
}
.ms-cell.n2 {
    color: var(--yellow);
}
.ms-cell.n3 {
    color: #a7e07a;
}
.ms-cell.n4 {
    color: #e0b63a;
}
.ms-cell.n5 {
    color: #cfd6dd;
}
.ms-cell.n6 {
    color: #9aa5b1;
}
.ms-cell.n7 {
    color: #fff1b8;
}
.ms-cell.n8 {
    color: var(--danger);
}

/* match 3 */
.match-board {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 5px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--bg-1);
    box-shadow: 0 24px 50px -30px #000, inset 0 1px 0 rgba(255, 255, 255, 0.03);
    user-select: none;
    touch-action: manipulation;
}

.gem {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.022);
    font-size: clamp(0.8rem, 3.1vw, 1.45rem);
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.gem:hover {
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.05);
}

.gem.is-selected {
    border-color: var(--green);
    background: rgba(70, 224, 138, 0.14);
    box-shadow: 0 0 0 1px rgba(70, 224, 138, 0.35) inset;
    transform: scale(0.93);
}

.gem.is-clearing {
    opacity: 0.15;
    transform: scale(0.5);
}

.gem--0 {
    color: var(--green);
}
.gem--1 {
    color: var(--yellow);
}
.gem--2 {
    color: #a7f3c8;
}
.gem--3 {
    color: #cfd6dd;
}
.gem--4 {
    color: var(--yellow-bright);
}
.gem--5 {
    color: #7fd1a8;
}

/* reaction */
.reaction-area {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background:
        radial-gradient(420px 240px at 50% 0%, rgba(70, 224, 138, 0.06), transparent 70%),
        linear-gradient(150deg, var(--bg-3), var(--bg-1));
    box-shadow: 0 24px 50px -30px #000, inset 0 1px 0 rgba(255, 255, 255, 0.03);
    touch-action: manipulation;
}

.reaction-hint {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    color: var(--text-dim);
    font-size: 0.82rem;
    text-align: center;
    pointer-events: none;
}

.reaction-target {
    position: absolute;
    padding: 0;
    border: 2px solid var(--yellow-bright);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff3c4, var(--yellow) 55%, var(--yellow-deep));
    box-shadow: 0 0 0 6px rgba(246, 201, 69, 0.12), 0 0 34px rgba(246, 201, 69, 0.35);
    cursor: pointer;
    animation: targetPulse 0.7s ease-in-out infinite;
    transform-origin: center;
}

.reaction-target:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 4px;
}

.reaction-target.is-hit {
    animation: none;
    opacity: 0;
    transform: scale(1.8);
    transition: opacity 0.22s ease, transform 0.22s ease;
    pointer-events: none;
}

@keyframes targetPulse {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.12);
    }
}

.reaction-progress {
    height: 4px;
    overflow: hidden;
    border-radius: 99px;
    background: var(--bg-3);
}

.reaction-progress span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--green), var(--yellow));
    transition: width 0.3s ease;
}

.match-status {
    min-height: 18px;
    color: var(--text-dim);
    font-size: 0.76rem;
    text-align: center;
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1100px) {
    .games-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .hero-inner {
        grid-template-columns: minmax(0, 1fr);
    }

    .record-card {
        max-width: 460px;
    }

    .record-list {
        min-height: 0;
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 860px) {
    .games-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .container {
        padding: 0 16px;
    }

    .game-bar {
        display: grid;
        grid-template-columns: 42px minmax(0, 1fr) auto;
        grid-template-areas:
            "title title title"
            "back score actions";
        gap: 10px 8px;
        padding: 10px;
    }

    .game-title-wrap {
        grid-area: title;
        flex: initial;
        justify-content: flex-start;
    }

    #back-btn {
        grid-area: back;
        width: 42px;
        height: 42px;
        padding: 0;
        border-color: var(--line);
        background: var(--bg-3);
    }

    #back-btn .btn-label {
        display: none;
    }

    #game-score {
        grid-area: score;
        justify-self: start;
    }

    .game-actions {
        grid-area: actions;
        justify-content: flex-end;
    }

    .game-container {
        min-height: 380px;
        padding: 12px;
        border-radius: 20px;
    }

    .game-overlay {
        border-radius: 20px;
    }

    .game-controls {
        margin-bottom: 28px;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 28px;
        padding-top: 38px;
    }

    .footer-bottom {
        flex-direction: column;
        text-align: center;
    }

    .modal-content {
        padding: 20px;
    }

    .game-over-card {
        padding: 22px;
    }
}

@media (max-width: 560px) {
    .record-card.is-empty {
        display: none;
    }

    .header-inner {
        min-height: 66px;
    }

    .brand-tag {
        display: none;
    }

    .brand-mark {
        width: 38px;
        height: 38px;
        border-radius: 12px;
    }

    .brand-mark svg {
        width: 26px;
        height: 26px;
    }

    .brand-name {
        font-size: 0.98rem;
    }

    .hero {
        margin-top: 20px;
        margin-bottom: 32px;
        border-radius: 20px;
    }

    .hero-inner {
        padding: 22px 18px;
    }

    .hero-title {
        font-size: clamp(1.9rem, 9vw, 2.5rem);
    }

    .hero-stats {
        gap: 18px;
        margin-top: 24px;
    }

    .hero-stat strong {
        font-size: 1.15rem;
    }

    .games-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
        padding-bottom: 48px;
    }

    .game-card {
        min-height: 0;
        padding: 18px;
    }

    .section-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .game-actions {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .score-chip {
        flex: 1;
    }

    .game-container {
        min-height: 340px;
        padding: 10px;
    }

    .game-overlay {
        padding: 12px;
    }

    .game-over-actions {
        flex-direction: column;
    }

    .game-hud {
        grid-auto-flow: row;
        grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
    }

    .hud {
        padding: 8px 10px;
    }

    .cookie-notice {
        flex-direction: column;
        align-items: stretch;
        left: 12px;
        right: 12px;
        bottom: 12px;
        gap: 10px;
    }

    .cookie-btn {
        width: 100%;
    }

    .modal {
        padding: 12px;
    }

    .page-shell {
        padding: 0 16px 56px;
    }

    .error-page {
        min-height: calc(100vh - 66px);
        padding: 24px 16px;
    }
}

@media (hover: none), (max-width: 700px) {
    .touch-pad {
        display: grid;
    }
}

@media (max-width: 640px) {
    .tetris-layout {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    .tetris-side {
        order: -1;
        flex-direction: row;
        width: 100%;
        max-width: 220px;
        gap: 6px;
    }

    .tetris-side .hud {
        flex: 1;
        padding: 7px 8px;
    }

    .tetris-side .hud:first-child {
        flex: 1.4;
    }

    .next-preview {
        max-width: 44px;
        margin: 3px auto 0;
    }

    .game-canvas--tetris {
        max-width: 220px;
    }

    .touch-pad {
        max-width: 220px;
    }
}

@media (max-width: 380px) {
    #restart-btn {
        width: 42px;
        height: 42px;
        padding: 0;
    }

    #restart-btn .btn-label {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}
