:root {
  --face: #c0c0c0;
  --hi: #ffffff;
  --lo: #808080;
  --dk: #000000;
  --title1: #000080;
  --title2: #1084d0;
  --ink: #000000;
  --select: #000080;
  --font: Tahoma, "MS Sans Serif", "Microsoft Sans Serif", Verdana, "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--ink); font: 13px/1.35 var(--font); }
[hidden] { display: none !important; }

/* ---------- 3D view ---------- */
#view { position: fixed; inset: 0; transition: transform 0.9s cubic-bezier(.6,.05,.3,1); }
#view.flipped { transform: rotate(180deg); }
#game, #tags { position: absolute; inset: 0; width: 100%; height: 100%; }
#game { image-rendering: pixelated; image-rendering: crisp-edges; }
#tags { pointer-events: none; }
body.playing #view { cursor: crosshair; }

#flash { position: fixed; inset: 0; pointer-events: none; background: #fff; opacity: 0; transition: opacity 0.5s; }
#flash.on { opacity: 0.85; transition: none; }
#flash.red { background: #c00000; }

#blind { position: fixed; inset: 0; background: #000; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; z-index: 5; }
.blind-title { font: bold 44px var(--font); color: #ffff00; text-shadow: 3px 3px 0 #000080; }
.blind-sub { font-size: 18px; margin-top: 6px; color: #c0c0c0; }
.blind-count { font: bold 120px/1 var(--font); margin-top: 18px; }

/* ---------- Win95 chrome ---------- */
.win {
  background: var(--face);
  border: 2px solid; border-color: var(--hi) var(--dk) var(--dk) var(--hi);
  box-shadow: inset -1px -1px 0 var(--lo), inset 1px 1px 0 #dfdfdf, 4px 4px 0 rgba(0,0,0,.35);
  padding: 3px;
}
.win .title {
  background: linear-gradient(90deg, var(--title1), var(--title2));
  color: #fff; font-weight: bold; padding: 3px 5px; display: flex; align-items: center; gap: 6px; user-select: none;
}
.win .title img { width: 16px; height: 16px; image-rendering: auto; }
.win .title span { font-weight: normal; opacity: .85; }
.win .body { padding: 12px; }
.dialog { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; z-index: 10; }
.dialog.wide { width: min(820px, calc(100vw - 32px)); }

.btn {
  font: inherit; background: var(--face); color: var(--ink); padding: 5px 16px; min-width: 84px; cursor: pointer;
  border: 2px solid; border-color: var(--hi) var(--dk) var(--dk) var(--hi);
  box-shadow: inset -1px -1px 0 var(--lo), inset 1px 1px 0 #dfdfdf;
}
.btn.default { outline: 1px solid var(--dk); outline-offset: 0; }
.btn:active:not(:disabled) { border-color: var(--dk) var(--hi) var(--hi) var(--dk); box-shadow: inset 1px 1px 0 var(--lo); padding: 6px 15px 4px 17px; }
.btn:focus-visible { outline: 1px dotted var(--dk); outline-offset: -5px; }
.btn:disabled { color: var(--lo); text-shadow: 1px 1px 0 var(--hi); cursor: default; }

input, select {
  font: inherit; background: #fff; color: var(--ink); padding: 3px 4px;
  border: 2px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo);
  box-shadow: inset 1px 1px 0 var(--dk); border-radius: 0;
}
select:disabled { background: var(--face); color: #404040; }
input:focus, select:focus { outline: 1px dotted var(--dk); outline-offset: 1px; }

fieldset { border: 1px solid var(--lo); box-shadow: 1px 1px 0 var(--hi), inset 1px 1px 0 var(--hi); margin: 0; padding: 8px 10px 10px; min-width: 0; }
legend { padding: 0 4px; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.row.tight { margin-top: 8px; }
.row.end { justify-content: flex-end; }
.row input { flex: 1; min-width: 120px; }
.status { color: #404040; min-height: 1.3em; margin-top: 8px; flex: 1; }
.status.err { color: #a00000; }

.join-hero { display: flex; gap: 12px; align-items: center; }
.join-hero p { margin: 0 0 6px; }
.hero-rat { width: 120px; flex: none; }

/* lobby */
.lobby { display: grid; grid-template-columns: 1fr 1.25fr; gap: 10px; }
.lobby .how, .lobby .invite, .lobby .row.end { grid-column: 1 / -1; }
.listbox { list-style: none; margin: 0; padding: 2px; background: #fff; min-height: 150px; max-height: 230px; overflow: auto;
  border: 2px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo); box-shadow: inset 1px 1px 0 var(--dk); }
.listbox li { padding: 2px 4px; display: flex; gap: 6px; align-items: center; }
.listbox li.me { background: var(--select); color: #fff; }
.listbox li .tag { font-size: 11px; color: var(--lo); }
.listbox li.me .tag { color: #c0c0ff; }
.listbox li .score { margin-left: auto; font-variant-numeric: tabular-nums; }
.settings { display: grid; gap: 7px; }
.settings label { display: grid; grid-template-columns: 105px 1fr; align-items: center; gap: 8px; }
.settings label.local { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--lo); box-shadow: 0 -1px 0 var(--hi); }
.settings select { width: 100%; min-width: 0; }
.how ul { margin: 0; padding-left: 18px; }
.how li { margin: 2px 0; }
.invite { background: #ffffe1; border: 1px solid var(--dk); padding: 6px 8px; }
.invite code { font: 12px/1.4 Consolas, "Courier New", monospace; user-select: all; }

/* results */
.winner { font: bold 20px var(--font); text-align: center; margin-bottom: 10px; }
.results { width: 100%; border-collapse: collapse; background: #fff; border: 2px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo); }
.results th { background: var(--face); text-align: left; padding: 3px 6px; font-weight: normal; border: 1px solid; border-color: var(--hi) var(--lo) var(--lo) var(--hi); }
.results td { padding: 3px 6px; }
.results td:nth-child(n+3), .results th:nth-child(n+3) { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 6; }
.hud-panel { position: absolute; background: var(--face); padding: 6px 10px;
  border: 2px solid; border-color: var(--hi) var(--dk) var(--dk) var(--hi); box-shadow: inset -1px -1px 0 var(--lo), 3px 3px 0 rgba(0,0,0,.35); }
#hudRole { top: 12px; left: 12px; min-width: 170px; }
#hudRole .role { font-weight: bold; }
#hudRole .timer { font: bold 28px/1.1 var(--font); font-variant-numeric: tabular-nums; }
#hudRole .timer.low { color: #c00000; }
#hudRole .sub { font-size: 12px; color: #404040; }
#hudPlayers { top: 12px; right: 12px; min-width: 150px; max-width: 220px; font-size: 12px; }
#hudPlayers div { display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hudPlayers img { width: 18px; height: 12px; object-fit: contain; flex: none; }
#hudPlayers .out { color: var(--lo); text-decoration: line-through; }
#hudPlayers .me { font-weight: bold; }

#stamina { position: absolute; left: 12px; bottom: 40px; width: 160px; height: 16px; background: #fff;
  border: 2px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo); }
#staminaFill { height: 100%; width: 100%; background: repeating-linear-gradient(90deg, var(--select) 0 8px, transparent 8px 10px); }
#stamina span { position: absolute; right: -36px; top: -1px; color: #fff; font-size: 11px; font-weight: bold; text-shadow: 1px 1px 0 #000; }

#crosshair { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: rgba(255,255,0,.85); box-shadow: 0 0 0 1px #000; display: none; }
body.seeker #crosshair { display: block; }

#toasts { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast { background: rgba(0,0,0,.6); color: #fff; padding: 6px 14px; font-weight: bold; font-size: 16px; text-shadow: 1px 1px 0 #000; animation: toast 3s forwards; white-space: nowrap; }
.toast.big { font-size: 28px; background: none; color: #ffff00; text-shadow: 2px 2px 0 #000080, -1px -1px 0 #000; }
@keyframes toast { 0% { opacity: 0; transform: scale(.9); } 8% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }

#hint { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; color: #fff; font-size: 12px; text-shadow: 1px 1px 0 #000; opacity: .85; }
body:not(.seeker) #catchHint { display: none; }
#lockHint { position: absolute; left: 50%; top: 60%; transform: translateX(-50%); color: #fff; background: rgba(0,0,128,.75); padding: 4px 10px; font-size: 12px; }
body.locked #lockHint, body.touch #lockHint, body.touch #hint { display: none; }

#map { position: absolute; right: 12px; bottom: 40px; width: 220px; height: 220px; background: rgba(0,0,0,.6); border: 2px solid; border-color: var(--hi) var(--dk) var(--dk) var(--hi); }

#touchStick { position: absolute; width: 120px; height: 120px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); background: rgba(255,255,255,.08); transform: translate(-50%, -50%); }
#touchKnob { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%; background: rgba(255,255,255,.45); }

@media (max-width: 700px) {
  .lobby { grid-template-columns: 1fr; }
  .lobby > * { grid-column: 1 / -1; }
  .hero-rat { width: 80px; }
  #hudRole { min-width: 0; padding: 4px 8px; }
  #hudRole .timer { font-size: 22px; }
  #hudPlayers { display: none; }
  .blind-count { font-size: 80px; }
}
