* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --mint: #6fe3c1;
  --mint-dark: #2ba884;
  --teal: #1d7f8c;
  --pink: #ff7ba2;
  --cream: #fff8ef;
  --ink: #1c3640;
  --danger: #ff5f6d;
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Fredoka', system-ui, sans-serif;
  background: radial-gradient(circle at 50% 30%, #2a6b75 0%, #143d46 70%);
  color: var(--cream);
  user-select: none;
}

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ============================== MENUS ============================== */
#menu { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 40; pointer-events: auto; }
#menu.hidden { display: none; }
.end-btns { display: flex; gap: 12px; }

.screen {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 36px 48px; border-radius: 28px;
  background: rgba(13, 42, 50, .88);
  box-shadow: 0 24px 70px rgba(0,0,0,.5), inset 0 2px 0 rgba(255,255,255,.08);
  backdrop-filter: blur(8px);
  max-height: 92vh; overflow-y: auto;
}
.screen.hidden { display: none; }

.logo {
  font-size: 72px; font-weight: 700; letter-spacing: 2px; line-height: .95;
  color: var(--cream); text-shadow: 0 6px 0 rgba(0,0,0,.25);
}
.logo span { display: block; color: var(--mint); }
.tagline { font-size: 18px; opacity: .85; margin-bottom: 8px; }

input {
  font-family: inherit; font-size: 20px; text-align: center;
  padding: 12px 18px; border-radius: 14px; border: 3px solid var(--mint-dark);
  background: var(--cream); color: var(--ink); outline: none; width: 280px;
}
input:focus { border-color: var(--mint); }

.btn {
  font-family: inherit; font-weight: 600; font-size: 19px; cursor: pointer;
  padding: 12px 26px; border-radius: 16px; border: 0;
  background: var(--mint); color: #0c3b2e;
  box-shadow: 0 5px 0 var(--mint-dark);
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--mint-dark); }
.btn.big { font-size: 24px; padding: 16px 40px; }
.btn.small { font-size: 15px; padding: 8px 14px; }
.btn.ghost { background: transparent; color: var(--cream); box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.btn:disabled { filter: grayscale(.8) brightness(.7); cursor: not-allowed; }

.btn-col { display: flex; flex-direction: column; gap: 12px; width: 280px; }
.btn-col .btn { width: 100%; }
.join-row { display: flex; gap: 10px; }
.join-row input { width: 120px; text-transform: uppercase; letter-spacing: 4px; font-weight: 600; }
.join-row .btn { flex: 1; }
.conn { font-size: 14px; opacity: .6; min-height: 18px; }

/* ---------- lobby ---------- */
#screen-lobby { width: min(860px, 94vw); }
.lobby-head { display: flex; align-items: center; gap: 18px; }
.lobby-head h2 { font-size: 30px; }
#lobby-code { color: var(--mint); letter-spacing: 6px; }

.vote-title { font-size: 15px; opacity: .8; margin-bottom: -4px; }
#map-vote { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; width: 100%; }
.vote-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 4px 8px; border-radius: 14px; cursor: pointer;
  background: rgba(255,255,255,.07); border: 2px solid rgba(255,255,255,.15);
  transition: transform .08s, border-color .15s;
  font-family: inherit; color: var(--cream);
}
.vote-card:hover { transform: translateY(-2px); border-color: rgba(255,255,255,.4); }
.vote-card.mine { border-color: var(--mint); box-shadow: 0 0 10px rgba(111,227,193,.35); }
.vote-card.leading { background: rgba(111,227,193,.14); }
.vote-card .vicon { font-size: 26px; }
.vote-card .vname { font-size: 11.5px; font-weight: 600; text-align: center; line-height: 1.15; }
.vote-card .vcount {
  position: absolute; top: -7px; right: -5px; min-width: 20px; height: 20px;
  border-radius: 10px; background: var(--mint); color: #0c3b2e;
  font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.style-row { display: flex; align-items: center; gap: 10px; font-size: 15px; }
#hat-btns { display: flex; gap: 6px; }
.hat-btn {
  font-size: 19px; width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.15);
}
.hat-btn:hover { border-color: rgba(255,255,255,.45); }
.hat-btn.sel { border-color: var(--mint); background: rgba(111,227,193,.18); }
.opt-btns { display: flex; gap: 5px; }
.opt-btn {
  font-family: inherit; font-weight: 600; font-size: 13px; color: var(--cream);
  padding: 6px 10px; border-radius: 9px; cursor: pointer;
  background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.15);
}
.opt-btn:hover { border-color: rgba(255,255,255,.45); }
.opt-btn.sel { border-color: var(--mint); background: rgba(111,227,193,.18); }
.opt-btn:disabled { cursor: default; opacity: .55; }
.opt-btn:disabled:hover { border-color: rgba(255,255,255,.15); }
.opt-btn.sel:disabled { opacity: 1; }

.teams { display: flex; gap: 18px; width: 100%; }
.team-col {
  flex: 1; padding: 14px; border-radius: 18px; text-align: center;
  display: flex; flex-direction: column; gap: 8px;
}
.dentist-col { background: rgba(95, 170, 255, .13); border: 2px solid rgba(95,170,255,.4); }
.tooth-col { background: rgba(255, 255, 255, .10); border: 2px solid rgba(255,255,255,.4); }
.team-col h3 { font-size: 22px; }
.team-desc { font-size: 12px; opacity: .7; }
.team-list { min-height: 70px; display: flex; flex-direction: column; gap: 6px; }
.player-chip {
  background: rgba(0,0,0,.3); border-radius: 10px; padding: 6px 10px; font-size: 16px;
}
.player-chip.me { outline: 2px solid var(--mint); }
.player-chip.bot { opacity: .85; font-style: italic; }
.player-chip.bot:hover { cursor: pointer; background: rgba(255, 95, 109, .35); }
.bot-btn { margin-top: 2px; }
.bench { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; min-height: 10px; }
.bench .player-chip { opacity: .65; }
.lobby-hint { font-size: 14px; opacity: .65; }

/* ---------- end screen ---------- */
#screen-end h1 { font-size: 56px; text-shadow: 0 5px 0 rgba(0,0,0,.3); }
#end-title.win { color: var(--mint); }
#end-title.lose { color: var(--danger); }
#end-reason { font-size: 19px; opacity: .9; }
#end-stats { border-collapse: collapse; margin: 10px 0; }
#end-stats th, #end-stats td { padding: 7px 16px; text-align: center; font-size: 16px; }
#end-stats th { opacity: .6; font-weight: 600; font-size: 13px; text-transform: uppercase; }
#end-stats tbody tr { background: rgba(255,255,255,.06); }
#end-stats tbody tr:nth-child(odd) { background: rgba(255,255,255,.11); }

/* ---------- help ---------- */
#modal-help {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 40;
}
#modal-help.hidden { display: none; }
.help-box {
  background: rgba(13,42,50,.97); border-radius: 24px; padding: 30px 40px;
  max-width: 760px; width: 92vw; max-height: 90vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px; align-items: center;
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
}
.help-box h2 { font-size: 32px; color: var(--mint); }
.help-intro { font-size: 16px; text-align: center; opacity: .9; }
.help-cols { display: flex; gap: 26px; width: 100%; }
.help-cols > div { flex: 1; }
.help-cols h3 { margin-bottom: 8px; }
.help-cols small { opacity: .6; font-size: 13px; }
.help-cols ul { list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.help-foot { font-size: 14px; opacity: .7; }

/* ---------- toast ---------- */
#toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--danger); color: #fff; font-weight: 600;
  padding: 12px 26px; border-radius: 14px; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 60; font-size: 17px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================== HUD ============================== */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud.hidden { display: none; }
#hud .hidden { display: none; }

#timer {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  font-size: 38px; font-weight: 700; letter-spacing: 2px;
  text-shadow: 0 3px 0 rgba(0,0,0,.4); color: var(--cream);
}
#timer.low { color: var(--danger); animation: pulse 1s infinite; }
#timer.hide-phase { color: #ffd23f; font-size: 30px; }
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.12); } }

#crosshair {
  position: absolute; top: 50%; left: 50%; width: 14px; height: 14px;
  transform: translate(-50%, -50%);
}
#crosshair::before, #crosshair::after {
  content: ''; position: absolute; background: rgba(255,255,255,.9);
  box-shadow: 0 0 3px rgba(0,0,0,.7); border-radius: 2px;
}
#crosshair::before { left: 6px; top: 0; width: 2px; height: 14px; }
#crosshair::after { top: 6px; left: 0; width: 14px; height: 2px; }

#feed {
  position: absolute; top: 16px; right: 18px; display: flex; flex-direction: column;
  gap: 6px; align-items: flex-end; max-width: 40vw;
}
.feed-msg {
  background: rgba(10, 30, 36, .75); padding: 7px 14px; border-radius: 12px;
  font-size: 15px; animation: feedin .25s; border-left: 4px solid var(--mint);
}
.feed-msg.bad { border-left-color: var(--danger); }
.feed-msg.gold { border-left-color: #ffd23f; }
@keyframes feedin { from { transform: translateX(30px); opacity: 0; } }

#banner {
  position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
}
#banner h1 { font-size: 64px; text-shadow: 0 6px 0 rgba(0,0,0,.35); color: var(--cream); }
#banner p { font-size: 22px; opacity: .9; margin-top: 6px; }

/* dentist hud */
#dentist-hud { position: absolute; bottom: 26px; right: 34px; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
#ammo { display: flex; gap: 7px; }
.ammo-blob { width: 20px; height: 26px; border-radius: 50% 50% 45% 45%; background: var(--pink); box-shadow: inset 0 -4px 0 rgba(0,0,0,.2), 0 2px 4px rgba(0,0,0,.4); }
.ammo-blob.empty { background: rgba(255,255,255,.15); box-shadow: none; }
#reload-label { font-size: 17px; font-weight: 600; color: #ffd23f; text-shadow: 0 2px 0 rgba(0,0,0,.4); }
.skill {
  position: relative; width: 150px; height: 38px; border-radius: 12px; overflow: hidden;
  background: rgba(10,30,36,.7); display: flex; align-items: center; justify-content: center;
}
.skill span { position: relative; z-index: 1; font-weight: 600; font-size: 15px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.skill-fill { position: absolute; inset: 0; background: var(--teal); transform-origin: left; }

/* tooth hud */
#tooth-hud { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 10px; }
#goop { position: relative; width: 280px; height: 26px; border-radius: 13px; background: rgba(10,30,36,.7); overflow: hidden; }
#goop-fill { position: absolute; inset: 0; background: linear-gradient(90deg, var(--pink), #ff4f79); transform-origin: left; transform: scaleX(0); transition: transform .2s; }
#goop span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; text-shadow: 0 1px 2px rgba(0,0,0,.7); }
#trap-bar { display: flex; gap: 10px; }
.trap-slot {
  position: relative; width: 64px; height: 64px; border-radius: 14px;
  background: rgba(10,30,36,.75); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px; overflow: hidden;
  border: 2px solid rgba(255,255,255,.2);
}
.trap-slot .ico { font-size: 24px; line-height: 1; }
.trap-slot .key { position: absolute; top: 2px; left: 6px; font-size: 11px; opacity: .7; font-weight: 600; }
.trap-slot .count { font-size: 13px; font-weight: 600; }
.trap-slot .cd { position: absolute; inset: 0; background: rgba(0,0,0,.65); transform-origin: bottom; transform: scaleY(0); }
.trap-slot.empty { opacity: .35; }
.trap-slot.sel { border-color: var(--mint); box-shadow: 0 0 8px rgba(111,227,193,.5); }
.ability-hints { display: flex; gap: 18px; }
#shrink-hint, #camo-hint { font-size: 13px; opacity: .65; font-weight: 600; letter-spacing: 1px; }
#shrink-hint.active, #camo-hint.active { color: var(--mint); opacity: 1; }
#camo-hint.active { animation: camo-pulse 1.6s infinite; }
@keyframes camo-pulse { 50% { opacity: .55; } }

/* scoreboard */
#scoreboard {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(10,30,36,.92); border-radius: 18px; padding: 22px 34px;
  min-width: 420px;
}
#scoreboard h3 { margin: 8px 0 4px; font-size: 18px; }
#scoreboard .sb-row { display: flex; justify-content: space-between; gap: 30px; font-size: 16px; padding: 3px 0; }
#scoreboard .sb-row .dead { opacity: .45; text-decoration: line-through; }

#hint-pause {
  position: absolute; top: 60%; left: 50%; transform: translateX(-50%);
  background: rgba(10,30,36,.85); padding: 12px 26px; border-radius: 14px;
  font-size: 18px; font-weight: 600;
}
#spectate-label {
  position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%);
  font-size: 17px; font-weight: 600; opacity: .85;
  background: rgba(10,30,36,.8); padding: 10px 22px; border-radius: 12px;
}

/* ---------- blindfold (dentist hide phase) ---------- */
#fx-blindfold {
  position: fixed; inset: 0; z-index: 14;
  background: radial-gradient(circle at 50% 45%, rgba(16, 10, 24, .96) 0%, rgba(4, 2, 8, .99) 75%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center; pointer-events: none;
}
#fx-blindfold.hidden { display: none; }
.blindfold-emoji { font-size: 90px; animation: bf-bob 2.4s ease-in-out infinite; }
@keyframes bf-bob { 50% { transform: translateY(-12px) rotate(-4deg); } }
#fx-blindfold h2 { font-size: 38px; color: var(--cream); }
#fx-blindfold p { font-size: 18px; opacity: .75; }
#blindfold-count { font-size: 72px; font-weight: 700; color: #ffd23f; text-shadow: 0 5px 0 rgba(0,0,0,.5); }

/* ---------- mic chip ---------- */
#mic-chip {
  position: fixed; bottom: 18px; left: 18px; z-index: 30;
  background: rgba(10, 30, 36, .85); color: var(--cream);
  font-family: 'Fredoka', sans-serif; font-size: 14px; font-weight: 600;
  padding: 9px 16px; border-radius: 12px;
  border: 2px solid rgba(111, 227, 193, .5);
}
#mic-chip.muted { border-color: rgba(255, 95, 109, .6); opacity: .85; }
#mic-chip.hidden { display: none; }
#mic-chip { display: flex; align-items: center; gap: 8px; cursor: pointer; pointer-events: auto; }
#mic-vu { width: 46px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.15); overflow: hidden; display: inline-block; }
#mic-vu-fill { display: block; height: 100%; width: 0%; background: var(--mint); border-radius: 4px; transition: width .08s; }

/* ---------- text chat ---------- */
#chat {
  position: fixed; bottom: 56px; left: 18px; z-index: 30; width: 340px;
  display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
#chat-log { display: flex; flex-direction: column; gap: 4px; }
.chat-msg {
  background: rgba(10, 30, 36, .78); border-radius: 10px; padding: 5px 11px;
  font-size: 14px; color: var(--cream); animation: feedin .2s;
  align-self: flex-start; max-width: 100%; word-break: break-word;
}
.chat-msg .who { font-weight: 600; }
.chat-msg .who.dentist { color: #8fc9ff; }
.chat-msg .who.tooth { color: #fff; }
.chat-msg .who.dead { color: #b9aaf0; }
.chat-msg.fade { opacity: 0; transition: opacity 1s; }
#chat-input {
  pointer-events: auto; width: 100%; font-size: 15px; text-align: left;
  padding: 8px 12px; border-radius: 10px; border: 2px solid var(--mint-dark);
}
#chat-input.hidden { display: none; }

/* ============================== touch controls ============================== */
#touch-ui { position: fixed; inset: 0; z-index: 16; pointer-events: none; }
#touch-ui.hidden { display: none; }
#touch-ui * { touch-action: none; -webkit-touch-callout: none; user-select: none; }
#touch-look {
  position: absolute; top: 0; right: 0; width: 60%; height: calc(100% - 150px);
  pointer-events: auto;
}
#joy-base {
  position: absolute; left: 22px; bottom: 110px; width: 132px; height: 132px;
  border-radius: 50%; background: rgba(10, 30, 36, .35);
  border: 2px solid rgba(255,255,255,.25); pointer-events: auto;
  display: flex; align-items: center; justify-content: center;
}
#joy-nub {
  width: 58px; height: 58px; border-radius: 50%;
  background: rgba(111, 227, 193, .55); border: 2px solid rgba(255,255,255,.5);
  pointer-events: none;
}
#touch-btns {
  position: absolute; right: 16px; bottom: 110px; pointer-events: none;
  display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 12px;
}
.touch-btn {
  pointer-events: auto; width: 60px; height: 60px; border-radius: 50%;
  font-size: 26px; border: 2px solid rgba(255,255,255,.35);
  background: rgba(10, 30, 36, .5); color: var(--cream);
}
.touch-btn.big { width: 82px; height: 82px; font-size: 36px; }
.touch-btn:active { background: rgba(111, 227, 193, .45); transform: scale(.94); }
.touch-btn.on { border-color: var(--mint); background: rgba(111,227,193,.3); }

/* touch devices: no pointer-lock prompts, tappable trap bar */
.touch-device #hint-pause { display: none !important; }
#trap-bar { pointer-events: auto; }
.trap-slot { cursor: pointer; }
.touch-device #tooth-hud { bottom: 12px; }
.touch-device .trap-slot { width: 52px; height: 52px; }
.touch-device .trap-slot .ico { font-size: 19px; }
@media (max-width: 480px) {
  .touch-device #trap-bar { gap: 5px; }
  .touch-device .trap-slot { width: 44px; height: 44px; border-radius: 10px; }
  .touch-device .trap-slot .ico { font-size: 16px; }
  .touch-device .trap-slot .count { font-size: 11px; }
  .touch-device #goop { width: 170px; height: 20px; }
}

/* small screens: compact menus */
@media (max-width: 760px) {
  .screen { padding: 20px 16px; border-radius: 18px; width: 96vw; gap: 10px; }
  .logo { font-size: 48px; }
  #map-vote { grid-template-columns: repeat(3, 1fr); }
  .teams { flex-direction: column; gap: 10px; }
  .help-cols { flex-direction: column; gap: 12px; }
  #timer { font-size: 26px; top: 10px; }
  .style-row { flex-wrap: wrap; justify-content: center; }
  #end-stats th, #end-stats td { padding: 4px 7px; font-size: 13px; }
  #chat { width: 250px; bottom: 250px; }
  #mic-chip { bottom: 8px; left: 8px; font-size: 12px; padding: 6px 10px; }
  #goop { width: 200px; }
}

/* ============================== FX overlays ============================== */
#fx-plaque, #fx-trip, #fx-goop { position: fixed; inset: 0; pointer-events: none; z-index: 15; opacity: 0; }
#fx-plaque {
  background:
    radial-gradient(ellipse 30% 22% at 22% 30%, rgba(214,188,80,.92) 0%, rgba(214,188,80,0) 70%),
    radial-gradient(ellipse 36% 28% at 70% 60%, rgba(199,170,60,.9) 0%, rgba(199,170,60,0) 70%),
    radial-gradient(ellipse 26% 30% at 45% 80%, rgba(225,200,95,.9) 0%, rgba(225,200,95,0) 70%),
    radial-gradient(ellipse 24% 18% at 80% 18%, rgba(214,188,80,.85) 0%, rgba(214,188,80,0) 70%);
  transition: opacity .3s;
}
#fx-trip { background: radial-gradient(circle, transparent 35%, rgba(120, 30, 30, .55) 100%); transition: opacity .2s; }
#fx-goop {
  background:
    radial-gradient(ellipse 40% 30% at 10% 90%, rgba(255,123,162,.8) 0%, transparent 70%),
    radial-gradient(ellipse 35% 25% at 90% 85%, rgba(255,123,162,.75) 0%, transparent 70%),
    radial-gradient(ellipse 50% 18% at 50% 100%, rgba(255,79,121,.8) 0%, transparent 75%);
  transition: opacity .4s;
}
