/* Barricade — stylesheet. Layout follows the reference screenshots:
   dark page, rounded dark board, tinted goal rows, side panel on desktop,
   stacked layout on phones. */

:root {
  --bg: #0b0b0c;
  --panel: #1c1c1e;
  --panel-2: #2a2a2c;
  --sq: #262628;
  --sq-border: #3a3a3c;
  --line: #333336;
  --text: #ececee;
  --muted: #8e8e93;
  --red: #ef4444;
  --red-deep: #dc2626;
  --blue: #3b82f6;
  --green: #22c55e;
  --yellow: #eab308;
  --active-card: #1f4a33;
  --active-edge: #34d399;
  --radius: 14px;
  --sq-radius: 5px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
input { font-family: inherit; font-size: inherit; }
:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- home */
.home {
  max-width: 440px; margin: 0 auto; padding: 56px 20px 40px;
  display: flex; flex-direction: column; gap: 22px;
}
.home h1 { font-size: 40px; margin: 0; letter-spacing: -0.02em; font-weight: 700; }
.home .tagline { color: var(--muted); margin: -12px 0 0; line-height: 1.45; }
.card { background: var(--panel); border-radius: var(--radius); padding: 18px; }
.card h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
input[type="text"] {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 11px 12px; width: 100%; min-width: 0;
}
input[type="text"]::placeholder { color: #6b6b70; }
input[type="text"]:focus { border-color: #6b6b70; outline: none; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.seg { display: flex; background: var(--panel-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; background: transparent; color: var(--muted); border: 0; border-radius: 8px; padding: 9px 8px; font-weight: 600;
}
.seg button.on { background: #3d3d40; color: var(--text); }
.btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 14px; font-weight: 600;
}
.btn.primary { background: #fff; color: #000; border-color: #fff; }
.btn.danger { background: var(--red-deep); color: #fff; border-color: var(--red-deep); }
.btn.small { padding: 7px 10px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.mt { margin-top: 12px; }
.err { color: #fca5a5; font-size: 13px; min-height: 1.2em; }

/* --------------------------------------------------------------- lobby */
.lobby { max-width: 480px; margin: 0 auto; padding: 40px 20px; display: flex; flex-direction: column; gap: 16px; }
.lobby .code-box { text-align: center; }
.lobby .code-box .label { color: var(--muted); font-size: 13px; }
.lobby .code-box .code { font-size: 42px; font-weight: 700; letter-spacing: .18em; margin: 2px 0 6px; }
.lobby .code-box .link { color: var(--muted); font-size: 13px; word-break: break-all; }
.plist { display: flex; flex-direction: column; gap: 8px; }
.plist .seat {
  display: flex; align-items: center; gap: 10px; background: var(--panel-2);
  border-radius: 10px; padding: 10px 12px; border-left: 4px solid var(--seat-color, #555);
}
.plist .seat.empty { border-left-color: #444; color: var(--muted); border-style: dashed; background: transparent; }
.plist .seat .nm { flex: 1; font-weight: 600; }
.plist .seat .tag { color: var(--muted); font-size: 12px; }
.lobby .status { color: var(--muted); font-size: 14px; text-align: center; }

/* ---------------------------------------------------------------- game */
.game { display: flex; justify-content: center; align-items: flex-start; gap: 20px; padding: 24px 16px 32px; }
.board-col { display: flex; flex-direction: column; gap: 14px; width: min(760px, 100%); }
.board {
  background: var(--panel); border-radius: 22px; padding: 3.5% 6% 4.6% 3.5%;
  position: relative; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.board .grid { position: relative; width: 100%; aspect-ratio: 1 / 1; }
.sq {
  position: absolute; background: var(--sq); border: 1px solid var(--sq-border);
  border-radius: var(--sq-radius);
}
.sq.goal-red    { background: #3b2426; border-color: #7a3a3f; }
.sq.goal-blue   { background: #232a38; border-color: #3a4a6a; }
.sq.goal-green  { background: #22332a; border-color: #2f5a44; }
.sq.goal-yellow { background: #3a3323; border-color: #6b5a2a; }
.sq.goal-centre { background: #3a3323; border-color: #8a7a3a; box-shadow: inset 0 0 0 2px #5a4f2a; }
.sq.legal { border: 2px solid #f2f2f2; cursor: pointer; }
.sq.legal:hover { background: #38383b; }
.pawn {
  position: absolute; left: 22%; top: 22%; width: 56%; height: 56%; border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,.45);
}
.pawn.red { background: var(--red); }
.pawn.blue { background: var(--blue); }
.pawn.green { background: var(--green); }
.pawn.yellow { background: var(--yellow); }
.wall { position: absolute; border-radius: 3px; box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.wall.red { background: var(--red); }
.wall.blue { background: var(--blue); }
.wall.green { background: var(--green); }
.wall.yellow { background: var(--yellow); }
.wall.preview { opacity: .8; box-shadow: 0 0 0 2px rgba(255,255,255,.35); pointer-events: none; }
.wall.preview.bad { background: #7f1d1d; opacity: .75; box-shadow: 0 0 0 2px rgba(239,68,68,.5); }
.anchor { position: absolute; cursor: pointer; border-radius: 50%; }
.anchor:hover { background: rgba(255,255,255,.04); }
.coord { position: absolute; color: var(--muted); font-size: clamp(9px, 1.7vw, 13px); }
.coord.file { top: 100%; margin-top: .55em; width: 0; text-align: center; white-space: nowrap; }
.coord.rank { left: 100%; margin-left: 1.4em; height: 0; line-height: 0; white-space: nowrap; }

.modes { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.modes button {
  display: flex; align-items: center; gap: 10px; background: var(--panel); color: var(--text);
  border: 2px solid transparent; border-radius: 12px; padding: 12px 18px; font-weight: 600; font-size: 15px;
}
.modes button.on { border-color: #fff; }
.modes button .bar { width: 34px; height: 8px; border-radius: 4px; background: var(--red); }
.modes button .bar.v { width: 8px; height: 26px; }
.modes button .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--red); }

.panel { width: 292px; flex: 0 0 292px; background: var(--panel); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.panel .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel .top .back { background: none; border: 0; color: var(--text); padding: 6px 4px; font-size: 14px; display: flex; align-items: center; gap: 4px; }
.panel .top .roomcode { color: var(--muted); font-size: 12px; letter-spacing: .1em; }
.panel .resign { width: 100%; }
.pcards { display: flex; flex-direction: column; gap: 8px; }
.pcard {
  background: var(--panel-2); border-radius: 10px; padding: 10px 12px; border-left: 4px solid transparent;
  display: flex; flex-direction: column; gap: 4px;
}
.pcard.active { background: var(--active-card); border-left-color: var(--active-edge); }
.pcard.out { opacity: .5; }
.pcard .name { font-weight: 600; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.pcard .name .you { color: var(--muted); font-weight: 400; font-size: 12px; }
.pcard .walls { display: flex; align-items: center; gap: 6px; color: #cfcfd3; font-size: 14px; }
.pcard .walls .chip { width: 18px; height: 7px; border-radius: 4px; }
.pcard .walls b { font-size: 18px; color: #fff; }
.pcard .walls .of { color: var(--muted); font-size: 12px; }
.chip.red { background: var(--red); } .chip.blue { background: var(--blue); }
.chip.green { background: var(--green); } .chip.yellow { background: var(--yellow); }
.history h3 { font-size: 14px; margin: 4px 0 8px; font-weight: 600; }
.history .list {
  background: #141416; border-radius: 10px; padding: 8px 10px; max-height: 240px; overflow: auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; font-size: 13px; font-variant-numeric: tabular-nums;
}
.history .list .none { grid-column: 1 / -1; color: var(--muted); text-align: center; font-style: italic; padding: 12px 0; }
.history .list .h { display: flex; align-items: center; gap: 6px; }
.history .list .h .n { color: var(--muted); width: 2.2em; text-align: right; }
.history .list .h .dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.red { background: var(--red); } .dot.blue { background: var(--blue); }
.dot.green { background: var(--green); } .dot.yellow { background: var(--yellow); }
.turnline { color: var(--muted); font-size: 13px; text-align: center; min-height: 1.3em; }
.panel .help { color: var(--muted); font-size: 12px; line-height: 1.4; }
.mobile-cards { display: none; }

/* --------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #2a2a2c; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.5); z-index: 50; max-width: min(92vw, 520px); text-align: center;
}
.toast.error { background: #7f1d1d; }

/* ------------------------------------------------------------- phones */
@media (max-width: 900px) {
  .game { flex-direction: column; align-items: stretch; padding: 10px 10px 24px; gap: 12px; }
  .board-col { width: 100%; }
  .panel { width: auto; flex: none; }
  .mobile-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .panel .pcards { display: none; }
  .modes button { padding: 12px 14px; }
  .history .list { max-height: 180px; }
}
@media (max-width: 420px) {
  .modes button { font-size: 14px; padding: 10px 12px; gap: 8px; }
  .mobile-cards .pcard .name { font-size: 14px; }
}
@media (prefers-reduced-motion: no-preference) {
  .pawn { transition: left .12s, top .12s; }
}
