@font-face { font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/be-vietnam-pro-latin-400.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/be-vietnam-pro-vietnamese-400.woff2") format("woff2"); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/be-vietnam-pro-latin-600.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/be-vietnam-pro-vietnamese-600.woff2") format("woff2"); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 700 900; font-display: swap; src: url("fonts/be-vietnam-pro-latin-700.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 700 900; font-display: swap; src: url("fonts/be-vietnam-pro-vietnamese-700.woff2") format("woff2"); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }

:root {
    color-scheme: light;
    --font: "Be Vietnam Pro", "Segoe UI", Arial, sans-serif;
    --small: 13px;
    --base: 15px;
    --large: 24px;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1b1f27;
    --muted: #6b7280;
    --line: #e2e5ea;
    --accent: #2563eb;
    --accent-soft: #e7eefc;
    --current: #e6eaf1;
    --ok: #15803d;
    --bad: #dc2626;
    --bad-soft: #fde8e8;
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f141b;
    --surface: #171d26;
    --text: #e6e9ee;
    --muted: #8d97a5;
    --line: #283140;
    --accent: #60a5fa;
    --accent-soft: #1c2b42;
    --current: #263042;
    --ok: #4ade80;
    --bad: #f87171;
    --bad-soft: #3a1d22;
}
* { box-sizing: border-box; }
body.typing-game { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: var(--base)/1.5 var(--font); }
.typing-game [hidden] { display: none !important; }
.typing-game :is(button, input) { font: inherit; color: inherit; }
.typing-game :is(button, input, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.typing-game .home-site-header { --ui-font: var(--font); }
.typing-game .home-site-header :is(a, button, span, strong, code), .typing-game .tt-global-footer, .typing-game .tt-global-footer * { font-family: var(--font) !important; }
.typing-game .tt-global-footer > span { font-size: var(--base); font-weight: 600; }
.typing-game .tt-footer-visits { font-size: var(--small); }
.tg-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.tg-main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 32px; }
.tg-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin-bottom: 16px; }
.tg-top h1 { margin: 0; font-size: var(--large); font-weight: 700; }
.tg-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.tg-segment { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.tg-segment button { padding: 6px 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.tg-segment button:hover { color: var(--text); }
.tg-segment button.selected { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tg-segment button:disabled { cursor: default; }
.tg-segment button:disabled:not(.selected) { opacity: .55; }
.tg-notice { margin-bottom: 12px; padding: 10px 14px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); }
.tg-primary { padding: 8px 18px; border: 0; border-radius: 10px; background: var(--accent); color: #fff !important; font-weight: 600; cursor: pointer; }
.typing-game .tg-input { min-width: 0; height: 52px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; outline: none; background: var(--surface); font-size: var(--large); }
.tg-input:focus { border-color: var(--accent); }
.tg-input::placeholder { color: var(--muted); font-size: var(--base); }
.tg-input.is-off { border-color: var(--bad); color: var(--bad); }

.tg-layout { gap: 20px; }
.tg-layout .tg-ranking { --ranking-accent: var(--accent); --ranking-panel: var(--surface); --ranking-row: var(--surface); --ranking-border: var(--line); margin: 0; padding: 16px; border-radius: 12px; box-shadow: none; color: var(--text); font: var(--base)/1.5 var(--font); }
.tg-ranking h2 { margin: 0; color: var(--text); font: 600 var(--base)/1.5 var(--font); }
.tg-ranking .arcade-ranking-heading button { padding: 2px 8px; background: transparent; color: var(--muted); font: var(--base)/1.5 var(--font); }
.tg-ranking .arcade-ranking-own { min-height: 0; margin: 10px 0; padding: 6px 10px; border: 0; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: var(--small); }
.tg-ranking .arcade-ranking-own:empty { display: none; }
.tg-ranking .arcade-ranking-scroll { margin-top: 10px; border-color: var(--line); scrollbar-color: var(--line) transparent; }
.tg-ranking .arcade-ranking-own:not(:empty) + .arcade-ranking-scroll { margin-top: 0; }
.tg-ranking table { font: var(--small)/1.5 var(--font); }
.tg-ranking th { height: 34px; background: var(--surface); color: var(--muted); font-size: var(--small); font-weight: 500; }
.tg-ranking td { height: 40px; background: var(--surface); border-bottom-color: var(--line); }
.tg-ranking .arcade-ranking-avatar { background: var(--current); color: var(--text); }
.tg-ranking :is(.podium-1, .podium-2, .podium-3) { color: inherit; }
.tg-ranking :is(.podium-1, .podium-2, .podium-3) .arcade-ranking-position { color: var(--accent); font-weight: 700; }
.tg-ranking .is-own td { background: var(--accent-soft); }
.tg-ranking td.arcade-ranking-empty { height: 90px; color: var(--muted); }
.tg-ranking .arcade-ranking-status { display: none; }

.tg-room { margin-bottom: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.tg-room-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tg-room-row button:not(.tg-primary) { padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px; background: transparent; cursor: pointer; }
.tg-room-row input { width: 120px; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: var(--bg); text-transform: uppercase; }
.tg-room-row input:focus { border-color: var(--accent); }
.tg-room-row strong { letter-spacing: 1px; }
.tg-room-players { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.tg-room-players:empty { display: none; }
.tg-room-player { display: grid; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.tg-room-player.is-you { border-color: var(--accent); }
.tg-room-player.is-winner { background: var(--accent-soft); }
.tg-room-player strong { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.tg-room-player span { color: var(--muted); font-size: var(--small); }
.tg-room-status { margin: 8px 0 0; color: var(--muted); font-size: var(--small); }
.tg-room-status:empty { display: none; }
.tg-room-status.is-win { color: var(--ok); font-weight: 600; }

body.typing-game { display: flex; flex-direction: column; }
body.typing-game > .tg-main { flex: 1 0 auto; width: 100%; }
.tg-chip { padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); cursor: pointer; }
.tg-chip[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.tg-ime, .tg-ime[aria-pressed="true"] { min-width: 34px; padding: 6px 0; font-weight: 800; font-size: 15px; line-height: 1; text-align: center; color: #fff; background: #2563eb; border-color: #2563eb; }
.tg-ime.is-vi, .tg-ime.is-vi[aria-pressed="true"] { background: #dc2626; border-color: #dc2626; color: #fff; }
.is-ime-alert { animation: tg-ime-alert 1s ease-in-out infinite; }
@keyframes tg-ime-alert { 0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.9); } 50% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); } }
@media (prefers-reduced-motion: reduce) { .is-ime-alert { animation: none; outline: 3px solid #f59e0b; outline-offset: 2px; } }
