:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --panel: #1c2230;
  --line: #2a3341;
  --text: #e6edf3;
  --muted: #8b98a9;
  --mine: #60e0a0;
  --foe: #ff5964;
  --accent: #6ea8ff;
  --accent2: #4b7bec;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #17203050, transparent), var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.view { min-height: 100%; }

/* ---------- Auth ---------- */
#authView {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px; gap: 18px;
}
.card {
  width: 100%; max-width: 380px;
  background: linear-gradient(180deg, var(--bg2), var(--panel));
  border: 1px solid var(--line); border-radius: 16px;
  padding: 28px 26px; box-shadow: 0 24px 60px -20px #000a;
}
.logo { margin: 0; font-size: 34px; letter-spacing: 3px; text-align: center; color: var(--mine); text-shadow: 0 0 24px #60e0a055; }
.sub { margin: 6px 0 20px; text-align: center; color: var(--muted); font-size: 13px; }
.tabs { display: flex; background: #0e131b; border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.tab { flex: 1; padding: 9px; border: 0; background: transparent; color: var(--muted); font-weight: 600; border-radius: 7px; cursor: pointer; font-size: 14px; }
.tab.active { background: var(--accent2); color: #fff; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 14px; font-weight: 600; }
input {
  width: 100%; margin-top: 6px; padding: 11px 12px;
  background: #0e131b; border: 1px solid var(--line); border-radius: 9px;
  color: var(--text); font-size: 15px; outline: none;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #6ea8ff22; }
.primary {
  width: 100%; padding: 12px; border: 0; border-radius: 10px; cursor: pointer;
  background: linear-gradient(180deg, var(--accent), var(--accent2)); color: #fff;
  font-size: 15px; font-weight: 700; transition: transform .05s, filter .15s;
}
.primary:hover { filter: brightness(1.08); }
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: .55; cursor: default; }
.msg { min-height: 18px; margin: 2px 0 12px; font-size: 13px; color: var(--foe); }
.msg.ok { color: var(--mine); }
.foot { color: var(--muted); font-size: 12px; }

/* ---------- Game ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--bg2);
}
.brand { font-weight: 800; letter-spacing: 2px; color: var(--mine); }
.userbox { display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-size: 14px; }
.who b { color: var(--text); }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.ghost:hover { color: var(--text); border-color: var(--accent); }
.ghost.sm { padding: 4px 9px; font-size: 12px; }
.ghost.danger { border-color: #7a2b30; color: var(--foe); }
.ghost.danger:hover { border-color: var(--foe); color: #fff; background: #ff596420; }
.side-actions { display: flex; gap: 6px; }

.layout {
  max-width: 1120px; margin: 0 auto; padding: 22px 20px;
  display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 22px; align-items: start;
}
.hud { display: flex; gap: 10px; margin-bottom: 12px; }
.stat { flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.stat .k { font-size: 11px; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }

.canvas-holder { position: relative; width: 100%; aspect-ratio: 760 / 480; }
#game {
  width: 100%; height: 100%; display: block;
  background: #0a0e14; border: 1px solid var(--line); border-radius: 12px;
  touch-action: none;
}
.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #0a0e14cc; backdrop-filter: blur(3px); border-radius: 12px; text-align: center;
}
.overlay.hidden { display: none; }
.overlay-inner { padding: 20px; max-width: 320px; }
.overlay-inner h2 { margin: 0 0 8px; font-size: 26px; }
.overlay-inner p { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.overlay-inner .score-big { font-size: 40px; font-weight: 800; color: var(--mine); }

.hint { color: var(--muted); font-size: 12.5px; margin-top: 12px; line-height: 1.6; }
.hint .mine { color: var(--mine); }
.hint .foe { color: var(--foe); }

.side { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.side-head h3 { margin: 0; font-size: 15px; }
.rank { list-style: none; margin: 0; padding: 0; }
.rank li { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 8px; font-size: 14px; }
.rank li:nth-child(odd) { background: #0e131b66; }
.rank li.me { background: #6ea8ff22; outline: 1px solid var(--accent); }
.rank .num { width: 26px; text-align: center; font-weight: 800; color: var(--muted); }
.rank li:nth-child(1) .num { color: #ffd54a; }
.rank li:nth-child(2) .num { color: #cdd6e0; }
.rank li:nth-child(3) .num { color: #e0965a; }
.rank .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .sc { font-variant-numeric: tabular-nums; color: var(--mine); font-weight: 700; }
.rank .empty { color: var(--muted); font-size: 13px; padding: 10px 4px; }
.rank .del { margin-left: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; line-height: 1; padding: 3px 7px; border-radius: 6px; }
.rank .del:hover { background: #ff596420; color: var(--foe); }
.admin-log { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.logbox { margin: 8px 0 0; max-height: 260px; overflow: auto; background: #0e131b; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-family: Consolas, monospace; font-size: 11px; line-height: 1.5; color: var(--muted); white-space: pre; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}
