:root {
  --ink: #0b0614;
  --paper: #ffe34a;
  --foam: #f7fbff;
  --green: #06d6a0;
  --blue: #5cc8ff;
  --red: #ff6b6b;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1d3a22;
  font-family: Nunito, "Trebuchet MS", system-ui, sans-serif;
  color: var(--foam);
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}
[hidden] { display: none !important; }
#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(14, 30, 18, 0.55), rgba(14, 30, 18, 0.82));
  touch-action: pan-y;
}
#end { background: rgba(10, 22, 14, 0.72); }
.card {
  width: min(100%, 420px);
  margin: auto;
  padding: 18px 16px 16px;
  background: #fff8cf;
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 24px;
  box-shadow: 6px 6px 0 var(--ink);
  user-select: text;
  -webkit-user-select: text;
}
h1, h2 {
  margin: 0;
  font-family: Bangers, Impact, "Arial Black", sans-serif;
  font-weight: 400;
  letter-spacing: 0.03em;
  text-align: center;
  line-height: 0.95;
}
h1 { font-size: clamp(2.6rem, 13vw, 3.6rem); color: #2f9e44; text-shadow: 3px 3px 0 var(--ink); -webkit-text-stroke: 1px var(--ink); }
h1 span { color: #f08c00; }
h2 { font-size: 2.6rem; color: #2f9e44; text-shadow: 2px 2px 0 var(--ink); }
.sub { margin: 8px 0 14px; text-align: center; font-weight: 800; font-size: 0.95rem; }
.lbl { margin: 12px 0 5px; font-weight: 900; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; }
.lbl.center { text-align: center; margin-bottom: 0; }
.row { display: flex; gap: 8px; align-items: stretch; margin-bottom: 4px; }
input {
  flex: 1; min-width: 0; min-height: 52px;
  padding: 0 14px;
  border: 3px solid var(--ink); border-radius: 14px;
  background: #fff; color: var(--ink);
  font: 900 1.15rem Nunito, system-ui, sans-serif;
  user-select: text; -webkit-user-select: text;
}
input.code { text-align: center; letter-spacing: 0.3em; text-transform: uppercase; font-size: 1.4rem; }
.btn {
  min-height: 52px; padding: 0 18px;
  border: 3px solid var(--ink); border-radius: 16px;
  background: var(--paper); color: var(--ink);
  font: 900 1.05rem Nunito, system-ui, sans-serif;
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
}
.btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.btn.big { width: 100%; min-height: 60px; font-size: 1.25rem; margin-top: 12px; }
.row .btn.big { width: auto; margin-top: 0; min-width: 110px; }
.btn.small { min-width: 56px; padding: 0 10px; }
.btn.go { background: var(--green); }
.btn.blue { background: var(--blue); }
.btn.ghost { background: #fff; box-shadow: 3px 3px 0 var(--ink); }
.btn:disabled { opacity: 0.5; }
#leaveBtn, #endLeave { width: 100%; margin-top: 12px; }
.or { margin: 16px 0 8px; text-align: center; font-weight: 900; font-size: 0.85rem; opacity: 0.7; }
.msg { margin: 10px 0 0; text-align: center; font-weight: 800; font-size: 0.92rem; min-height: 1.2em; color: #c92a2a; }
#lobbyMsg, #endMsg { color: #364fc7; }
.how { margin-top: 14px; font-weight: 700; font-size: 0.9rem; }
.how summary { cursor: pointer; font-weight: 900; padding: 8px 0; }
.how p { margin: 6px 0; line-height: 1.35; }

.roomcode {
  margin: 4px auto 6px; text-align: center;
  font: 400 4rem Bangers, Impact, sans-serif; letter-spacing: 0.16em;
  color: #2f9e44; text-shadow: 3px 3px 0 var(--ink); -webkit-text-stroke: 1px var(--ink);
}
.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.plist li {
  display: flex; align-items: center; gap: 10px;
  min-height: 46px; padding: 6px 12px;
  background: #fff; border: 3px solid var(--ink); border-radius: 14px;
  font-weight: 900;
}
.plist .dot { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--ink); }
.plist .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist .tag { font-size: 0.8rem; opacity: 0.75; }
.plist li.win { background: #d3f9d8; }
.plist li.lose { background: #ffe3e3; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-b {
  min-height: 44px; min-width: 58px; padding: 0 12px;
  border: 3px solid var(--ink); border-radius: 12px;
  background: #fff; color: var(--ink);
  font: 900 0.95rem Nunito, system-ui, sans-serif;
}
.chip-b.on { background: var(--paper); box-shadow: 3px 3px 0 var(--ink); }
.chip-b:disabled { opacity: 1; }
.chips.ro .chip-b:not(.on) { opacity: 0.45; }

/* ---------- in-game HUD ---------- */
#game { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud {
  position: absolute; left: 0; right: 0;
  top: calc(8px + env(safe-area-inset-top));
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  padding: 0 10px;
}
.chip {
  min-height: 38px; padding: 0 12px;
  display: flex; align-items: center;
  background: rgba(11, 6, 20, 0.72); border: 2px solid rgba(255, 255, 255, 0.85); border-radius: 999px;
  font-weight: 900; font-size: 0.95rem; white-space: nowrap;
}
.chip.timer { font-size: 1.1rem; font-variant-numeric: tabular-nums; background: rgba(255, 227, 74, 0.95); color: var(--ink); border-color: var(--ink); }
.chip.timer.hurry { background: var(--red); color: #fff; }
#mm {
  position: absolute; right: 10px;
  top: calc(54px + env(safe-area-inset-top));
  width: 96px; height: 96px;
  border: 3px solid var(--ink); border-radius: 14px;
  background: #2b5d33; opacity: 0.92;
}
.hint {
  position: absolute; left: 10px;
  top: calc(54px + env(safe-area-inset-top));
  max-width: calc(100% - 128px);
  padding: 6px 12px; border-radius: 12px;
  background: rgba(11, 6, 20, 0.7);
  font-weight: 800; font-size: 0.85rem; text-align: left;
}
.hint:empty { display: none; }
.banner {
  position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%);
  width: min(92%, 380px);
  padding: 14px 16px; text-align: center;
  background: var(--paper); color: var(--ink);
  border: 3px solid var(--ink); border-radius: 20px; box-shadow: 5px 5px 0 var(--ink);
  font: 400 1.9rem/1.05 Bangers, Impact, sans-serif; letter-spacing: 0.03em;
}
.banner small { display: block; margin-top: 6px; font: 800 0.9rem/1.25 Nunito, sans-serif; letter-spacing: 0; }
#toasts {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(160px + env(safe-area-inset-top));
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: min(92%, 360px);
  pointer-events: none;
}
.toast {
  padding: 7px 14px; border-radius: 12px;
  background: rgba(11, 6, 20, 0.78); font-weight: 800; font-size: 0.9rem; text-align: center;
}

/* controls */
#stickZone { position: absolute; left: 0; bottom: 0; width: 60%; height: 62%; pointer-events: auto; touch-action: none; }
#stick {
  position: fixed; width: 120px; height: 120px; margin: -60px 0 0 -60px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.18); border: 3px solid rgba(255, 255, 255, 0.55);
  pointer-events: none;
}
#knob {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.85); border: 3px solid var(--ink);
}
#btns {
  position: absolute; right: 14px; bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: flex-end; gap: 14px;
}
.gbtn {
  position: relative;
  border: 4px solid var(--ink); border-radius: 50%;
  color: var(--ink); font: 400 1.5rem Bangers, Impact, sans-serif; letter-spacing: 0.04em;
  box-shadow: 4px 4px 0 var(--ink);
  pointer-events: auto; touch-action: none;
}
.gbtn.act { width: 104px; height: 104px; background: var(--green); font-size: 1.8rem; }
.gbtn.sprint { width: 78px; height: 78px; background: var(--paper); margin-right: 13px; }
.gbtn.act.off { background: #adb5bd; opacity: 0.8; }
.gbtn.act.seek { background: #ffa94d; }
.gbtn.act.danger { background: var(--red); }
.gbtn:active, .gbtn.down { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.gbtn.sprint.tired { background: #adb5bd; }
#stam {
  position: absolute; left: 12px; right: 12px; bottom: 9px; height: 7px;
  background: rgba(0, 0, 0, 0.25); border-radius: 4px; overflow: hidden;
}
#stam b { display: block; height: 100%; width: 100%; background: #2f9e44; }
