:root {
    color-scheme: dark;
    --bg: #080a12;
    --ink: #f6f4ed;
    --muted: #9296a4;
    --panel: #11141e;
    --panel-2: #171a26;
    --line: rgba(255,255,255,.1);
    --cyan: #2de2e6;
    --blue: #6267ff;
    --yellow: #f5d547;
    --pink: #ff4d8d;
    --orange: #ff7043;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: radial-gradient(circle at 70% 7%, rgba(80,69,193,.18), transparent 30rem), var(--bg); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, summary, a { font: inherit; }
button, summary, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
[hidden] { display: none !important; }
.sr-only { width: 1px; height: 1px; padding: 0; position: absolute; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
::selection { color: #090b12; background: var(--cyan); }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 4px; }
.site-shell { min-height: 100vh; overflow: clip; }

.topbar { height: 82px; max-width: 1500px; margin: auto; padding: 0 40px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; position: relative; z-index: 30; border-bottom: 1px solid var(--line); }
.brand { width: max-content; display: inline-flex; align-items: center; gap: 12px; font-weight: 950; letter-spacing: -.045em; }
.brand > span:last-child span { color: var(--cyan); }
.brand-mark { display: grid; grid-template-columns: repeat(3, 7px); grid-template-rows: repeat(2, 7px); gap: 2px; transform: rotate(-8deg); }
.brand-mark i { background: var(--cyan); }
.brand-mark i:nth-child(1) { grid-column: 2; }
.brand-mark i:nth-child(4) { background: var(--pink); }
.nav { height: 100%; display: flex; gap: 38px; }
.nav a { min-width: 54px; display: grid; place-items: center; position: relative; color: #767a89; font-size: 11px; font-weight: 850; letter-spacing: .16em; text-align: center; }
.nav a.is-active { color: var(--ink); }
.nav a.is-active::after { content: ""; height: 3px; position: absolute; inset: auto 0 0; background: var(--cyan); }
.language-menu { justify-self: end; position: relative; }
.language-menu summary { padding: 10px 0 10px 16px; list-style: none; color: var(--ink); font-size: 11px; font-weight: 850; letter-spacing: .12em; cursor: pointer; }
.language-menu summary::-webkit-details-marker { display: none; }
.language-menu summary span { margin-inline-start: 7px; color: var(--muted); transition: transform .2s ease; }
.language-menu[open] summary span { display: inline-block; transform: rotate(180deg); }
.language-panel { width: min(530px, calc(100vw - 32px)); padding: 20px; position: absolute; top: calc(100% + 13px); inset-inline-end: 0; background: rgba(17,20,30,.98); border: 1px solid rgba(255,255,255,.14); box-shadow: 0 22px 70px rgba(0,0,0,.55); backdrop-filter: blur(18px); }
.language-panel > strong { display: block; margin-bottom: 14px; color: #747988; font-size: 9px; letter-spacing: .18em; }
.language-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.language-grid a { min-height: 52px; padding: 9px 11px; display: grid; align-content: center; border: 1px solid transparent; background: rgba(255,255,255,.025); }
.language-grid a:hover, .language-grid a.is-current { border-color: rgba(45,226,230,.55); background: rgba(45,226,230,.07); }
.language-grid span { font-size: 12px; font-weight: 800; }
.language-grid small { margin-top: 2px; color: #747988; font-size: 9px; }

.game-hero { max-width: 1420px; min-height: calc(100vh - 82px); margin: 0 auto; padding: 50px 40px 68px; display: grid; grid-template-columns: minmax(250px,.72fr) minmax(650px,1.6fr); gap: 56px; align-items: center; }
.eyebrow { color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .2em; }
.eyebrow span { width: 22px; height: 2px; margin-inline-end: 8px; display: inline-block; background: var(--cyan); vertical-align: middle; }
.intro-copy h1 { margin: 20px 0; font-size: clamp(62px,7vw,116px); line-height: .82; letter-spacing: -.075em; font-weight: 950; }
.intro-copy h1 em { color: transparent; -webkit-text-stroke: 1px rgba(245,243,236,.65); font-style: normal; }
.lede { max-width: 390px; color: #9a9eaa; font-size: 14px; line-height: 1.75; }
.personal-best { margin-top: 38px; padding-inline-start: 16px; display: grid; border-inline-start: 2px solid var(--yellow); }
.personal-best span, .personal-best small { color: #858a98; font-size: 9px; font-weight: 800; letter-spacing: .14em; }
.personal-best strong { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 28px; letter-spacing: .04em; }

.game-stage { direction: ltr; background: linear-gradient(145deg, rgba(22,25,38,.97), rgba(10,12,20,.98)); border: 1px solid var(--line); box-shadow: 0 35px 80px rgba(0,0,0,.42); }
.game-toolbar { min-height: 47px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); color: #838795; font-size: 9px; font-weight: 850; letter-spacing: .15em; }
.game-status { display: flex; align-items: center; }
.toolbar-actions { display: flex; gap: 4px; }
.game-toolbar button { min-height: 32px; padding: 0 8px; border: 0; color: #8d91a0; background: transparent; font-size: inherit; font-weight: inherit; letter-spacing: inherit; cursor: pointer; }
.game-toolbar button:hover { color: var(--cyan); }
.live-dot { width: 6px; height: 6px; margin-right: 8px; display: inline-block; flex: 0 0 auto; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); border-radius: 50%; }
.game-grid { padding: 26px 22px; display: grid; grid-template-columns: 110px minmax(270px,330px) 112px; justify-content: center; gap: 16px; }
.stat-column { display: flex; flex-direction: column; gap: 24px; }
.stat { display: grid; gap: 6px; }
.stat span, .piece-card > span, .speed-card span { color: #6f7481; font-size: 8px; font-weight: 850; letter-spacing: .18em; }
.stat strong { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 18px; }
.board-wrap { width: 100%; aspect-ratio: 1/2; max-height: 600px; min-height: 510px; position: relative; overflow: hidden; background: #070910; border: 1px solid rgba(255,255,255,.15); touch-action: none; }
#tetris-board { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.game-screen { width: min(82%,272px); padding: 25px 22px 22px; position: absolute; z-index: 3; inset: 50% auto auto 50%; transform: translate(-50%,-50%); text-align: center; background: rgba(17,20,31,.97); border: 1px solid rgba(255,255,255,.14); box-shadow: 0 18px 55px #000; }
.game-screen h2 { margin: 12px 0 7px; font-size: 29px; letter-spacing: -.045em; }
.game-screen p { margin: 0 0 16px; color: #8d91a0; font-size: 10px; line-height: 1.6; }
.mini-blocks { width: 34px; height: 20px; display: inline-block; background: linear-gradient(90deg, var(--cyan) 0 32%, transparent 32% 34%, var(--cyan) 34% 66%, transparent 66% 68%, var(--cyan) 68%); box-shadow: 0 0 18px rgba(45,226,230,.35); }
.game-screen label { display: block; margin: 0 0 6px; text-align: start; color: #737886; font-size: 8px; font-weight: 850; letter-spacing: .15em; }
.game-screen input { width: 100%; height: 39px; padding: 0 11px; border: 1px solid #343846; outline: none; color: var(--ink); background: #0c0f17; font-size: 11px; }
.game-screen input:focus { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(45,226,230,.12); }
.game-screen input[aria-invalid="true"] { border-color: var(--pink); }
.form-error { min-height: 20px; padding-top: 5px; display: block; color: #ff7aa9; text-align: start; font-size: 8px; line-height: 1.3; }
.primary-button { min-height: 42px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: space-between; gap: 24px; border: 0; background: var(--ink); color: #0a0b10; font-size: 10px; font-weight: 950; letter-spacing: .12em; cursor: pointer; }
button.primary-button { width: 100%; }
.primary-button:hover { background: var(--cyan); }
.primary-button:disabled { cursor: wait; opacity: .55; }
.primary-button span { font-size: 17px; }
.result-card { padding-top: 28px; }
.result-card h2 { margin: 4px 0 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 38px; color: var(--cyan); }
.result-kicker, .result-label { color: #808594 !important; font-size: 8px !important; font-weight: 850; letter-spacing: .17em; }
.result-message { min-height: 32px; margin: 14px 0 !important; color: var(--ink) !important; }
.text-link { margin-top: 16px; display: inline-block; color: var(--cyan); font-size: 8px; font-weight: 850; letter-spacing: .12em; }
.pause-glyph { width: 28px; height: 34px; margin: auto; display: block; border-inline: 8px solid var(--cyan); }
.piece-card, .speed-card { display: grid; gap: 8px; }
.piece-card canvas { width: 70px; height: 62px; border: 1px solid var(--line); background: rgba(255,255,255,.02); }
.speed-card { margin-top: auto; }
.speed-card strong { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 22px; color: var(--cyan); }
.speed-card small { color: #666b79; font-size: 8px; line-height: 1.4; }
.controls-hint { padding: 13px 8px; overflow: hidden; border-top: 1px solid var(--line); color: #606573; text-align: center; white-space: nowrap; font-size: 7px; letter-spacing: .1em; }
kbd { min-width: 19px; margin-inline-start: 6px; padding: 3px 5px; display: inline-grid; place-items: center; border: 1px solid #343846; color: #aeb2bd; background: #171a24; box-shadow: none; font: inherit; }
.touch-controls { display: none; grid-template-columns: repeat(5,1fr); border-top: 1px solid var(--line); }
.touch-controls button { min-height: 58px; border: 0; border-inline-end: 1px solid var(--line); background: #141722; font-size: 20px; touch-action: manipulation; }
.touch-controls button:active { color: #071014; background: var(--cyan); }
.touch-controls .drop-control { color: var(--yellow); }

.game-facts { padding: 82px max(40px,calc((100vw - 1340px)/2)); display: grid; grid-template-columns: minmax(280px,.8fr) minmax(520px,1.35fr); gap: 72px; align-items: start; border-top: 1px solid var(--line); }
.game-facts-copy h2 { max-width: 570px; margin: 18px 0 20px; font-size: clamp(42px,5vw,76px); line-height: .92; letter-spacing: -.055em; }
.game-facts-copy > p:last-child { max-width: 560px; margin: 0; color: #9a9eaa; font-size: 14px; line-height: 1.8; }
.game-facts-grid { margin: 0; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); background: rgba(17,20,30,.72); }
.game-facts-grid > div { min-height: 150px; padding: 27px; border-bottom: 1px solid var(--line); }
.game-facts-grid > div:nth-child(odd) { border-inline-end: 1px solid var(--line); }
.game-facts-grid > div:nth-last-child(-n+2) { border-bottom: 0; }
.game-facts-grid dt { color: var(--cyan); font-size: 9px; font-weight: 900; letter-spacing: .15em; }
.game-facts-grid dd { margin: 18px 0 0; color: #9296a4; font-size: 12px; line-height: 1.75; }
.game-facts-grid a { margin-top: 10px; display: block; color: var(--ink); font-size: 9px; font-weight: 850; letter-spacing: .1em; }
.game-facts-grid a:hover { color: var(--cyan); }

.rank-teaser { min-height: 330px; padding: 68px max(40px,calc((100vw - 1340px)/2)); display: grid; grid-template-columns: 1fr 1fr auto; gap: 50px; align-items: end; background: #11141e; border-block: 1px solid var(--line); }
.rank-teaser > div > span { color: var(--cyan); font-size: 9px; font-weight: 850; letter-spacing: .17em; }
.rank-teaser h2 { margin: 12px 0 0; font-size: 47px; line-height: .92; letter-spacing: -.045em; }
.rank-teaser p { max-width: 300px; color: #858a98; font-size: 13px; line-height: 1.7; }
.rank-teaser a { padding-bottom: 8px; border-bottom: 1px solid var(--cyan); color: var(--cyan); font-size: 10px; font-weight: 900; letter-spacing: .12em; }
.rank-teaser a span { margin-inline-start: 24px; }

.ranking-hero { max-width: 1360px; min-height: 430px; margin: auto; padding: 76px 40px 65px; display: grid; grid-template-columns: minmax(450px,1.25fr) 1fr auto; gap: 54px; align-items: end; }
.ranking-hero h1 { max-width: 730px; margin: 16px 0 0; font-size: clamp(70px,9vw,130px); line-height: .82; letter-spacing: -.075em; }
.ranking-hero > p { max-width: 390px; margin: 0; color: #959aa8; font-size: 14px; line-height: 1.75; }
.ranking-content { padding: 0 max(28px,calc((100vw - 1320px)/2)) 100px; }
.ranking-summary { display: grid; grid-template-columns: repeat(4,1fr); border: 1px solid var(--line); border-bottom: 0; background: #0d1019; }
.summary-stat { min-height: 105px; padding: 24px; display: grid; align-content: center; gap: 8px; border-inline-end: 1px solid var(--line); }
.summary-stat:last-child { border: 0; }
.summary-stat span { color: #707583; font-size: 8px; font-weight: 850; letter-spacing: .17em; }
.summary-stat strong { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 27px; }
.summary-stat.is-accent strong { color: var(--cyan); }
.ranking-layout { display: grid; grid-template-columns: minmax(0,1fr) 270px; border: 1px solid var(--line); }
.leaderboard-card { min-height: 480px; overflow: hidden; background: #10131d; }
.ranking-table-wrap { overflow-x: auto; }
.ranking-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.ranking-table th { height: 49px; padding: 0 16px; border-bottom: 1px solid var(--line); color: #666b78; text-align: start; font-size: 8px; letter-spacing: .14em; }
.ranking-table th:first-child { width: 82px; }.ranking-table th:nth-child(2) { width: 30%; }.ranking-table th:nth-child(3) { width: 16%; }
.ranking-table td { height: 70px; padding: 0 16px; border-bottom: 1px solid rgba(255,255,255,.065); color: #a6aab5; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.ranking-table td:nth-child(2) { font-family: inherit; }
.ranking-table td:nth-child(2) strong { display: block; color: var(--ink); font-size: 12px; }
.ranking-table td:nth-child(2) small { color: var(--cyan); font-size: 7px; letter-spacing: .1em; }
.ranking-table .score-cell { color: var(--ink); font-size: 14px; font-weight: 850; }
.ranking-table tr.is-current-player { background: rgba(45,226,230,.055); box-shadow: inset 3px 0 var(--cyan); }
.rank-number { display: inline-flex; align-items: center; gap: 8px; color: #7f8492; font-weight: 850; }
.rank-number i { width: 9px; height: 9px; display: inline-block; transform: rotate(45deg); background: #7f8492; }
.rank-1 { color: var(--yellow); }.rank-1 i { background: var(--yellow); box-shadow: 0 0 11px rgba(245,213,71,.5); }
.rank-2 { color: #c9d3e6; }.rank-2 i { background: #c9d3e6; }
.rank-3 { color: #d78e62; }.rank-3 i { background: #d78e62; }
.empty-ranking { min-height: 480px; padding: 70px 24px; display: grid; place-items: center; align-content: center; text-align: center; }
.empty-ranking h2 { margin: 24px 0 8px; font-size: 29px; }
.empty-ranking p { margin: 0 0 25px; color: var(--muted); font-size: 13px; }
.empty-blocks { width: 72px; height: 54px; display: grid; grid-template-columns: repeat(3,1fr); grid-template-rows: repeat(2,1fr); gap: 3px; transform: rotate(-4deg); }
.empty-blocks i { background: var(--cyan); box-shadow: inset 0 0 0 2px rgba(255,255,255,.15); }.empty-blocks i:first-child { grid-column: 2; }.empty-blocks i:last-child { background: var(--pink); }
.ranking-rules { padding: 38px 30px; background: #151824; border-inline-start: 1px solid var(--line); }
.ranking-rules > span { color: var(--cyan); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.ranking-rules h2 { margin: 64px 0 14px; font-size: 21px; letter-spacing: -.03em; }
.ranking-rules p { color: #9296a4; font-size: 12px; line-height: 1.75; }
.ranking-rules a { margin-top: 50px; padding-bottom: 7px; display: inline-block; border-bottom: 1px solid var(--cyan); color: var(--cyan); font-size: 9px; font-weight: 850; letter-spacing: .11em; }
.ranking-rules a span { margin-inline-start: 18px; }

.site-footer { min-height: 170px; max-width: 1360px; margin: auto; padding: 50px 40px 78px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 30px; }
.site-footer p { color: #5e6370; font-size: 8px; letter-spacing: .14em; }
.site-footer > a:last-child { justify-self: end; color: #858a97; font-size: 9px; font-weight: 850; letter-spacing: .12em; }
.site-footer > a:last-child span { margin-inline-start: 10px; color: var(--cyan); }

[dir="rtl"] .intro-copy h1, [dir="rtl"] .ranking-hero h1 { letter-spacing: -.035em; }
[dir="rtl"] .ranking-table th, [dir="rtl"] .ranking-table td { text-align: right; }
[dir="rtl"] .ranking-table tr.is-current-player { box-shadow: inset -3px 0 var(--cyan); }

@media (max-width: 1080px) {
    .game-hero { grid-template-columns: 1fr; }
    .intro-copy { display: grid; grid-template-columns: 1fr 1fr; gap: 0 36px; align-items: end; }
    .intro-copy .eyebrow, .intro-copy h1 { grid-column: 1; }
    .intro-copy .lede, .intro-copy .personal-best { grid-column: 2; }
    .intro-copy .lede { grid-row: 1 / 3; align-self: end; }
    .game-stage { width: min(760px,100%); margin: auto; }
    .game-facts { grid-template-columns: 1fr; gap: 38px; }
    .ranking-hero { grid-template-columns: 1fr 1fr; }.ranking-hero .primary-button { grid-column: 2; width: max-content; }
    .ranking-table th:nth-child(6), .ranking-table td:nth-child(6), .ranking-table th:nth-child(7), .ranking-table td:nth-child(7) { display: none; }
}

@media (max-width: 760px) {
    .topbar { height: 66px; padding: 0 18px; grid-template-columns: 1fr auto; }
    .nav { height: 58px; position: fixed; z-index: 25; inset: auto 0 0; justify-content: stretch; gap: 0; background: rgba(8,10,18,.96); border-top: 1px solid var(--line); backdrop-filter: blur(15px); }
    .nav a { width: 50%; }
    .language-menu { grid-column: 2; }.language-panel { position: fixed; top: 66px; right: 16px; left: auto; }
    .language-grid { grid-template-columns: repeat(2,1fr); }
    .game-hero { padding: 38px 16px 88px; gap: 30px; }
    .intro-copy { display: block; }
    .intro-copy h1 { font-size: clamp(57px,18vw,86px); }
    .game-grid { padding: 14px 8px; grid-template-columns: minmax(0,1fr); gap: 11px; }
    .stat-left { display: grid; grid-template-columns: repeat(4,1fr); gap: 7px; order: 0; }
    .stat-left .stat { padding: 8px; background: rgba(255,255,255,.025); }
    .stat strong { font-size: 13px; }
    .board-wrap { width: min(100%,340px); min-height: 0; margin: auto; order: 1; }
    .stat-right { display: grid; grid-template-columns: 1fr 1fr 1.15fr; gap: 7px; order: 2; }
    .piece-card, .speed-card { min-height: 78px; margin: 0; padding: 8px; border: 1px solid var(--line); }
    .piece-card canvas { width: 55px; height: 49px; border: 0; }
    .speed-card strong { font-size: 17px; }.speed-card small { display: none; }
    .controls-hint { display: none; }.touch-controls { display: grid; }
    .game-facts { padding: 58px 22px; }.game-facts-grid { grid-template-columns: 1fr; }.game-facts-grid > div { min-height: 0; }.game-facts-grid > div:nth-child(odd) { border-inline-end: 0; }.game-facts-grid > div:nth-last-child(2) { border-bottom: 1px solid var(--line); }
    .rank-teaser { padding: 54px 22px 92px; grid-template-columns: 1fr; gap: 24px; }.rank-teaser h2 { font-size: 41px; }
    .ranking-hero { min-height: 0; padding: 60px 22px 48px; grid-template-columns: 1fr; gap: 24px; }.ranking-hero h1 { font-size: clamp(62px,20vw,100px); }.ranking-hero .primary-button { grid-column: 1; }
    .ranking-content { padding: 0 12px 90px; }.ranking-summary { grid-template-columns: 1fr 1fr; }.summary-stat { min-height: 88px; padding: 17px; border-bottom: 1px solid var(--line); }.summary-stat:nth-child(2) { border-inline-end: 0; }.summary-stat strong { font-size: 21px; }
    .ranking-layout { grid-template-columns: 1fr; }.ranking-rules { border: 0; border-top: 1px solid var(--line); }.ranking-rules h2 { margin-top: 28px; }
    .ranking-table th:nth-child(4), .ranking-table td:nth-child(4), .ranking-table th:nth-child(5), .ranking-table td:nth-child(5) { display: none; }.ranking-table th:nth-child(2) { width: 45%; }.ranking-table th:nth-child(3) { width: 28%; }.ranking-table th, .ranking-table td { padding: 0 10px; }
    .site-footer { padding: 44px 22px 95px; grid-template-columns: 1fr auto; }.site-footer p { display: none; }
}

@media (hover: none) and (pointer: coarse) { .touch-controls { display: grid; } }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
