:root {
  --t: #ff8a1e;
  --g: #5dffa0;
  --bg: rgba(12, 8, 22, 0.78);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f1eafc;
  --muted: #a99bc0;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0a0614; color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; user-select: none;
  -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
body.playing { touch-action: none; }
#app canvas { display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
kbd { background: #2a2140; border: 1px solid #4a3d6b; border-radius: 4px; padding: 0 5px; font-size: 12px; }

/* ---------- login ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; overflow-y: auto; scroll-behavior: smooth;
  background: radial-gradient(circle at 50% 30%, rgba(80, 30, 110, 0.55), rgba(5, 2, 12, 0.92)); }
.hero { position: relative; min-height: 100vh; min-height: 100svh; display: grid; place-items: center; padding: 12px 0 40px; }
.scrollcue { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  color: var(--muted); font-size: 13px; text-decoration: none; }
.scrollcue:hover { color: var(--text); }
.card { width: min(440px, calc(100vw - 32px)); background: var(--bg); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; text-align: center; box-shadow: 0 0 60px rgba(255, 120, 20, 0.15); }
.logo { font-size: 46px; }
h1 { margin: 6px 0 2px; font-size: 30px; letter-spacing: 1px; color: var(--t); text-shadow: 0 0 18px rgba(255, 138, 30, 0.6); }
.sub { margin: 0 0 18px; color: var(--muted); }
.row { display: flex; gap: 8px; }
input { flex: 1; font: inherit; font-size: 17px; padding: 11px 14px; border-radius: 10px; border: 1px solid #4a3d6b;
  background: #150e25; color: var(--text); outline: none; }
input:focus { border-color: var(--t); }
button { font: inherit; cursor: pointer; border-radius: 10px; border: 0; }
input.room { width: 100%; margin-top: 8px; font-size: 14px; text-transform: uppercase; }
input.room::placeholder { text-transform: none; }
#roomLine { margin-top: 8px; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
#roomLine b { color: var(--text); letter-spacing: 2px; }
#shareBtn { pointer-events: auto; margin-left: auto; padding: 4px 10px; font-size: 12px; font-weight: bold; color: #1a0a00;
  background: linear-gradient(180deg, #ffa646, #ff7a00); border-radius: 6px; }
#shareBtn:hover { filter: brightness(1.1); }
.ghostbtn { width: 50px; font-size: 22px; background: #2a2140; }
.ghostbtn:hover { background: #3a2d58; }
.primary { margin-top: 12px; width: 100%; padding: 12px; font-size: 18px; font-weight: bold; color: #1a0a00;
  background: linear-gradient(180deg, #ffa646, #ff7a00); }
.primary:hover { filter: brightness(1.1); }
.rules { margin-top: 18px; text-align: left; font-size: 14px; line-height: 1.6; display: grid; gap: 6px; }

/* ---------- guide below the game (scroll down from the login card) ---------- */
.guide-wrap { background: #0a0614; border-top: 1px solid var(--line); user-select: text; -webkit-user-select: text; }
.guide { max-width: 780px; margin: 0 auto; padding: 32px 16px 24px; font-size: 16px; line-height: 1.7; color: #ddd3ee; }
.guide .lead { font-size: 17px; color: var(--text); }
.guide h2 { margin: 40px 0 10px; font-size: 23px; line-height: 1.3; color: var(--t); }
.guide h3 { margin: 22px 0 4px; font-size: 18px; color: var(--text); }
.guide strong, .guide b { color: var(--text); }
.guide ul { padding-left: 22px; }
.guide li { margin: 4px 0; }
.guide table { margin: 14px 0; font-size: 14px; font-variant-numeric: normal; }
.guide th, .guide td { text-align: left !important; width: auto !important; color: inherit; padding: 8px 10px; vertical-align: top;
  border-bottom: 1px solid var(--line); }
.guide th { color: var(--muted); }
.guide td:first-child { color: var(--text); font-weight: 600; }
.guide details { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 8px 0; background: rgba(255, 255, 255, 0.02); }
.guide summary { cursor: pointer; font-weight: 600; color: var(--text); }
.guide details p { margin: 8px 0 2px; }
.guide .again { margin: 36px 0 8px; text-align: center; }
.playbtn { display: inline-block; width: auto; padding: 12px 28px; text-decoration: none; border-radius: 10px; }
.footnav { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; font-size: 13px; }
.footnav a, .guide a:not(.primary) { color: var(--t); }
.disclaimer { max-width: 780px; margin: 0 auto; padding: 16px 16px 32px; font-size: 12px; line-height: 1.6; color: var(--muted);
  border-top: 1px solid var(--line); }
@media (max-width: 560px) {
  .guide { font-size: 15px; }
  .guide h2 { font-size: 20px; }
  .guide table { font-size: 13px; }
  .guide th, .guide td { padding: 6px 6px; }
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#topbar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; align-items: stretch;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.teamscore { display: flex; align-items: center; gap: 8px; padding: 6px 16px; font-size: 26px; font-weight: bold; }
.teamscore.t { color: var(--t); background: rgba(255, 138, 30, 0.12); }
.teamscore.g { color: var(--g); background: rgba(93, 255, 160, 0.10); }
.teamscore .ico { font-size: 22px; }
#topbar .mid { padding: 4px 18px; text-align: center; min-width: 120px; }
#timer { font-size: 24px; font-weight: bold; font-variant-numeric: tabular-nums; }
#phase { font-size: 12px; color: var(--muted); }
#counts { position: absolute; top: 12px; left: 12px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; font-size: 13px; line-height: 1.7; }
#feed { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
#feed div { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; font-size: 13px;
  animation: fadein 0.2s; }
#feed .t { color: var(--t); } #feed .g { color: var(--g); }
@keyframes fadein { from { opacity: 0; transform: translateX(20px); } }
#banner { position: absolute; top: 28%; left: 50%; transform: translateX(-50%); text-align: center; font-size: 40px;
  font-weight: bold; text-shadow: 0 0 20px rgba(0, 0, 0, 0.9); white-space: nowrap; transition: opacity 0.3s; }
#banner small { display: block; font-size: 18px; font-weight: normal; color: var(--muted); }
#me { position: absolute; left: 12px; bottom: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; min-width: 200px; }
#meName { font-size: 18px; font-weight: bold; }
#meTeam { font-size: 13px; margin: 2px 0 4px; }
#meStats { font-size: 13px; color: var(--muted); }
#stamina { margin-top: 6px; height: 6px; background: #2a2140; border-radius: 3px; overflow: hidden; }
#stamina div { height: 100%; width: 100%; background: var(--t); }
#hint { position: absolute; right: 12px; bottom: 12px; font-size: 12px; color: var(--muted); background: var(--bg);
  padding: 6px 10px; border-radius: 8px; }
#spectate { position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%); background: var(--bg);
  border: 1px solid var(--line); padding: 6px 14px; border-radius: 8px; font-size: 14px; }

/* name tags */
.tag { text-align: center; line-height: 1.15; text-shadow: 0 1px 3px #000, 0 0 6px #000; pointer-events: none; }
.tag .n { font-size: 13px; font-weight: bold; white-space: nowrap; }
.tag .w { font-size: 11px; color: #ffe08a; }
.tag.me .n::before { content: "▶ "; }

/* ---------- scoreboard ---------- */
#board { position: fixed; z-index: 10; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(860px, calc(100vw - 32px));
  max-height: calc(100vh - 40px); overflow: auto; background: rgba(10, 6, 20, 0.9); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; box-shadow: 0 10px 50px rgba(0, 0, 0, 0.6); }
.boardhead { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.side { margin-bottom: 12px; }
.sidehead { display: flex; align-items: baseline; gap: 12px; padding: 6px 10px; border-radius: 8px 8px 0 0; }
.side.t .sidehead { background: rgba(255, 138, 30, 0.18); color: var(--t); }
.side.g .sidehead { background: rgba(93, 255, 160, 0.13); color: var(--g); }
.sidehead .big { font-size: 28px; font-weight: bold; }
.sidehead .lbl { font-size: 18px; font-weight: bold; }
.sidehead .info { margin-left: auto; font-size: 13px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th { text-align: right; font-weight: normal; color: var(--muted); font-size: 12px; padding: 4px 8px; border-bottom: 1px solid var(--line); }
td { text-align: right; padding: 4px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
th:nth-child(1), td:nth-child(1) { width: 34px; text-align: center; color: var(--muted); }
th:nth-child(2), td:nth-child(2) { text-align: left; }
tr.self td { background: rgba(255, 255, 255, 0.08); }
tr.caught td { opacity: 0.45; }
.st { font-size: 12px; margin-left: 6px; }

/* ---------- abilities (both desktop and touch) ---------- */
#actions { position: absolute; right: 12px; bottom: 52px; display: flex; gap: 10px; align-items: flex-end; }
.act { pointer-events: auto; position: relative; overflow: hidden; display: grid; place-items: center; align-content: center; gap: 2px;
  width: 74px; height: 56px; border-radius: 12px; color: var(--text); background: var(--bg); border: 2px solid var(--line);
  font-size: 12px; letter-spacing: 1px; touch-action: none; --cd: 0; }
.act b { position: relative; z-index: 1; }
.act kbd { position: relative; z-index: 1; font-size: 10px; }
.act.dash { border-color: rgba(255, 166, 70, 0.7); }
.act.atk { border-color: rgba(93, 255, 160, 0.8); color: var(--g); }
.act::after { content: ""; position: absolute; inset: 0; border-radius: inherit;   /* cooldown sweep */
  background: conic-gradient(rgba(0, 0, 0, 0.62) calc(var(--cd) * 360deg), transparent 0); }
.act.ready { box-shadow: 0 0 14px rgba(255, 166, 70, 0.35); }
.act.atk.ready { box-shadow: 0 0 16px rgba(93, 255, 160, 0.45); }
.act.pressed { transform: scale(0.92); }

/* ---------- touch / phone landscape ---------- */
#stickBase, #boardBtn { display: none; }
#rotate { display: none; }
body.touch #hint { display: none; }
body.touch #boardBtn { display: block; pointer-events: auto; position: absolute; top: 8px; right: 8px; width: 40px; height: 40px;
  border-radius: 10px; font-size: 20px; background: var(--bg); border: 1px solid var(--line); color: var(--text); }
body.touch #feed { top: 54px; right: 8px; }
body.touch #feed div { font-size: 11px; padding: 3px 8px; }
body.touch #counts { top: 8px; left: 8px; font-size: 11px; padding: 5px 9px; line-height: 1.5; }
body.touch #me { top: 60px; bottom: auto; left: 8px; min-width: 0; padding: 6px 10px; }
body.touch #meName { font-size: 14px; }
body.touch #meTeam, body.touch #meStats, body.touch #roomLine { font-size: 11px; }
body.touch #topbar { top: 6px; transform: translateX(-50%) scale(0.82); transform-origin: top center; }
body.touch #banner { font-size: 26px; top: 22%; }
body.touch #banner small { font-size: 14px; }
body.touch #spectate { bottom: 12px; font-size: 12px; }
body.touch #actions { right: calc(18px + env(safe-area-inset-right)); bottom: 18px; gap: 14px; }
body.touch .act { width: 76px; height: 76px; border-radius: 50%; font-size: 13px; }
body.touch .act.atk { width: 96px; height: 96px; font-size: 14px; }
body.touch .act kbd { display: none; }
body.touch .tag .n { font-size: 11px; }
body.touch .tag .w { font-size: 9px; }
body.touch #stickBase { display: block; position: absolute; width: 130px; height: 130px; margin: -65px 0 0 -65px; border-radius: 50%;
  left: calc(110px + env(safe-area-inset-left)); top: calc(100% - 110px); background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.18); opacity: 0.55; transition: opacity 0.15s; }
body.touch #stickBase.active { opacity: 1; transition: none; }
#stickKnob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  background: rgba(255, 166, 70, 0.55); border: 2px solid rgba(255, 220, 180, 0.7); }
body.touch #board { width: calc(100vw - 16px); max-height: calc(100vh - 16px); padding: 8px 10px; font-size: 12px; }
body.touch #board table { font-size: 12px; }
body.touch #board .sidehead .big { font-size: 20px; }
body.touch #board th, body.touch #board td { padding: 3px 5px; }
@media (orientation: portrait) {
  body.touch.playing #rotate { display: grid; position: fixed; inset: 0; z-index: 50; place-content: center; text-align: center; gap: 12px;
    background: #0b0718; color: var(--text); font-size: 18px; }
  body.touch.playing #rotate div { font-size: 54px; }
}
@media (max-height: 520px) {
  .card { padding: 14px 18px; }
  .logo { display: none; }
  h1 { font-size: 22px; }
  .sub { margin-bottom: 10px; }
  .rules { margin-top: 10px; font-size: 12px; line-height: 1.45; }
  .hero { padding-bottom: 32px; }
  .scrollcue { bottom: 6px; font-size: 12px; }
}
