:root {
  color-scheme: dark;
  --bg: #0d1720;
  --panel: rgba(19, 32, 44, 0.94);
  --soft: rgba(255, 255, 255, 0.065);
  --line: rgba(255, 255, 255, 0.13);
  --text: #f6fbff;
  --muted: #a9bac7;
  --gold: #ffbc42;
  --orange: #ff7a45;
  --red: #ee4b5f;
  --blue: #31a8ff;
  --green: #14c78f;
  --radius: 8px;
  font-family: Inter, "Be Vietnam Pro", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(140deg, rgba(20, 199, 143, .16), transparent 34%),
    linear-gradient(320deg, rgba(255, 122, 69, .13), transparent 38%),
    var(--bg);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.shell { width: min(1220px, calc(100% - 24px)); margin: 0 auto; padding: 18px 0 34px; }
.home { display: grid; grid-template-columns: minmax(300px, .9fr) minmax(360px, 1.1fr); gap: 18px; min-height: 100vh; }
.hero, .panel, .room-head, .versus, .board-frame, .side {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
}
.hero { display: flex; flex-direction: column; justify-content: space-between; padding: clamp(24px, 4vw, 40px); overflow: hidden; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo { display: grid; width: 52px; height: 52px; place-items: center; border-radius: var(--radius); background: var(--gold); color: #111821; font-size: 26px; font-weight: 1000; box-shadow: 5px 5px 0 #081017; }
.brand p, .brand h1 { margin: 0; }
.brand p, .kicker { color: var(--green); font-size: 12px; font-weight: 900; text-transform: uppercase; }
.brand h1 { font-size: 28px; line-height: 1; }
.hero h2 { max-width: 620px; font-size: clamp(42px, 7vw, 82px); line-height: .96; margin: 42px 0 28px; }
.hero-board { position: relative; display: grid; grid-template-columns: repeat(7,1fr); width: min(390px,100%); aspect-ratio: 1; align-self: center; background: #f5ce75; border: 2px solid rgba(255,255,255,.84); box-shadow: 12px 12px 0 var(--gold); }
.hero-board span { display: grid; place-items: center; border-right: 1px solid rgba(13,23,32,.25); border-bottom: 1px solid rgba(13,23,32,.25); font-weight: 1000; }
.hero-board .x { color: var(--red); } .hero-board .o { color: var(--blue); }
.hero-board b { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(13,23,32,.12); font-size: clamp(34px,5vw,58px); line-height: .95; text-align: center; pointer-events: none; }
.home-panel { display: grid; align-content: start; gap: 14px; padding: 16px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--soft); padding: 16px; }
.field { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 800; }
.field input, .field select { width: 100%; min-height: 46px; border: 1px solid rgba(255,255,255,.18); border-radius: var(--radius); padding: 0 13px; background: #0a1219; color: var(--text); outline: none; }
.avatar-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.avatar { display: grid; gap: 4px; min-height: 70px; place-items: center; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.07); color: var(--muted); font-size: 12px; font-weight: 800; }
.avatar span { font-size: 24px; }
.avatar.active { border-color: var(--gold); background: rgba(255,188,66,.17); color: white; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.primary, .secondary, .ghost, .danger, .warn {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  padding: 0 14px;
  color: white;
  font-weight: 900;
}
.primary { background: linear-gradient(135deg, var(--gold), var(--orange)); color: #17120a; }
.secondary { background: var(--green); color: #06130f; }
.ghost { border: 1px solid var(--line); background: rgba(255,255,255,.08); }
.danger { background: rgba(238,75,95,.18); color: #ffdbe0; border: 1px solid rgba(238,75,95,.35); }
.warn { background: var(--red); }
.room-list { display: grid; gap: 8px; }
.room-item { display: flex; justify-content: space-between; gap: 12px; align-items: center; min-height: 50px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.06); color: white; padding: 0 12px; text-align: left; }
.muted { color: var(--muted); }
.room { display: grid; gap: 14px; }
.room-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px; }
.room-head .brand span { color: var(--muted); font-size: 13px; display: block; }
.sync { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 900; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(20,199,143,.12); }
.versus { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; padding: 14px; align-items: center; }
.player { display: grid; grid-template-columns: 54px minmax(0,1fr); gap: 12px; align-items: center; min-height: 78px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.055); padding: 12px; }
.player.active { border-color: var(--gold); box-shadow: inset 4px 0 0 var(--gold); }
.pavatar { display: grid; place-items: center; width: 54px; height: 54px; border-radius: var(--radius); background: rgba(255,255,255,.1); font-size: 26px; }
.player strong, .player span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.player span { color: var(--muted); font-size: 12px; font-weight: 800; }
.vs { display: grid; place-items: center; min-width: 150px; text-align: center; }
.vs strong { color: var(--gold); font-size: 28px; }
.vs span { color: var(--muted); font-size: 13px; font-weight: 900; }
.layout { display: grid; grid-template-columns: minmax(0,1fr) 360px; gap: 14px; align-items: start; }
.board-col { display: grid; gap: 12px; }
.result-bar { display: grid; gap: 6px; border: 1px solid rgba(255,188,66,.35); border-radius: var(--radius); background: rgba(255,188,66,.13); padding: 12px; text-align: center; }
.board-frame { position: relative; width: min(74vh,100%); max-width: calc(100vw - 24px); aspect-ratio: 1; justify-self: center; padding: clamp(8px,1.3vw,14px); background: #efc86f; box-shadow: 9px 9px 0 #071018; }
.watermark { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(12,20,26,.1); font-size: clamp(36px,7vw,86px); font-weight: 1000; line-height: .9; text-align: center; pointer-events: none; }
.board { --size: 15; position: relative; z-index: 1; display: grid; grid-template-columns: repeat(var(--size), minmax(0,1fr)); grid-template-rows: repeat(var(--size), minmax(0,1fr)); width: 100%; height: 100%; border: 2px solid rgba(7,16,24,.9); background: linear-gradient(90deg,rgba(7,16,24,.3) 1px,transparent 1px), linear-gradient(0deg,rgba(7,16,24,.3) 1px,transparent 1px), rgba(255,245,204,.34); background-size: calc(100% / var(--size)) calc(100% / var(--size)); }
.cell { display: grid; place-items: center; aspect-ratio: 1; border: 0; border-right: 1px solid rgba(7,16,24,.16); border-bottom: 1px solid rgba(7,16,24,.16); background: transparent; padding: 0; }
.cell:hover { background: rgba(255,255,255,.28); }
.mark { display: grid; width: 78%; height: 78%; place-items: center; border-radius: 50%; color: #fff; font-size: clamp(12px,2vw,28px); font-weight: 1000; line-height: 1; }
.mark.x { border-radius: var(--radius); background: var(--red); }
.mark.o { background: var(--blue); }
.cell.last { background: rgba(255,255,255,.35); }
.cell.win .mark { box-shadow: 0 0 0 4px rgba(255,188,66,.55), 0 0 22px rgba(255,188,66,.6); }
.side { display: grid; gap: 12px; padding: 12px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs button { min-height: 36px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.08); color: white; font-weight: 900; padding: 0 10px; }
.tabs button.active { border-color: var(--gold); background: rgba(255,188,66,.17); }
.messages { height: 280px; overflow: auto; display: grid; align-content: start; gap: 8px; padding-right: 4px; }
.msg { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 8px; }
.msg i { display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius); background: rgba(255,255,255,.09); font-style: normal; }
.msg p { margin: 0; }
.msg strong, .msg span { display: block; }
.msg span { color: var(--muted); font-size: 13px; line-height: 1.35; word-break: break-word; }
.msg.system span { color: var(--gold); }
.msg.tease span { color: #ff9ba8; }
.chat-form { display: grid; grid-template-columns: minmax(0,1fr) 72px; gap: 8px; margin-top: 10px; }
.chat-form input { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 12px; background: #0a1219; color: white; }
.tease-menu { display: grid; gap: 6px; margin-top: 8px; }
.tease-menu button, .small-row { min-height: 36px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.07); color: white; font-weight: 800; }
.small-list { display: grid; gap: 8px; }
.small-row { display: flex; align-items: center; justify-content: space-between; padding: 0 10px; }
.h2h { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 10px; }
.h2h div, .history { border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.05); padding: 10px; }
.toast, .tease-pop { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); border-radius: var(--radius); background: #071018; box-shadow: 0 24px 70px rgba(0,0,0,.28); padding: 12px 14px; font-weight: 900; }
.toast { bottom: 18px; max-width: min(480px,calc(100% - 28px)); }
.tease-pop { top: 22px; min-width: min(420px,calc(100% - 28px)); border: 1px solid rgba(255,188,66,.42); }
.tease-pop span { display: block; color: var(--gold); font-size: 18px; }
[hidden] { display: none !important; }
@media (max-width: 980px) { .home, .layout, .versus { grid-template-columns: 1fr; } .vs { order: -1; } .board-frame { width: min(92vw,74vh); } }
@media (max-width: 680px) { .shell { width: min(100% - 18px,1220px); padding-top: 10px; } .hero h2 { font-size: 42px; } .grid2 { grid-template-columns: 1fr; } .avatar-grid { grid-template-columns: repeat(3,1fr); } .room-head { flex-direction: column; align-items: flex-start; } .btns > * { flex: 1 1 135px; } }
