/* ===================================================================
 * PASS THE MONKEY - styles
 * =================================================================== */
:root {
  --bg: #0a0c11;
  --panel: #161a22;
  --panel-2: #1e2430;
  --line: #2a3140;
  --text: #e8eaf0;
  --muted: #9aa0b5;
  --accent: #00d4ff;
  --green: #2ec27e;
  --yellow: #f5c211;
  --red: #e01b24;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: radial-gradient(1200px 800px at 50% -10%, #141a26 0%, var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
#app { height: 100%; }
.screen { position: absolute; inset: 0; display: flex; }
.hidden { display: none !important; }
kbd {
  background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 6px; font-family: var(--mono); font-size: 12px;
}

/* ---------------- LOBBY ---------------- */
#lobby { align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.lobby-card {
  width: min(680px, 96vw); background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 26px 28px; box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.title { margin: 0 0 6px; font-size: clamp(26px, 5vw, 40px); letter-spacing: 1px; }
.tagline { margin: 0 0 20px; color: var(--muted); line-height: 1.5; }
.setting { margin: 18px 0; }
.setting label { display: block; margin-bottom: 8px; font-weight: 600; }
.setting input[type=range] { width: 100%; accent-color: var(--accent); }

.radio-row { display: flex; gap: 10px; flex-wrap: wrap; }
.radio {
  display: flex; align-items: center; gap: 7px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; cursor: pointer; font-size: 14px; flex: 1; min-width: 170px;
}
.radio:hover { border-color: #3c4760; }
.radio small { color: var(--muted); }
.radio input { accent-color: var(--accent); }
.radio input:disabled { opacity: .4; }
.select, .text-in {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font: inherit; margin-top: 6px;
}
.loc-row { display: flex; gap: 8px; margin-top: 8px; }
.loc-row .text-in { margin-top: 0; flex: 1; }
.loc-row .ghost-btn { white-space: nowrap; }
#loc-opts { border-left: 2px solid var(--line); padding-left: 12px; margin: 4px 0; }
#room-code { text-transform: uppercase; letter-spacing: 3px; font-weight: 700; text-align: center; }
.room-code { color: var(--accent); letter-spacing: 4px; font-family: var(--mono); }
.waiting-list { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.wait-row {
  display: flex; align-items: center; gap: 10px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-weight: 600;
}
.wait-row .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.wait-row .tag { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px; margin-left: 4px; }
.wait-row .tag.you { background: rgba(0,212,255,.18); color: var(--accent); }
.wait-row .tag.host { background: rgba(245,194,17,.18); color: var(--yellow); }
.wait-row .tag.bot { background: rgba(154,160,181,.18); color: var(--muted); }
#host-start-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---- cold-start lobby board ---- */
.board-head { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 0 8px; }
.board-head h3 { margin: 0; }
.loc-status { font-size: 12px; color: var(--muted); }
.rooms-board { display: flex; flex-direction: column; gap: 8px; }
.board-empty { color: var(--muted); font-size: 14px; padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: 12px; }
.room-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px;
  transition: .15s;
}
.room-card.soon { border-color: var(--red); box-shadow: 0 0 0 1px rgba(224,27,36,.35) inset; }
.rc-name { font-weight: 700; font-size: 15px; }
.rc-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.rc-meta b { color: var(--accent); }
.rc-right { display: flex; align-items: center; gap: 12px; }
.rc-timer { font-family: var(--mono); font-size: 13px; color: var(--muted); white-space: nowrap; }
.rc-timer.soon { color: var(--red); font-weight: 700; }
.rc-join {
  background: linear-gradient(180deg, #36e0ff, var(--accent)); color: #04121a; border: 0;
  border-radius: 9px; padding: 9px 16px; font-weight: 800; cursor: pointer; letter-spacing: .5px;
}
.rc-join:hover { filter: brightness(1.08); }
.or-sep { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 0 10px; }
.ghost-btn.wide { width: 100%; }

.loadout-head { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 0 10px; }
.loadout-head h3 { margin: 0; }
.loadout-head small { color: var(--muted); font-weight: 400; }
.loadout-count { color: var(--accent); font-size: 13px; font-family: var(--mono); }
.loadout-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.pu-card {
  text-align: left; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 12px; cursor: pointer; transition: .15s; font: inherit;
}
.pu-card:hover { border-color: #3c4760; transform: translateY(-1px); }
.pu-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: #16222b; }
.pu-icon { font-size: 22px; }
.pu-name { font-weight: 700; margin: 4px 0 2px; }
.pu-desc { font-size: 11.5px; color: var(--muted); line-height: 1.35; min-height: 30px; }
.pu-cost { font-size: 12px; color: var(--yellow); margin-top: 6px; font-family: var(--mono); }

.primary-btn {
  width: 100%; margin-top: 22px; padding: 15px; font-size: 17px; font-weight: 800; letter-spacing: 1px;
  color: #04121a; background: linear-gradient(180deg, #36e0ff, var(--accent)); border: 0; border-radius: 12px;
  cursor: pointer; transition: .15s;
}
.primary-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }

.serve-note {
  margin: 14px 0 0; font-size: 12.5px; line-height: 1.45; color: #f5d77a;
  background: rgba(245,194,17,.08); border: 1px solid rgba(245,194,17,.3);
  border-radius: 8px; padding: 9px 11px;
}
.howto { margin-top: 18px; color: var(--muted); font-size: 14px; }
.howto summary { cursor: pointer; color: var(--text); font-weight: 600; }
.howto ul { margin: 10px 0 0; padding-left: 18px; line-height: 1.7; }

/* ---------------- GAME ---------------- */
#game { flex-direction: column; padding: 10px; gap: 8px; }
.topbar {
  display: flex; gap: 8px; align-items: center; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; flex-wrap: wrap;
}
.stat { display: flex; flex-direction: column; line-height: 1.1; min-width: 58px; }
.stat-k { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-v { font-size: 16px; font-weight: 700; font-family: var(--mono); }
.danger-text { color: var(--red) !important; }
.mode-chip {
  margin-left: auto; font-size: 11px; color: var(--muted); background: var(--panel-2);
  border: 1px solid var(--line); padding: 6px 10px; border-radius: 999px; white-space: nowrap;
}
.icon-btn {
  margin-left: 8px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; width: 38px; height: 38px; font-size: 17px; cursor: pointer;
}

.arena {
  position: relative; flex: 1; min-height: 0; border-radius: 14px; overflow: hidden;
  background: #11151c;
}
.map-layer, #field { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-layer { z-index: 1; background: #11151c; }
#field { z-index: 2; display: block; touch-action: none; cursor: crosshair; }
.leaflet-container { background: #11151c !important; font: inherit; }
.leaflet-control-attribution { font-size: 9px; background: rgba(10,12,17,.6) !important; color: #888 !important; }
#game.has-monkey .arena { box-shadow: inset 0 0 0 3px var(--red), inset 0 0 50px rgba(224,27,36,.35); }

.map-loading {
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; background: rgba(10,12,17,.82); color: var(--muted);
  text-align: center; padding: 20px;
}
.spinner { width: 38px; height: 38px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.countdown {
  position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center;
  font-size: clamp(80px, 18vw, 150px); font-weight: 900; color: #fff;
  text-shadow: 0 6px 30px rgba(0,0,0,.7); pointer-events: none;
  animation: pop .4s ease;
}
@keyframes pop { from { transform: scale(1.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.banner {
  position: absolute; top: 14px; left: 50%; z-index: 7; transform: translateX(-50%) translateY(-12px);
  padding: 10px 18px; border-radius: 999px; font-weight: 800; opacity: 0; pointer-events: none;
  background: rgba(20,24,32,.92); border: 1px solid var(--line); transition: .2s; white-space: nowrap;
}
.banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.banner.danger { background: rgba(224,27,36,.95); border-color: #ff6b6b; }
.banner.warn { background: rgba(160,120,16,.95); border-color: var(--yellow); }
.banner.ok { background: rgba(38,162,105,.95); border-color: #57e389; }
.banner.go { background: rgba(38,162,105,.95); font-size: 20px; }
.banner.curse { background: rgba(97,53,131,.95); border-color: #c061cb; }
.banner.death { background: rgba(40,40,46,.96); border-color: #777; }

.spectate { position: absolute; inset: 0; z-index: 6; display: flex; align-items: flex-end; justify-content: center; pointer-events: none; }
.spectate-inner {
  pointer-events: auto; margin-bottom: 24px; background: rgba(10,12,17,.85); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 16px; text-align: center;
}
.spectate-title { color: var(--muted); margin-bottom: 8px; }
.ghost-btn, .primary-btn.ghost {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 16px; cursor: pointer; font: inherit; font-weight: 700;
}
.ghost-btn:hover { border-color: var(--accent); }

#game.shake { animation: shake .35s; }
@keyframes shake {
  0%,100%{transform:translate(0,0)} 20%{transform:translate(-6px,3px)}
  40%{transform:translate(7px,-2px)} 60%{transform:translate(-4px,-3px)} 80%{transform:translate(3px,4px)}
}

/* bottom bar: mojo + powerups */
.bottombar { display: flex; gap: 10px; align-items: stretch; }
.mojo-wrap {
  flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px;
}
.mojo-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.mojo-label span { font-weight: 700; }
.mojo-bar { position: relative; height: 26px; background: #0c0f15; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.mojo-fill { height: 100%; width: 100%; background: var(--green); transition: width .12s linear, background .3s; }
.mojo-num {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-weight: 800; font-size: 14px; text-shadow: 0 1px 3px #000;
}
.pulse-slow { animation: pSlow 1.2s infinite; }
.pulse-fast { animation: pFast .45s infinite; }
@keyframes pSlow { 50% { filter: brightness(1.35); } }
@keyframes pFast { 50% { filter: brightness(1.6); } }

.powerup-dock { display: flex; gap: 8px; align-items: center; }
.pu-btn {
  position: relative; width: 56px; height: 56px; border-radius: 12px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); color: #fff; font-size: 22px;
  display: flex; align-items: center; justify-content: center; transition: .15s;
}
.pu-btn .pu-key {
  position: absolute; top: 3px; left: 5px; font-size: 10px; color: var(--muted); font-family: var(--mono);
}
.pu-btn.ready { border-color: var(--accent); box-shadow: 0 0 12px rgba(0,212,255,.35); }
.pu-btn.active { border-color: var(--green); }
.pu-btn.active::after {
  content: attr(data-left) "s"; position: absolute; bottom: 2px; right: 4px; font-size: 9px;
  color: var(--green); font-family: var(--mono);
}
.pu-btn.used { opacity: .35; cursor: default; filter: grayscale(1); }
.dock-empty { color: var(--muted); font-size: 13px; padding: 0 8px; }

.log {
  position: absolute; left: 16px; bottom: 16px; z-index: 6; width: min(280px, 60vw);
  font-size: 12px; font-family: var(--mono); pointer-events: none;
}
.log-row { background: rgba(10,12,17,.6); border-left: 2px solid var(--line); padding: 2px 8px; margin-top: 3px; border-radius: 3px; color: var(--muted); }
.log-row.death { border-color: var(--red); color: #ff9a9a; }
.log-row.curse { border-color: #c061cb; color: #e0a8e8; }
.log-row.info { border-color: var(--accent); color: #bfe9ff; }

/* ---------------- RESULTS ---------------- */
#results { align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.result-card {
  width: min(640px, 96vw); background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px; text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
#result-title { font-size: clamp(30px, 6vw, 46px); margin: 0 0 6px; }
#result-title.win { color: var(--yellow); text-shadow: 0 0 30px rgba(245,194,17,.4); }
#result-title.lose { color: var(--red); }
.result-sub { color: var(--muted); margin: 0 0 22px; }
.result-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; text-align: left; }
@media (max-width: 520px) { .result-cols { grid-template-columns: 1fr; } }
.result-box { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.result-box h4 { margin: 0 0 10px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.stat-row, .xp-row { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,.04); }
.stat-row b { font-family: var(--mono); }
.xp-row i { color: var(--muted); font-style: normal; font-size: 12px; }
.xp-row b { color: var(--green); font-family: var(--mono); }
.reward-totals { display: flex; justify-content: space-between; margin-top: 14px; font-weight: 800; font-size: 20px; }
.xp-total { color: var(--green); }
.banana-total { color: var(--yellow); }
.result-card .primary-btn { margin-top: 22px; }
