@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Inter:wght@400;600;700;800&display=swap');

/* ===== Day theme (default) ===== */
:root{
  --bg:#f4f7fc;
  --panel:#ffffff;
  --panel-2:#eef2f9;
  --border:#d9e1ee;
  --text:#182233;
  --text-dim:#5c6b85;

  --blue:#2f80ed;
  --yellow:#c98a00;
  --red:#e5484d;
  --green:#1fa971;
  --gray:#8792a6;

  --font-display:'Press Start 2P', monospace;
  --font-body:'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius:14px;
  --radius-sm:9px;
}

/* ===== Night theme (toggle from the ☰ menu) ===== */
body.theme-night{
  --bg:#101826;
  --panel:#182338;
  --panel-2:#1e2c47;
  --border:#2c3c5c;
  --text:#eaf1ff;
  --text-dim:#8ea0c2;

  --blue:#3aa0ff;
  --yellow:#ffcc33;
  --red:#ff5c5c;
  --green:#39d98a;
  --gray:#9aa7bd;
}

*{ box-sizing:border-box; }
html,body{ height:100%; margin:0; }
body{
  background:
    radial-gradient(circle at 20% 0%, rgba(47,128,237,0.08), transparent 55%),
    radial-gradient(circle at 90% 100%, rgba(229,72,77,0.06), transparent 55%),
    var(--bg);
  color:var(--text);
  font-family:var(--font-body);
  min-height:100vh;
  transition:background-color .2s ease, color .2s ease;
}

#app{ max-width:520px; margin:0 auto; padding:16px 16px 48px; display:flex; flex-direction:column; gap:14px; }

/* ---- Top bar / menu ---- */
.topbar{ display:flex; align-items:center; justify-content:space-between; position:relative; z-index:40; }
.topbar-title{ display:flex; align-items:center; gap:8px; font-weight:800; font-size:14px; color:var(--text); }
.menu-wrap{ position:relative; margin-left:auto; }
.menu-btn{
  background:var(--panel); color:var(--text);
  border-radius:var(--radius-sm); padding:8px; cursor:pointer; display:flex;
  box-shadow:0 1px 3px rgba(0,0,0,0.08);
}
.menu-btn:hover{ background:var(--panel-2); }
.menu-dropdown{
  display:none; flex-direction:column; position:absolute; right:0; top:calc(100% + 6px);
  background-color:#ffffff; border-radius:var(--radius-sm);
  min-width:190px; padding:6px; z-index:1000; box-shadow:0 8px 24px rgba(0,0,0,0.20);
}
.menu-dropdown.open{ display:flex; }
.menu-item{
  background:transparent; border:none; text-align:left; padding:10px 12px;
  font-size:13.5px; font-weight:600; color:#182233; cursor:pointer;
  border-radius:8px; display:flex; align-items:center; gap:8px;
}
.menu-item:hover{ background:#eef2f9; }
/* ---- "How to play" live demo: a tiny animated seeker-chases-hider scene
   (~370×90, constantly looping, pure CSS — no JS/canvas timers needed) ---- */
.demo-banner{
  position:relative;
  width:min(370px, 100%);
  height:90px;
  margin:2px auto 0;
  border-radius:16px;
  overflow:hidden;
  box-shadow:0 1px 3px rgba(0,0,0,0.08);
  background: linear-gradient(180deg, rgba(47,128,237,0.07), rgba(31,169,113,0.10));
}
body.theme-night .demo-banner{
  background: linear-gradient(180deg, rgba(58,160,255,0.12), rgba(57,255,136,0.08));
}
.demo-ground{
  position:absolute; left:0; right:0; bottom:0; height:32%;
  background: repeating-linear-gradient(90deg, rgba(31,169,113,0.20) 0 6px, transparent 6px 16px);
}
body.theme-night .demo-ground{
  background: repeating-linear-gradient(90deg, rgba(57,255,136,0.16) 0 6px, transparent 6px 16px);
}

.demo-label{
  position:absolute; top:6px; left:10px; z-index:5;
  font-family:var(--font-display); font-size:8px; letter-spacing:0.05em;
  color:var(--text-dim); display:flex; align-items:center; gap:4px;
}
.demo-label .icon{ width:10px; height:10px; }
.demo-live-tag{
  position:absolute; top:7px; right:10px; z-index:5;
  display:flex; align-items:center; gap:4px;
  font-size:8.5px; font-weight:800; letter-spacing:0.05em;
  color:var(--red);
}
.demo-live-dot{ width:5px; height:5px; border-radius:50%; background:var(--red); animation:blink 1s step-start infinite; }

/* Fixed "hiding spots" on the mini map */
.demo-bush{ position:absolute; top:44%; transform:translateY(-50%); font-size:18px; opacity:0.85; z-index:1; }
.demo-bush-1{ left:92px; }
.demo-bush-2{ left:218px; }

/* Hider + seeker travel a fixed path across the map, on a shared 9s loop */
.demo-hider-wrap, .demo-seeker-wrap, .demo-hider-caught, .demo-flash{
  position:absolute; top:50%; left:0; z-index:2;
}
.demo-hider-wrap .icon, .demo-seeker-wrap .icon,
.demo-hider-wrap .icon-emoji, .demo-seeker-wrap .icon-emoji{ font-size:19px; }
.demo-hider-wrap{ color:var(--blue); animation:demoHiderPath 9s infinite; }
.demo-seeker-wrap{ color:var(--red); animation:demoSeekerPath 9s infinite; }
.demo-hider-caught{
  font-size:17px; opacity:0; z-index:3;
  transform:translate(280px,-50%);
  animation:demoCaughtFade 9s infinite;
}
.demo-hider-bob{ display:block; animation:demoHiderBob 0.9s ease-in-out infinite; }
.demo-seeker-bob{ display:block; animation:demoSeekerBob 1.1s ease-in-out infinite; }
@keyframes demoHiderBob{ 0%,100%{ transform:translateY(0); } 50%{ transform:translateY(-2px); } }
@keyframes demoSeekerBob{ 0%,100%{ transform:rotate(-7deg); } 50%{ transform:rotate(7deg); } }

/* Hider ducks small+dim behind a bush, peeks out, dashes to the next bush,
   and finally gets cornered right where the seeker converges. */
@keyframes demoHiderPath{
  0%   { transform:translate(92px,  calc(-50% + 0px))  scale(0.65); opacity:0.55; }
  20%  { transform:translate(100px, calc(-50% - 6px))  scale(1);    opacity:1; }
  34%  { transform:translate(172px, calc(-50% - 10px)) scale(1);    opacity:1; }
  38%  { transform:translate(218px, calc(-50% + 5px))  scale(0.65); opacity:0.55; }
  55%  { transform:translate(222px, calc(-50% + 5px))  scale(0.65); opacity:0.55; }
  64%  { transform:translate(246px, calc(-50% - 7px))  scale(1);    opacity:1; }
  78%  { transform:translate(272px, calc(-50% - 3px))  scale(1);    opacity:1; }
  80%  { transform:translate(280px, calc(-50% + 0px))  scale(1.15); opacity:0; }
  92%  { transform:translate(280px, calc(-50% + 0px))  scale(1.15); opacity:0; }
  100% { transform:translate(92px,  calc(-50% + 0px))  scale(0.65); opacity:0.55; }
}
/* Seeker enters from off-screen, sweeps across, and converges right as the
   hider is cornered — then retreats to reset the loop. */
@keyframes demoSeekerPath{
  0%   { transform:translate(-26px, -50%); opacity:0; }
  8%   { opacity:1; }
  10%  { transform:translate(16px,  calc(-50% + 4px)); }
  25%  { transform:translate(76px,  calc(-50% - 6px)); }
  35%  { transform:translate(124px, calc(-50% + 4px)); }
  50%  { transform:translate(188px, calc(-50% - 8px)); }
  62%  { transform:translate(230px, calc(-50% + 4px)); }
  74%  { transform:translate(264px, calc(-50% - 2px)); }
  80%  { transform:translate(280px, -50%); }
  88%  { transform:translate(280px, -50%); }
  92%  { transform:translate(230px, -50%); opacity:0; }
  100% { transform:translate(-26px, -50%); opacity:0; }
}
@keyframes demoCaughtFade{
  0%,78%  { opacity:0; }
  80%,90% { opacity:1; }
  94%,100%{ opacity:0; }
}
.demo-flash{
  width:24px; height:24px; margin:-12px 0 0 -12px; border-radius:50%;
  border:3px solid var(--red);
  transform:translate(280px,-50%) scale(0.4); opacity:0;
  animation:demoFlashPulse 9s infinite;
}
@keyframes demoFlashPulse{
  0%,76% { opacity:0;  transform:translate(280px,-50%) scale(0.4); }
  79%    { opacity:0.9; transform:translate(280px,-50%) scale(1); }
  84%    { opacity:0;  transform:translate(280px,-50%) scale(1.9); }
  100%   { opacity:0; }
}

/* Status readout at the bottom mirrors the real in-game proximity colors */
.demo-status-labels{ position:absolute; left:0; right:0; bottom:6px; z-index:5; height:14px; text-align:center; }
.demo2-label{ position:absolute; left:0; right:0; font-size:11px; font-weight:800; letter-spacing:0.04em; opacity:0; }
.demo2-label-far{    color:var(--gray);   animation:demo2Far 9s infinite; }
.demo2-label-close{  color:var(--yellow); animation:demo2Close 9s infinite; }
.demo2-label-near{   color:var(--blue);   animation:demo2Near 9s infinite; }
.demo2-label-caught{ color:var(--red);    animation:demo2Caught 9s infinite; }
@keyframes demo2Far{    0%,36%{ opacity:1; } 40%,100%{ opacity:0; } }
@keyframes demo2Close{  0%,36%{ opacity:0; } 40%,62%{ opacity:1; } 66%,100%{ opacity:0; } }
@keyframes demo2Near{   0%,66%{ opacity:0; } 70%,78%{ opacity:1; } 82%,100%{ opacity:0; } }
@keyframes demo2Caught{ 0%,78%{ opacity:0; } 80%,90%{ opacity:1; } 94%,100%{ opacity:0; } }


h1{

  font-family:var(--font-display);
  font-size:19px;
  line-height:1.5;
  display:flex; align-items:center; gap:10px;
  margin:6px 0 0;
  color:var(--blue);
}
h2{ font-family:var(--font-display); font-size:15px; margin:0; }

.tagline{ color:var(--text-dim); font-size:13.5px; line-height:1.5; margin:0 0 4px; }
.hint{ color:var(--text-dim); font-size:12.5px; text-align:center; margin:4px 0 0; }
.footnote{ color:var(--text-dim); font-size:11.5px; line-height:1.6; text-align:center; margin-top:6px; }
.connecting{ display:flex; align-items:center; gap:8px; justify-content:center; padding:40px 10px; color:var(--text-dim); font-size:14px; }
.spinner{
  width:16px; height:16px; border-radius:50%;
  border:2.5px solid var(--panel-2); border-top-color:var(--blue);
  animation:spin .7s linear infinite;
}
@keyframes spin{ to{ transform:rotate(360deg); } }

/* Screens fade + rise into place — plays on join, and on every screen change */
#app > div{ animation:screenIn .35s ease both; }
@keyframes screenIn{
  from{ opacity:0; transform:translateY(10px); }
  to{ opacity:1; transform:translateY(0); }
}
.join-error, .geo-error{ color:var(--red); font-size:12.5px; display:flex; align-items:center; gap:6px; margin:8px 0 0; }

/* ---- Icons & emoji ---- */
.icon{ width:18px; height:18px; flex:none; vertical-align:middle; }
h1 .icon{ width:22px; height:22px; }
label .icon, .btn .icon, .role-badge .icon{ width:15px; height:15px; }
.tag .icon{ width:12px; height:12px; }
.status-icon-hidden{ color:var(--green); }
.emoji-mark{ font-size:16px; line-height:1; display:inline-flex; align-items:center; }
.emoji-revealed{ font-size:15px; }
.icon-emoji{ font-size:1.05em; line-height:1; vertical-align:-0.12em; display:inline-block; }

/* ---- Round per-player avatar (first-initial, color-coded to match radar dots) ---- */
.avatar{
  display:inline-flex; align-items:center; justify-content:center;
  width:22px; height:22px; border-radius:50%; flex:none;
  font-size:11px; font-weight:800; line-height:1;
  box-shadow:0 0 0 2px var(--panel);
}
.avatar-sm{ width:18px; height:18px; font-size:9.5px; }

/* ---- Panels ---- */
.panel{
  background:var(--panel);
  border-radius:var(--radius);
  padding:16px;
  display:flex; flex-direction:column; gap:10px;
  box-shadow:0 1px 3px rgba(0,0,0,0.06);
}
body.theme-night .panel{ box-shadow:0 1px 4px rgba(0,0,0,0.30); }
label{
  display:flex; align-items:center; gap:7px;
  font-size:11.5px; font-weight:700; letter-spacing:0.06em; text-transform:uppercase;
  color:var(--text-dim);
}

/* ---- Inputs ---- */
input[type=text], input[type=number]{
  width:100%;
  background:var(--bg);
  border:none;
  box-shadow:inset 0 0 0 1.5px var(--panel-2);
  color:var(--text);
  font-family:var(--font-body);
  font-size:16px;
  padding:11px 12px;
  border-radius:var(--radius-sm);
  outline:none;
}
input[type=text]:focus, input[type=number]:focus{ box-shadow:inset 0 0 0 1.5px var(--blue); }
input[type=checkbox], input[type=radio]{ width:17px; height:17px; accent-color:var(--blue); }

.toggle-row{ flex-direction:row; align-items:center; text-transform:none; letter-spacing:0; font-size:13.5px; color:var(--text); gap:8px; cursor:pointer; }

/* ---- Buttons ---- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  font-family:var(--font-body); font-weight:700; font-size:14.5px;
  border:none;
  border-radius:var(--radius-sm);
  padding:13px 16px;
  cursor:pointer;
  width:100%;
  transition:transform .08s ease;
}
.btn:active{ transform:scale(0.97); }
.btn:disabled{ opacity:0.45; cursor:not-allowed; }
.btn-small{ width:auto; padding:9px 13px; font-size:13px; }

.btn-primary{ background:var(--blue); color:#ffffff; box-shadow:0 4px 0 rgba(0,0,0,0.18); }
.btn-primary:active{ box-shadow:0 1px 0 rgba(0,0,0,0.18); }

/* Create Room button gives a brief attention-grabbing shake every ~2.6s */
@keyframes createBtnShake{
  0%, 90%, 100%{ transform:translateX(0) rotate(0); }
  91%{ transform:translateX(-4px) rotate(-2deg); }
  92%{ transform:translateX(4px) rotate(2deg); }
  93%{ transform:translateX(-4px) rotate(-2deg); }
  94%{ transform:translateX(4px) rotate(2deg); }
  95%{ transform:translateX(-2px) rotate(-1deg); }
  96%{ transform:translateX(2px) rotate(1deg); }
  97%, 100%{ transform:translateX(0) rotate(0); }
}
#createBtn{ animation:createBtnShake 2.6s ease-in-out infinite; }
#createBtn:hover, #createBtn:active{ animation-play-state:paused; }

.btn-secondary{ background:var(--panel-2); color:var(--text); }

/* Join button + Deal Roles & Start button — both green, per request */
.btn-green{ background:var(--green); color:#ffffff; box-shadow:0 4px 0 rgba(0,0,0,0.18); }
.btn-green:active{ box-shadow:0 1px 0 rgba(0,0,0,0.18); }

.btn-reveal{ background:var(--green); color:#04241a; box-shadow:0 4px 0 rgba(0,0,0,0.18); font-size:15px; }
.btn-reveal:active{ box-shadow:0 1px 0 rgba(0,0,0,0.18); }
.btn-reveal:disabled{ background:var(--panel-2); color:var(--text-dim); box-shadow:none; }

/* ---- Join screen ---- */
.screen-join{ display:flex; flex-direction:column; gap:14px; }

/* ---- Lobby ---- */
.room-code{
  font-family:var(--font-display);
  font-size:24px; letter-spacing:0.1em;
  color:var(--yellow);
  text-align:center; margin:0;
  display:flex; align-items:center; justify-content:center; gap:10px;
}
.player-count{ text-align:center; color:var(--text-dim); font-size:12.5px; display:flex; align-items:center; justify-content:center; gap:6px; margin:0; }

.player-list, .final-roles, .participant-list, .role-pick-list, .chat-messages{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:8px; }
.player-list li, .final-roles li, .participant-list li{
  display:flex; align-items:center; justify-content:space-between;
  background:var(--bg); border-radius:var(--radius-sm);
  padding:10px 12px; font-size:14px;
}
.player-name{ display:flex; align-items:center; gap:7px; }
.player-badges{ display:flex; gap:6px; }
.tag{
  display:flex; align-items:center; gap:4px;
  font-size:10px; font-weight:700; letter-spacing:0.06em; text-transform:uppercase;
  padding:3px 8px; border-radius:999px;
}
.tag-you{ background:rgba(47,128,237,0.12); color:var(--blue); }
.tag-host{ background:rgba(201,138,0,0.12); color:var(--yellow); }

.role-pick-row{ flex-direction:column; align-items:stretch; gap:8px; }
.role-pick-options{ display:flex; gap:14px; }
.role-radio{ display:flex; align-items:center; gap:6px; font-size:13px; color:var(--text); text-transform:none; letter-spacing:0; font-weight:500; cursor:pointer; }

/* ---- HUD / game screen ---- */
.hud-top{ display:flex; align-items:center; justify-content:space-between; gap:8px; }
.hud-item{ display:flex; align-items:center; gap:7px; }
.hud-timer{
  font-family:var(--font-display); font-size:15px; color:var(--text);
  background:var(--panel); border-radius:var(--radius-sm);
  padding:8px 12px; box-shadow:0 1px 3px rgba(0,0,0,0.06);
}
.hud-timer.timer-low{ color:var(--red); background:rgba(229,72,77,0.10); animation:blink 1s step-start infinite; }
@keyframes blink{ 50%{ opacity:0.35; } }

.role-badge{
  display:flex; align-items:center; gap:6px;
  font-size:11.5px; font-weight:800; letter-spacing:0.06em; text-transform:uppercase;
  padding:8px 12px; border-radius:999px;
}
.role-badge.role-seeker{ background:rgba(229,72,77,0.16); color:var(--red); }
.role-badge.role-hider{ background:rgba(47,128,237,0.16); color:var(--blue); }

/* ---- Tracker rows: name left, distance badge right. A colored left edge
   (not a full outline) shows the proximity zone at a glance. ---- */
.tracker-list{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:5px; }
.tracker-row{
  display:flex; align-items:center; justify-content:space-between; gap:5px;
  background:var(--bg); border-radius:var(--radius-sm);
  border-left:4px solid var(--panel-2);
  padding:7px 8px 7px 8px;
}
.tracker-row .row-left{ display:flex; align-items:center; gap:5px; font-size:15px; font-weight:700; min-width:0; flex:1 1 auto; }
.tracker-row .row-left .player-name{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.tracker-row .row-left .icon{ width:15px; height:15px; flex:none; }
.tracker-row .row-left .emoji-mark{ font-size:14px; flex:none; }
.dist-badge{
  display:flex; align-items:center; gap:3px; flex:none;
  font-family:var(--font-display); font-size:10.5px;
  padding:4px 6px; border-radius:var(--radius-sm);
}
.dist-badge .icon{ width:12px; height:12px; }
.dist-value{ font-size:13px; }
.dist-unit{ font-size:8.5px; opacity:0.85; }

/* Proximity colors: blue < 20m, yellow < 50m, gray for everything beyond */
.zone-blue{ color:var(--blue); }
.dist-badge.zone-blue{ background:rgba(47,128,237,0.10); }
.tracker-row.zone-blue{ border-left-color:var(--blue); }

.zone-yellow{ color:var(--yellow); }
.dist-badge.zone-yellow{ background:rgba(201,138,0,0.10); }
.tracker-row.zone-yellow{ border-left-color:var(--yellow); }

.zone-gray{ color:var(--gray); }
.dist-badge.zone-gray{ background:rgba(135,146,166,0.10); }
.tracker-row.zone-gray{ border-left-color:var(--gray); }

.zone-nofix{ color:var(--text-dim); }
.dist-badge.zone-nofix{ background:var(--panel-2); }

.empty-row{ text-align:center; color:var(--text-dim); font-size:13px; padding:14px 0; list-style:none; }

/* ---- Chat ---- */
.chat-box{ gap:8px; }
.chat-messages{ max-height:180px; overflow-y:auto; padding-right:2px; }
.chat-messages li{
  background:var(--bg); border-radius:var(--radius-sm);
  border-left:3px solid transparent;
  padding:8px 10px; font-size:13px; display:flex; flex-direction:column; gap:2px;
}
.chat-messages li.own-message{ border-left-color:var(--blue); background:rgba(47,128,237,0.06); }
.chat-name{ font-size:10.5px; font-weight:800; color:var(--blue); text-transform:uppercase; letter-spacing:0.04em; }
.chat-text{ color:var(--text); word-break:break-word; }
.chat-input-row{ display:flex; gap:8px; }
.chat-input-row input{ flex:1; }

/* ---- Status chips in participant / final lists ---- */
.role-tag{ display:flex; align-items:center; gap:6px; font-size:11.5px; color:var(--text-dim); text-transform:capitalize; }

/* ---- Tracker + radar side-by-side row ---- */
.tracker-row-layout{ display:flex; gap:10px; align-items:stretch; }
.tracker-row-layout .tracker-panel{ flex:1 1 auto; min-width:0; }
@media (max-width:360px){
  .tracker-row-layout{ flex-direction:column; }
  .radar-panel{ width:100%; flex:none; align-self:stretch; flex-direction:row; justify-content:center; gap:10px; }
}

/* ---- Radar (PUBG-style), docked beside the tracker list ---- */
.radar-panel{
  flex:0 0 104px;
  width:104px;
  align-self:flex-start;
  display:flex; flex-direction:column; align-items:center; gap:6px;
  background:var(--panel); border-radius:16px;
  padding:8px; box-shadow:0 2px 10px rgba(0,0,0,0.12);
}
.radar-svg-holder{ width:88px; height:88px; }
.radar-svg{ width:100%; height:100%; display:block; }
.radar-ring-outer, .radar-ring-mid, .radar-ring-inner{ fill:none; stroke:var(--border); stroke-width:1; }
.radar-cross{ stroke:var(--border); stroke-width:0.6; }
.radar-self{ fill:var(--text); }
.radar-dot{ stroke:var(--panel); stroke-width:1; }
.radar-dot-found{ opacity:0.35; }
.radar-dot-edge{ opacity:0.6; }
.radar-compass-btn{
  width:100%; border:none; background:var(--panel-2); color:var(--text-dim);
  font-size:10px; font-weight:700; padding:5px 4px; border-radius:8px; cursor:pointer;
}
.radar-compass-btn:hover{ background:var(--border); }

/* ---- End screen ---- */
.screen-end{ display:flex; flex-direction:column; gap:14px; align-items:stretch; text-align:center; }
.result-title{ display:flex; align-items:center; justify-content:center; gap:10px; font-size:17px; flex-wrap:wrap; }
.result-title.result-seeker{ color:var(--red); }
.result-title.result-hiders{ color:var(--blue); }
