/* Curling Arena v2 — clean, touch-first, installable. */
:root {
  --bg: #0b1220; --panel: #141d30; --panel2: #1b2740;
  --line: #26324d; --ink: #e9eef7; --muted: #93a1b8; --accent: #4ba3dc;
  --red: #dc2626; --yellow: #eab308; --good: #34d399; --bad: #f87171;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; border: 0; cursor: pointer; }
.hidden { display: none !important; }

header {
  position: sticky; top: 0; z-index: 20; background: rgba(11,18,32,.92);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  display: flex; align-items: center; gap: 10px;
}
header .title { font-weight: 700; letter-spacing: .2px; }
header .spacer { flex: 1; }
.scorechip {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.scorechip .red { color: #ff7b7b; } .scorechip .yel { color: #ffd34d; }
.iconbtn {
  background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 12px; min-width: 44px; min-height: 40px; font-size: 18px;
}
.iconbtn.active { border-color: var(--accent); color: var(--accent); }

.view { max-width: 600px; margin: 0 auto; padding: 14px; }

/* ---- home ---- */
.hero {
  background: linear-gradient(160deg, var(--panel2), var(--panel));
  border: 1px solid var(--line); border-radius: 20px; padding: 22px; text-align: center;
}
.hero h1 { margin: 0 0 6px; font-size: 24px; }
.hero p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.bigbtn {
  display: inline-block; background: var(--accent); color: #08121f;
  font-weight: 700; font-size: 17px; border-radius: 14px; padding: 14px 26px;
  min-height: 48px;
}
.bigbtn:disabled { opacity: .5; }
.endsrow { margin-top: 12px; color: var(--muted); font-size: 14px; }
.endsrow .chip { margin-left: 6px; }
.chip {
  display: inline-block; background: var(--panel2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px;
  min-height: 38px; font-size: 14px;
}
.chip.sel { border-color: var(--accent); color: var(--accent); font-weight: 700; }
h2.section { font-size: 14px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .8px; margin: 22px 4px 8px; }
.matchrow {
  width: 100%; text-align: left; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  margin-bottom: 8px; display: flex; align-items: center; gap: 10px;
}
.matchrow .who { flex: 1; min-width: 0; }
.matchrow .who .names { font-weight: 600; font-size: 15px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.matchrow .who .sub { color: var(--muted); font-size: 12.5px; }
.matchrow .score { font-weight: 700; font-variant-numeric: tabular-nums; }
.matchrow .tag { font-size: 12px; color: var(--accent); }

/* ---- game ---- */
.statusbar { display: flex; align-items: center; gap: 8px; margin: 2px 2px 10px;
  color: var(--muted); font-size: 14px; flex-wrap: wrap; }
.statusbar b { color: var(--ink); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.red { background: var(--red); } .dot.yel { background: var(--yellow); }
.boardwrap { position: relative; }
canvas.board {
  width: 100%; display: block; border-radius: 18px; touch-action: none;
  border: 1px solid var(--line); background: #eef4fa;
}
.overlaymsg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(11,18,32,.45); border-radius: 18px; color: #fff; font-weight: 600;
  backdrop-filter: blur(1.5px); text-align: center; padding: 20px;
}
.heatlegend { display: flex; align-items: center; gap: 8px; margin-top: 6px;
  color: var(--muted); font-size: 12.5px; }
.heatlegend .bar { flex: 1; height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, rgba(23,111,208,.85), rgba(150,150,148,.25), rgba(198,44,34,.85)); }
.shotbar { margin-top: 12px; }
.moderow { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.actionrow { display: flex; gap: 10px; align-items: center; }
.throwbtn {
  flex: 1; background: var(--accent); color: #08121f; font-weight: 800;
  font-size: 18px; border-radius: 14px; min-height: 54px;
}
.throwbtn:disabled { opacity: .35; }
.subbtn { background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 12px; min-height: 48px; padding: 0 16px; font-size: 14px; }
.hint { color: var(--muted); font-size: 13.5px; margin-top: 8px; min-height: 20px; }
.coachpanel { margin-top: 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px; }
.coachpanel h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px; }
.evaltrace { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.evalpill { font-size: 12.5px; border-radius: 8px; padding: 3px 8px;
  background: var(--panel2); border: 1px solid var(--line);
  font-variant-numeric: tabular-nums; }
.evalpill.up { color: var(--good); } .evalpill.down { color: var(--bad); }

/* ---- replay ---- */
.replaybar { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.replaybar input[type=range] { flex: 1; accent-color: var(--accent); height: 34px; }
.steplabel { text-align: center; color: var(--muted); font-size: 14px; margin-top: 6px; }

/* ---- modal & toast ---- */
.modal { position: fixed; inset: 0; background: rgba(5,9,18,.65); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal .card { background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 20px; max-width: 380px; width: 100%; }
.modal h3 { margin: 0 0 6px; }
.modal p { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.modal .row { display: flex; gap: 10px; }
.modal .row > button { flex: 1; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 60;
  background: var(--panel2); border: 1px solid var(--line); color: var(--ink);
  padding: 10px 18px; border-radius: 12px; font-size: 14.5px; max-width: 90vw;
  box-shadow: 0 6px 24px rgba(0,0,0,.4); transition: opacity .3s;
}
.backrow { margin-bottom: 10px; }
.linky { background: none; color: var(--accent); padding: 6px 4px; font-size: 14px; }

/* v2.1: multiplayer + replay heat */
.modegrid { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.modegrid .bigbtn { width: 100%; }
.joinrow { display: flex; gap: 8px; margin-top: 14px; }
.joinrow input { flex: 1; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--ink); font-size: 14px; min-height: 44px; }
.subbtn.active { border-color: var(--accent); color: var(--accent); }
