/* ──────────────────────────────────────────────────────────────────────
   A tournament hall, not a phone screen.
   The board is the hero and fills real space; everything around it is
   quiet — a clock, a scoresheet, a pairing list. Layout is built for a
   wide screen first and folds down to one column, rather than a mobile
   column stretched across a monitor, which is what this replaced.
   ────────────────────────────────────────────────────────────────────── */
:root {
  /* Felt, lifted for a bright monitor. The Android palette bottoms out at
     1% luminance, which on a large screen reads as flat black rather than
     green — so the web values sit two steps up while staying the same hue. */
  --felt-void:    #0B1512;
  --felt:         #16241F;
  --felt-raised:  #1E3029;
  --felt-high:    #274036;
  --line:         #2F4B41;
  --line-bright:  #416A5C;

  --buff:      #F1EAD6;
  --buff-2:    #CFC5AB;
  --buff-3:    #948D78;

  --brass:       #C8922F;
  --brass-light: #EBCB86;
  --brass-dark:  #7E5A15;
  --on-brass:    #17110４;

  --danger: #B24A4C;
  --good:   #6E9C7C;

  --sq-light: #E2D6BC;
  --sq-dark:  #56402F;

  --r-lg: 10px;
  --r-sm: 5px;

  /* Notation is monospaced on a real scoresheet; keep it that way. */
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --sans: 'Archivo', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--felt-void); }
body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 700px at 22% -10%, #223A31 0%, transparent 60%),
    var(--felt-void);
  color: var(--buff);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

h1, h2, h3 { font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
h1 { font-size: clamp(28px, 3vw, 40px); }
h2 { font-size: 21px; }
h3 { font-size: 16px; font-weight: 600; letter-spacing: 0; }
.lead { font-size: 17px; color: var(--buff-2); max-width: 46ch; }
.dim  { color: var(--buff-3); font-size: 13px; }

a { color: var(--brass-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── top bar: a real site header, present on every screen ─────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 28px;
  height: 60px; padding: 0 24px;
  background: rgba(11,21,18,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 800; font-size: 18px; letter-spacing: -0.03em;
  color: var(--buff); cursor: pointer;
}
.brand svg { width: 24px; height: 24px; }
.nav { display: flex; gap: 4px; margin-left: 6px; }
.nav button {
  border: 0; background: none; cursor: pointer; font: inherit;
  color: var(--buff-3); padding: 7px 13px; border-radius: var(--r-sm);
  font-size: 14px;
}
.nav button:hover { color: var(--buff); background: rgba(255,255,255,.04); }
.nav button.on { color: var(--brass-light); background: rgba(200,146,47,.12); }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

/* ── page shell ───────────────────────────────────────────────────── */
.page { max-width: 1180px; margin: 0 auto; padding: 26px 24px 64px; }

/* Board beside a panel. The board gets the room; the panel is a column
   of controls, not a stack of equal cards. */
.split {
  display: grid; gap: 36px;
  grid-template-columns: minmax(0, 1fr) 350px;
  align-items: start;
}
/* Below this the 350px side column has no room left, so stack instead.
   The gap between the old breakpoints (700 and 1000) left tablet widths
   with a two-column grid narrower than its own columns, which forced a
   horizontal scroll on every page. */
@media (max-width: 1040px) {
  .split { grid-template-columns: 1fr; }
  .board-stage { max-width: 560px; margin: 0 auto; }
}

.board-stage { position: relative; }
.board-stage { max-width: 620px; }
.board-stage .row { width: calc(100% - 20px); }
.board-stage canvas { width: 100%; display: block; aspect-ratio: 1 / 0.9; }

/* ── the clock: a brass window, the one loud object ───────────────── */
.clock {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 30px; font-weight: 600; letter-spacing: -0.02em;
  padding: 7px 16px; border-radius: var(--r-sm);
  background: #0E1A16; border: 1px solid var(--line); color: var(--buff-2);
}
.clock.live { background: linear-gradient(180deg,#8E6518,#6B4711); border-color: var(--brass); color: #FFF3DA; }
.clock.low  { background: #6E2426; border-color: var(--danger); color: #FFE3E3; }

/* ── the scoresheet: notation in two columns, as it is written ────── */
.sheet { border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.sheet-head {
  display: grid; grid-template-columns: 42px 1fr 1fr;
  padding: 8px 12px; font-size: 11.5px; color: var(--buff-3);
  border-bottom: 1px solid var(--line); background: #12201B;
}
.sheet-body { max-height: 300px; overflow: auto; }
.sheet-row {
  display: grid; grid-template-columns: 42px 1fr 1fr;
  font-family: var(--mono); font-size: 13.5px;
  border-bottom: 1px solid rgba(47,75,65,.45);
}
.sheet-row:last-child { border-bottom: 0; }
.sheet-row > * { padding: 5px 12px; }
.sheet-row .no { color: var(--buff-3); }
.sheet-row .mv { cursor: pointer; color: var(--buff-2); }
.sheet-row .mv:hover { background: rgba(255,255,255,.04); color: var(--buff); }
.sheet-row .mv.on { background: rgba(200,146,47,.18); color: var(--brass-light); }

/* ── pairing list: how a tournament posts its rounds ──────────────── */
.pairings { border-top: 1px solid var(--line); }
.pairing {
  display: grid; grid-template-columns: 34px 1fr auto;
  align-items: center; gap: 14px;
  padding: 13px 4px; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.pairing:hover { background: rgba(255,255,255,.025); }
.pairing .seat { font-family: var(--mono); color: var(--buff-3); font-size: 13px; }
.pairing .who { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.pairing .who b { font-weight: 600; }
.pairing .rating { font-family: var(--mono); font-size: 12.5px; color: var(--buff-3); }
.pairing .vs { color: var(--buff-3); }

/* ── time-control chooser: eight squares of a board ───────────────── */
.times { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.time {
  cursor: pointer; border: 0; font: inherit; text-align: left;
  padding: 15px 16px; background: #12201B; color: var(--buff);
}
.time:nth-child(2), .time:nth-child(3) { background: #16241F; }
.time:hover { background: var(--felt-raised); }
.time.on { background: linear-gradient(180deg, rgba(200,146,47,.22), rgba(200,146,47,.10)); box-shadow: inset 0 0 0 1px var(--brass-dark); }
.time .t { font-family: var(--mono); font-size: 19px; font-weight: 600; }
.time .n { font-size: 12px; color: var(--buff-3); }
.time.on .n { color: var(--brass-light); }

/* ── buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; cursor: pointer; font: inherit; font-weight: 600;
  padding: 13px 20px; border-radius: var(--r-sm); width: 100%;
  background: linear-gradient(180deg, var(--brass-light), var(--brass) 58%, #A2721F);
  color: #1A1206; font-size: 15.5px;
  box-shadow: 0 2px 0 var(--brass-dark);
}
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.btn:disabled { background: var(--felt-raised); color: var(--buff-3); box-shadow: none; cursor: default; }
.btn.quiet {
  background: transparent; border: 1px solid var(--line);
  color: var(--buff); box-shadow: none; font-weight: 500;
}
.btn.quiet:hover { border-color: var(--line-bright); background: rgba(255,255,255,.03); }
.btn.slim { padding: 9px 14px; font-size: 14px; width: auto; }

.tool {
  cursor: pointer; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: rgba(14,26,22,.9); color: var(--buff-2);
  width: 38px; height: 38px; font-size: 15px; line-height: 1;
  display: grid; place-items: center;
}
.tool:hover { background: var(--felt-raised); color: var(--buff); }

/* ── panels and rows ──────────────────────────────────────────────── */
.panel { background: var(--felt); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel > .hd { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.panel > .bd { padding: 16px; }

.rows { display: flex; flex-direction: column; }
.rowitem {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  cursor: pointer; background: none; border-left: 0; border-right: 0; border-top: 0;
  font: inherit; color: inherit; text-align: left; width: 100%;
}
.rowitem:last-child { border-bottom: 0; }
.rowitem:hover { background: rgba(255,255,255,.03); }
.rowitem .ic { width: 34px; height: 34px; border-radius: var(--r-sm); background: var(--felt-raised); display: grid; place-items: center; font-size: 17px; flex: none; }
.rowitem .tx { flex: 1; min-width: 0; }
.rowitem .tx b { display: block; font-weight: 600; font-size: 14.5px; }

.tag {
  font-size: 11.5px; padding: 3px 9px; border-radius: 99px;
  border: 1px solid var(--line-bright); color: var(--buff-3); white-space: nowrap;
}
.tag.brass { border-color: var(--brass-dark); color: var(--brass-light); background: rgba(200,146,47,.1); }
.tag.good  { border-color: var(--good); color: #A5CCB0; background: rgba(110,156,124,.12); }
.tag.bad   { border-color: var(--danger); color: #E39294; background: rgba(178,74,76,.12); }

input, textarea {
  width: 100%; padding: 12px 13px; border-radius: var(--r-sm);
  background: #0E1A16; border: 1px solid var(--line);
  color: var(--buff); font: inherit; font-size: 14.5px;
}
input:focus, textarea:focus { outline: none; border-color: var(--brass); }
input::placeholder { color: var(--buff-3); }

.stack > * + * { margin-top: 10px; }
.center { display: grid; place-items: center; }
.spread { justify-content: space-between; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }

/* ── the hero: the board is the page ─────────────────────────────── */
.hero { display: grid; grid-template-columns: minmax(0,1.25fr) minmax(0,.9fr); gap: 40px; align-items: center; min-height: calc(100vh - 60px); padding: 0 24px; max-width: 1360px; margin: 0 auto; }
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; min-height: auto; padding: 32px 20px 48px; gap: 24px; } }
.hero canvas { width: 100%; display: block; aspect-ratio: 1/.88; }

/* ── chat ─────────────────────────────────────────────────────────── */
.chat { display: flex; flex-direction: column; height: 230px; }
.chatlog { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 82%; padding: 7px 12px; border-radius: 13px; font-size: 13.5px; }
.bubble.me { align-self: flex-end; background: #6B4711; color: #FFF3DA; }
.bubble.them { align-self: flex-start; background: var(--felt-raised); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--felt-high); border: 1px solid var(--line-bright);
  padding: 12px 18px; border-radius: var(--r-sm); font-size: 14px;
  z-index: 100; max-width: 90vw; box-shadow: 0 10px 30px rgba(0,0,0,.55);
}

.spin { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--brass); border-radius: 50%; animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* Grid of cards only where the content really is a set of like things —
   the store, where each item is a picture with a price. */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.item { border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; cursor: pointer; background: var(--felt); }
.item:hover { border-color: var(--line-bright); }
.item.owned { border-color: var(--brass-dark); }
.item .pic { height: 118px; display: grid; place-items: center; background: radial-gradient(circle at 50% 35%, var(--felt-high), var(--felt-void)); }
.item .meta { padding: 11px 13px; }


/* ── narrow screens ───────────────────────────────────────────────────
   One column, and the fixed grid columns that make the scoresheet and
   pairing list line up on a wide screen have to give way — otherwise
   they force a horizontal scroll on a phone. */
@media (max-width: 860px) {
  .topbar { gap: 12px; padding: 0 14px; height: 54px; overflow-x: auto; }
  .topbar::-webkit-scrollbar { display: none; }
  .nav { gap: 0; }
  .nav button { padding: 6px 9px; font-size: 13px; }
  .topbar .right .tag { display: none; }
  .brand span { display: none; }

  .page { padding: 16px 14px 48px; }
  .board-stage { max-width: none; }

  .sheet-head, .sheet-row { grid-template-columns: 32px 1fr 1fr; }
  .sheet-row > * { padding: 5px 9px; }

  .pairing { grid-template-columns: 24px 1fr; gap: 8px; row-gap: 4px; }
  .pairing .tag { grid-column: 2; justify-self: start; }

  .clock { font-size: 24px; padding: 5px 11px; }
  h1 { font-size: 26px; }
  .lead { font-size: 15.5px; }
}
