:root {
  --bg: #101216;
  --panel: #181b21;
  --panel-soft: #1d2128;
  --line: #30353d;
  --line-bright: #464c56;
  --text: #f4f1ea;
  --muted: #9297a2;
  --muted-strong: #c2c4c9;
  --accent: #d8f36a;
  --accent-dark: #202617;
  --orange: #ff936d;
  --shadow: 0 24px 80px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(circle at 50% -10%, #222730 0, var(--bg) 42%);
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  transition: background .3s ease, color .3s ease;
}
button { font: inherit; }
.app-shell { width: min(100% - 40px, 680px); margin: 0 auto; padding: 32px 0 26px; }
.site-header { display: flex; justify-content: space-between; align-items: center; }
.brand { color: var(--text); display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-family: "Space Grotesk", sans-serif; font-size: 18px; font-weight: 700; letter-spacing: -.6px; }
.brand > span:last-child span { color: var(--accent); }
.brand-mark { display: grid; grid-template-columns: repeat(2, 6px); grid-template-rows: repeat(2, 6px); gap: 3px; transform: rotate(45deg); }
.brand-mark span { display: block; width: 6px; height: 6px; border-radius: 2px; background: var(--accent); }
.brand-mark span:nth-child(2), .brand-mark span:nth-child(3) { background: var(--orange); }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted-strong); background: var(--panel); display: grid; place-items: center; cursor: pointer; transition: border-color .2s, transform .2s, color .2s; }
.icon-button:hover { border-color: var(--line-bright); color: var(--accent); transform: translateY(-2px); }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.hero { text-align: center; padding: 54px 0 30px; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 1.8px; margin: 0 0 15px; text-transform: uppercase; }
.dot { display: inline-block; width: 4px; height: 4px; margin: 0 7px 2px; border-radius: 50%; background: var(--accent); }
h1 { margin: 0; color: var(--text); font-family: "Space Grotesk", sans-serif; font-size: clamp(42px, 9vw, 66px); letter-spacing: -3px; line-height: .95; }
.subtitle { color: var(--muted); font-size: 14px; margin: 17px 0 0; }
.scoreboard { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 34px; }
.score-card { min-height: 85px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 15px; background: rgba(24, 27, 33, .7); transition: border-color .25s, background .25s; }
.score-card.active { border-color: var(--accent); background: linear-gradient(135deg, rgba(216, 243, 106, .11), rgba(24, 27, 33, .7)); }
.player-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 600; }
.player-symbol, .draw-symbol { display: inline-grid; width: 18px; height: 18px; place-items: center; border-radius: 5px; font-family: "Space Grotesk", sans-serif; font-size: 11px; font-weight: 700; }
.x-symbol { background: var(--accent); color: #202517; }
.o-symbol { background: var(--orange); color: #291c18; }
.draw-symbol { color: var(--muted-strong); background: #353941; font-size: 15px; }
.score-card strong { display: block; margin-top: 6px; color: var(--text); font-family: "Space Grotesk", sans-serif; font-size: 26px; line-height: 1; }
.game-area { display: flex; justify-content: center; }
.board-wrap { width: min(100%, 430px); }
.turn-indicator { display: flex; justify-content: center; align-items: center; gap: 8px; min-height: 26px; margin-bottom: 13px; color: var(--muted-strong); font-size: 13px; font-weight: 600; }
.turn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 11px rgba(216, 243, 106, .7); transition: background .2s, box-shadow .2s; }
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cell { position: relative; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 17px; background: linear-gradient(145deg, #1a1d23, #15181d); color: var(--text); cursor: pointer; box-shadow: inset 0 1px rgba(255,255,255,.02); transition: transform .2s, border-color .2s, background .2s; }
.cell:not(:disabled):hover { border-color: var(--accent); background: #20251e; transform: translateY(-3px); }
.cell:focus-visible, .button:focus-visible, .icon-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.cell:disabled { cursor: default; }
.cell::after, .cell::before { content: ""; position: absolute; left: 50%; top: 50%; opacity: 0; transform: translate(-50%, -50%) scale(.4); transition: opacity .18s, transform .22s cubic-bezier(.2,.8,.2,1); }
.cell.x::before, .cell.x::after { width: 9px; height: 62px; border-radius: 8px; background: var(--accent); opacity: 1; transform: translate(-50%, -50%) rotate(45deg); box-shadow: 0 0 17px rgba(216,243,106,.12); }
.cell.x::after { transform: translate(-50%, -50%) rotate(-45deg); }
.cell.o::before { width: 55px; height: 55px; border: 9px solid var(--orange); border-radius: 50%; opacity: 1; transform: translate(-50%, -50%) scale(1); box-shadow: 0 0 17px rgba(255,147,109,.1); }
.cell.winner { background: #29321d; border-color: var(--accent); animation: pulse .8s ease-in-out infinite alternate; }
.cell.winner.o { background: #34231d; border-color: var(--orange); }
@keyframes pulse { to { transform: scale(1.025); } }
.actions { display: flex; justify-content: center; gap: 10px; margin: 30px 0 23px; }
.button { border: 0; border-radius: 11px; padding: 13px 19px; font-size: 13px; font-weight: 700; cursor: pointer; transition: transform .2s, background .2s, border-color .2s; }
.button:hover { transform: translateY(-2px); }
.button-primary { display: flex; align-items: center; gap: 19px; background: var(--accent); color: var(--accent-dark); }
.button-primary:hover { background: #e5fa86; }
.button-arrow { font-size: 18px; line-height: 10px; }
.button-ghost { color: var(--muted-strong); background: transparent; border: 1px solid var(--line); }
.button-ghost:hover { border-color: var(--line-bright); color: var(--text); }
.tip { display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--muted); font-size: 11px; }
.tip-icon { display: grid; place-items: center; width: 15px; height: 15px; border: 1px solid #61666e; border-radius: 50%; font-size: 10px; font-weight: 700; }
footer { padding-top: 46px; color: #5f646d; text-align: center; font-size: 11px; letter-spacing: .2px; }
footer span { color: var(--muted); }
.confetti { pointer-events: none; position: fixed; inset: 0; overflow: hidden; z-index: 10; }
.confetti-piece { position: absolute; top: -14px; width: 8px; height: 14px; animation: fall 1.25s ease-in forwards; }
@keyframes fall { to { transform: translate3d(var(--drift), 105vh, 0) rotate(620deg); opacity: 0; } }
body.light { --bg: #f2f3ed; --panel: #ffffff; --panel-soft: #f7f8f3; --line: #dfe2d8; --line-bright: #c5cabe; --text: #20231f; --muted: #737971; --muted-strong: #4f554e; --accent-dark: #2c351c; --shadow: 0 24px 80px rgba(53, 62, 40, .12); background: radial-gradient(circle at 50% -10%, #fff 0, var(--bg) 55%); }
body.light .cell { background: linear-gradient(145deg, #fff, #f5f7ef); }
body.light .cell:not(:disabled):hover { background: #f2f8df; }
body.light .score-card { background: rgba(255,255,255,.7); }
@media (max-width: 520px) { .app-shell { width: min(100% - 28px, 440px); padding-top: 20px; } .hero { padding: 44px 0 25px; } .score-card { padding: 13px 10px; } .player-label { font-size: 10px; } .board { gap: 7px; } .cell { border-radius: 13px; } .cell.x::before, .cell.x::after { height: 48px; width: 7px; } .cell.o::before { width: 43px; height: 43px; border-width: 7px; } .actions { margin-top: 24px; } }
.header-actions { display: flex; align-items: center; gap: 9px; }
.account-button { display: flex; align-items: center; gap: 7px; min-height: 40px; padding: 4px 10px 4px 5px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted-strong); background: var(--panel); cursor: pointer; font-size: 11px; font-weight: 700; transition: border-color .2s, transform .2s; }
.account-button:hover { border-color: var(--line-bright); transform: translateY(-2px); }
.main-site-link { color: var(--muted); font-size: 11px; font-weight: 700; text-decoration: none; }
.main-site-link:hover { color: var(--accent); }
.account-avatar { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 9px; color: var(--accent-dark); background: var(--accent); font-family: "Space Grotesk", sans-serif; font-size: 12px; }
.save-note { display: flex; justify-content: center; align-items: center; gap: 7px; min-height: 18px; margin: 0 0 7px; color: var(--muted); font-size: 11px; }
.save-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.modal-open { overflow: hidden; }
.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(5, 7, 9, .7); backdrop-filter: blur(8px); }
.modal-backdrop[hidden] { display: none; }
.auth-modal { position: relative; width: min(100%, 395px); padding: 34px; border: 1px solid var(--line-bright); border-radius: 20px; background: var(--panel); box-shadow: var(--shadow); }
.modal-close { position: absolute; top: 13px; right: 16px; border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 25px; line-height: 1; }
.auth-modal .eyebrow { margin-bottom: 11px; }
.auth-modal h2 { margin: 0; color: var(--text); font-family: "Space Grotesk", sans-serif; font-size: 28px; letter-spacing: -1px; }
.auth-subtitle { margin: 10px 0 22px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.auth-tabs { display: flex; gap: 4px; margin-bottom: 21px; padding: 4px; border-radius: 10px; background: var(--panel-soft); }
.auth-tab { flex: 1; padding: 9px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; }
.auth-tab.active { color: var(--text); background: var(--line); }
.auth-modal label { display: block; margin: 13px 0 7px; color: var(--muted-strong); font-size: 11px; font-weight: 700; }
.auth-modal input { width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 9px; outline: none; color: var(--text); background: var(--panel-soft); font-size: 14px; }
.auth-modal input:focus { border-color: var(--accent); }
.form-error { min-height: 18px; margin: 9px 0 2px; color: #ff927d; font-size: 11px; }
.auth-submit { width: 100%; justify-content: space-between; margin-top: 5px; }
.profile-modal { text-align: center; }
.profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 24px 0; }
.profile-stats div { padding: 14px 5px; border: 1px solid var(--line); border-radius: 11px; }
.profile-stats strong { display: block; color: var(--text); font-family: "Space Grotesk", sans-serif; font-size: 25px; }
.profile-stats span { color: var(--muted); font-size: 10px; }
.full-button { width: 100%; }
@media (max-width: 520px) { .account-button { padding-right: 6px; } .account-button #accountLabel { display: none; } .auth-modal { padding: 30px 24px; } }
.mode-panel { display: flex; align-items: center; justify-content: center; gap: 5px; width: fit-content; margin: 0 auto 23px; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); }
.mode-button { border: 0; border-radius: 7px; padding: 9px 14px; color: var(--muted); background: transparent; cursor: pointer; font-size: 11px; font-weight: 700; }
.mode-button.active { color: var(--text); background: var(--line); }
.mode-button:hover { color: var(--text); }
.match-status { min-width: 10px; margin-left: 5px; color: var(--accent); font-size: 10px; font-weight: 600; }
@media (max-width: 520px) { .mode-panel { max-width: 100%; } .match-status { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }
.chat-panel { width: min(100%, 430px); margin: 16px auto 0; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: rgba(24, 27, 33, .7); }
.chat-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; color: var(--muted-strong); font-size: 12px; font-weight: 700; }
.chat-hint { color: var(--muted); font-size: 9px; font-weight: 500; }
.chat-messages { height: 118px; overflow-y: auto; padding: 2px 1px; }
.chat-empty { margin: 38px 0; color: var(--muted); text-align: center; font-size: 11px; }
.chat-message { display: flex; gap: 7px; margin: 0 0 8px; color: var(--muted-strong); font-size: 11px; line-height: 1.35; }
.chat-message strong { flex: 0 0 auto; color: var(--accent); }
.chat-message span { overflow-wrap: anywhere; }
.chat-form { display: flex; gap: 7px; margin-top: 10px; }
.chat-form input { min-width: 0; flex: 1; padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; outline: none; color: var(--text); background: var(--panel-soft); font-size: 11px; }
.chat-form input:focus { border-color: var(--accent); }
.chat-form .button { padding: 10px 14px; font-size: 11px; }
