:root {
  --bg: #071018;
  --bg2: #0b1420;
  --panel: #101b29;
  --panel2: #152337;
  --line: #2c3e55;
  --text: #edf5ff;
  --muted: #91a4ba;
  --accent: #2dd4ff;
  --blue: #1c69d4;
  --green: #38d996;
  --warn: #ffcf5a;
  --danger: #ff5c6a;
  --board: #d8b46a;
  --board-line: rgba(61, 43, 22, .72);
  --black: #10141c;
  --white: #f8fafc;
  --shadow: 0 24px 80px rgba(0, 0, 0, .36);
  --sans: 'Noto Sans SC', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 76% 0, rgba(45, 212, 255, .16), transparent 34%), linear-gradient(180deg, var(--bg), #09121c 52%, #0e1724);
  color: var(--text);
  font-family: var(--sans);
  overflow-x: hidden;
}

.grid-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(#000, transparent 78%);
}

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  background: rgba(7, 16, 24, .82);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand b { letter-spacing: .08em; }
.brand small { display: block; color: var(--muted); font: 700 11px var(--mono); margin-top: 2px; }
.logo { width: 38px; height: 38px; border: 1px solid rgba(255, 255, 255, .2); background: linear-gradient(135deg, #13263a, #071018); display: grid; place-items: center; }
.logo::before { content: ''; width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #111827 42%, #000); box-shadow: 11px 11px 0 #f8fafc; }
.status { display: flex; align-items: center; gap: 9px; color: var(--muted); font-weight: 800; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 18px var(--green); }
.dot.warn { background: var(--warn); box-shadow: 0 0 18px var(--warn); }
.dot.bad { background: var(--danger); box-shadow: 0 0 18px var(--danger); }

#app { width: min(1440px, calc(100% - 32px)); margin: 0 auto; }
.hidden { display: none !important; }
.view { padding: 34px 0; }
.hero { min-height: calc(100vh - 80px); display: grid; grid-template-columns: 1.2fr 440px; align-items: center; gap: 34px; }
.kicker, .eyebrow { font: 900 12px var(--mono); letter-spacing: .16em; color: var(--accent); text-transform: uppercase; }
.hero h1 { font-size: clamp(52px, 8vw, 108px); line-height: .96; margin: 14px 0; font-weight: 400; letter-spacing: -.075em; }
.hero h1 span { font-weight: 900; }
.hero p { max-width: 720px; color: #d7e4f3; font-size: 19px; }

.panel { background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .035)); border: 1px solid rgba(255, 255, 255, .14); box-shadow: var(--shadow); padding: 22px; }
.login-card { display: grid; gap: 12px; }
.login-card label { font-weight: 900; }
input { width: 100%; height: 46px; background: #0b1522; border: 1px solid var(--line); color: var(--text); padding: 0 13px; outline: none; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(45, 212, 255, .14); }
button { height: 42px; border: 1px solid var(--line); background: #142236; color: var(--text); padding: 0 14px; font-weight: 900; cursor: pointer; touch-action: manipulation; }
button:hover { border-color: var(--accent); }
button.primary { background: linear-gradient(135deg, var(--blue), #2dd4ff); border-color: transparent; color: #fff; }
button.danger { background: rgba(255, 92, 106, .12); border-color: rgba(255, 92, 106, .42); color: #ffcdd2; }
.hint, .muted { color: var(--muted); }
.layout.two { display: grid; grid-template-columns: 420px 1fr; gap: 18px; }
.panel-head { display: flex; align-items: end; justify-content: space-between; }
.count-chip { display: grid; gap: 2px; text-align: right; color: var(--muted); font-size: 12px; }
.count-chip strong { font-size: 26px; color: var(--text); }
.mono { font-family: var(--mono); }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 18px 0; }
.user-list, .user-grid { display: grid; gap: 10px; }
.user-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.user-card { border: 1px solid var(--line); background: rgba(7, 16, 24, .45); padding: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.user-card b { display: block; }
.badge { font: 900 11px var(--mono); padding: 4px 7px; border-radius: 99px; background: rgba(45, 212, 255, .14); color: #9feaff; }
.badge.busy { background: rgba(255, 207, 90, .15); color: #ffe29a; }

.game-shell { display: grid; grid-template-columns: 310px minmax(520px, 1fr) 300px; gap: 16px; align-items: start; }
.info-panel, .history-panel { position: sticky; top: 84px; }
.info-row { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid rgba(255, 255, 255, .1); padding: 12px 0; color: var(--muted); }
.info-row b { color: var(--text); text-align: right; }
.actions { display: grid; gap: 9px; margin-top: 16px; }
.result { padding: 14px; margin-top: 14px; border: 1px solid rgba(56, 217, 150, .36); background: rgba(56, 217, 150, .1); font-weight: 900; }

.board-panel { display: grid; place-items: center; }
.board-wrap { position: relative; padding: 34px; max-width: 100%; }
.board {
  width: min(76vmin, 760px);
  height: min(76vmin, 760px);
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  background: radial-gradient(circle at 28% 20%, rgba(255, 255, 255, .28), transparent 20%), linear-gradient(135deg, #e0be79, #b8893d);
  border: 2px solid #4f3414;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .38), inset 0 0 0 12px rgba(82, 49, 14, .18);
  position: relative;
  touch-action: manipulation;
}
.cell {
  position: relative;
  border: none;
  padding: 0;
  background: transparent;
  display: grid;
  place-items: center;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
}
.cell::before, .cell::after { content: ''; position: absolute; background: var(--board-line); z-index: 0; pointer-events: none; }
.cell::before { left: 0; right: 0; top: 50%; height: 1px; transform: translateY(-50%); }
.cell::after { top: 0; bottom: 0; left: 50%; width: 1px; transform: translateX(-50%); }
.cell:nth-child(15n + 1)::before { left: 50%; }
.cell:nth-child(15n)::before { right: 50%; }
.cell:nth-child(-n + 15)::after { top: 50%; }
.cell:nth-last-child(-n + 15)::after { bottom: 50%; }
.cell.disabled { cursor: not-allowed; }
@media (hover: hover) { .cell:hover { background: rgba(45, 212, 255, .14); } }
.cell.star { background-image: radial-gradient(circle at center, #35210e 0 4px, transparent 4.5px); }
.stone { width: 72%; height: 72%; border-radius: 50%; position: relative; z-index: 2; pointer-events: none; }
.stone.black { background: radial-gradient(circle at 35% 25%, #4b5563, #111827 52%, #020617); box-shadow: inset -4px -6px 12px rgba(0, 0, 0, .48), 0 5px 10px rgba(0, 0, 0, .35); }
.stone.white { background: radial-gradient(circle at 35% 25%, #fff, #e5e7eb 58%, #94a3b8); box-shadow: inset -4px -6px 12px rgba(148, 163, 184, .28), 0 5px 10px rgba(0, 0, 0, .24); }
.cell.last .stone { outline: 2px solid var(--accent); outline-offset: 3px; box-shadow: 0 0 0 3px rgba(45, 212, 255, .2), 0 0 18px rgba(45, 212, 255, .55); }
.cell.win { background-color: rgba(56, 217, 150, .24); }
.coords { position: absolute; font: 800 11px var(--mono); color: #7f93a8; pointer-events: none; }
.top-coords { left: 34px; right: 34px; top: 10px; display: grid; grid-template-columns: repeat(15, 1fr); text-align: center; }
.left-coords { top: 34px; bottom: 34px; left: 8px; display: grid; grid-template-rows: repeat(15, 1fr); align-items: center; }
.history { max-height: 64vh; overflow: auto; padding-left: 24px; color: #dbeafe; }
.history li { padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, .08); font-family: var(--mono); font-size: 13px; }
.dialog { border: 1px solid var(--line); background: #0d1724; color: var(--text); padding: 24px; box-shadow: var(--shadow); max-width: 420px; }
.dialog::backdrop { background: rgba(0, 0, 0, .62); backdrop-filter: blur(6px); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.toast { position: fixed; right: 18px; bottom: 18px; background: #0d1724; border: 1px solid var(--line); box-shadow: var(--shadow); padding: 13px 15px; transform: translateY(12px); opacity: 0; transition: .2s; z-index: 20; }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 1080px) {
  .hero, .layout.two, .game-shell { grid-template-columns: 1fr; }
  .info-panel, .history-panel { position: static; }
  .board { width: min(calc(100vw - 84px), 680px); height: min(calc(100vw - 84px), 680px); }
}

@media (max-width: 620px) {
  .topbar { padding: 0 12px; }
  .brand small { display: none; }
  #app { width: calc(100% - 18px); }
  .panel { padding: 16px; }
  .board-wrap { padding: 18px; }
  .board { width: min(calc(100vw - 72px), 680px); height: min(calc(100vw - 72px), 680px); }
  .hero { gap: 20px; }
  .hero h1 { font-size: 48px; }
  .top-coords { left: 18px; right: 18px; top: 2px; font-size: 10px; }
  .left-coords { top: 18px; bottom: 18px; left: 0; font-size: 10px; }
  .history { max-height: 220px; }
}
