/* Визуальный язык взят с harrypotterobamasonic10inu.xyz: жёсткие рамки,
   смещённые тени без размытия, нулевые скругления, Space Mono для интерфейса
   и Inter для заголовков. Отличие одно — фон остаётся тёмным, поэтому обводки
   светлые, а роль «бумаги» играет тёмная панель. */

:root {
  --bg: #0b0d14;
  --panel: #241e20;
  --panel-deep: #14100f;

  --yellow: #ffeb01;
  --blue: #1555ea;
  --red: #ed1c22;
  --green: #1bc508;
  --cream: #fefce1;

  --text: var(--cream);
  --muted: #9a9186;
  --stroke: #000000;
  --stroke-light: var(--cream);

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Space Mono', ui-monospace, 'Courier New', monospace;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: calc(env(safe-area-inset-top) + 12px) calc(env(safe-area-inset-right) + 12px)
           calc(env(safe-area-inset-bottom) + 12px) calc(env(safe-area-inset-left) + 12px);
}

#stats {
  position: absolute;
  left: calc(env(safe-area-inset-left) + 12px);
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  display: flex;
  gap: 16px;
  background: var(--panel);
  border: 3px solid var(--stroke-light);
  box-shadow: 5px 5px 0 var(--blue);
  padding: 10px 14px;
  font-variant-numeric: tabular-nums;
}

.stat { display: flex; flex-direction: column; gap: 3px; min-width: 56px; }

.stat .label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--yellow);
}

.stat span:last-child {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
}

#room-board {
  position: absolute;
  right: calc(env(safe-area-inset-right) + 12px);
  top: calc(env(safe-area-inset-top) + 12px);
  width: 200px;
  background: var(--panel);
  border: 3px solid var(--stroke-light);
  box-shadow: 5px 5px 0 var(--red);
  padding: 10px 12px;
}

.board-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--yellow);
  border-bottom: 2px solid var(--stroke-light);
  padding-bottom: 6px;
  margin-bottom: 8px;
}

#room-list, #global-list, #death-global-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 13px;
}

#room-list li, #global-list li, #death-global-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(254, 252, 225, 0.12);
}

#room-list li:last-child, #global-list li:last-child, #death-global-list li:last-child {
  border-bottom: none;
}

#room-list li.me, #global-list li.me, #death-global-list li.me {
  color: var(--yellow);
  font-weight: 700;
}

/* Первое место — единственная строка, которую видно с одного взгляда. */
#global-list li:first-child, #death-global-list li:first-child, #room-list li:first-child {
  color: var(--yellow);
}

.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.value { color: var(--muted); font-variant-numeric: tabular-nums; }
li.empty { color: var(--muted); justify-content: center; text-transform: uppercase; letter-spacing: 0.1em; }

#minimap {
  position: absolute;
  right: calc(env(safe-area-inset-right) + 12px);
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  width: 120px;
  height: 120px;
  background: var(--panel);
  border: 3px solid var(--stroke-light);
  box-shadow: 5px 5px 0 var(--green);
}

/* Кнопки живут над оверлеями: звук нужен и в меню, поэтому кластер вынесен
   из #hud, а «Выйти» прячется, когда игра не идёт. */
#top-left {
  position: fixed;
  left: calc(env(safe-area-inset-left) + 12px);
  top: calc(env(safe-area-inset-top) + 12px);
  display: flex;
  gap: 8px;
  z-index: 20;
}

#leave, .sound-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  height: 34px;
  padding: 0 14px;
  border: 3px solid var(--stroke-light);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--stroke);
  transition: all 0.16s var(--ease-out);
}

#leave:hover, .sound-btn:hover {
  background: var(--yellow);
  color: var(--stroke);
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--stroke);
}

.sound-btn.off { color: var(--muted); }

/* Микрофон включён — кнопка залита, состояние видно боковым зрением. */
#mic.live {
  background: var(--yellow);
  color: var(--stroke);
}

#mic.blocked {
  color: var(--muted);
  border-color: var(--muted);
  cursor: not-allowed;
}

/* Значок динамика у ника в списке комнаты. Рисуем формой, а не иконочным
   шрифтом: тянуть целый шрифт ради одного символа не за чем. */
.talk {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  background: var(--yellow);
  clip-path: polygon(0 30%, 35% 30%, 70% 0, 70% 100%, 35% 70%, 0 70%);
}

#touch-controls {
  position: absolute;
  right: calc(env(safe-area-inset-right) + 12px);
  bottom: calc(env(safe-area-inset-bottom) + 148px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: auto;
}

#touch-controls button {
  width: 96px;
  height: 46px;
  border: 3px solid var(--stroke);
  background: var(--yellow);
  color: var(--stroke);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  box-shadow: 4px 4px 0 var(--red);
  transition: all 0.16s var(--ease-out);
}

#touch-controls button:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--red);
}

/* ---------- оверлеи ---------- */

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    linear-gradient(rgba(254, 252, 225, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(254, 252, 225, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 50% 38%, rgba(255, 235, 1, 0.07), rgba(6, 8, 13, 0.96) 62%);
  background-size: 40px 40px, 40px 40px, cover;
  overflow-y: auto;
  z-index: 10;
  animation: fadeIn 0.35s var(--ease-out);
}

.panel {
  width: min(430px, 100%);
  background: var(--panel);
  border: 4px solid var(--stroke-light);
  box-shadow: 10px 10px 0 var(--red);
  padding: 28px 24px;
  text-align: center;
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.panel h1 {
  margin: 0 0 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: clamp(20px, 6.4vw, 30px);
  font-weight: 900;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  animation: fadeInDown 0.6s var(--ease-out) 0.05s both;
}

.panel h1 span {
  background: var(--blue);
  color: var(--cream);
  padding: 2px 10px;
  border: 4px solid var(--stroke);
  box-shadow: 5px 5px 0 var(--red);
  transform: rotate(-2deg);
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 900;
  text-transform: uppercase;
  display: inline-block;
  background: var(--red);
  color: var(--cream);
  padding: 6px 16px;
  border: 4px solid var(--stroke);
  box-shadow: 5px 5px 0 var(--yellow);
  transform: rotate(-1deg);
}

.tagline {
  margin: 6px 0 22px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  animation: fadeInUp 0.6s var(--ease-out) 0.15s both;
}

.killer {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 14px 0 16px;
  min-height: 18px;
}

#join-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeInUp 0.6s var(--ease-out) 0.25s both;
}

#nick {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  background: var(--panel-deep);
  border: 3px solid var(--stroke-light);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 16px;
  text-align: center;
  letter-spacing: 0.06em;
  transition: all 0.16s var(--ease-out);
}

#nick::placeholder { color: var(--muted); text-transform: uppercase; font-size: 13px; }

#nick:focus {
  outline: none;
  border-color: var(--yellow);
  box-shadow: 4px 4px 0 var(--yellow);
}

#play, #respawn, #summary-again {
  width: 100%;
  height: 54px;
  border: 4px solid var(--stroke);
  background: var(--yellow);
  color: var(--stroke);
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 6px 6px 0 var(--red);
  transition: all 0.16s var(--ease-out);
}

#play:hover, #respawn:hover, #summary-again:hover {
  transform: translate(3px, 3px);
  box-shadow: 3px 3px 0 var(--red);
}

#play:active, #respawn:active, #summary-again:active { transform: translate(5px, 5px); box-shadow: 1px 1px 0 var(--red); }
#play:disabled { opacity: 0.45; cursor: default; transform: none; box-shadow: 6px 6px 0 var(--red); }

#to-menu, #summary-menu {
  width: 100%;
  height: 46px;
  margin-top: 12px;
  border: 3px solid var(--stroke-light);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.16s var(--ease-out);
}

#to-menu:hover, #summary-menu:hover { background: var(--cream); color: var(--stroke); }

.share {
  margin-top: 20px;
  border-top: 3px solid var(--stroke-light);
  padding-top: 14px;
}

.share .board-title { text-align: left; }

.share-row { display: flex; gap: 10px; }

.share-row button {
  flex: 1;
  height: 44px;
  padding: 0 6px;
  border: 3px solid var(--stroke);
  background: var(--cream);
  color: var(--stroke);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.16s var(--ease-out);
}

.share-x { box-shadow: 4px 4px 0 var(--yellow); }
.share-tg { box-shadow: 4px 4px 0 var(--blue); }

.share-x:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--yellow); }
.share-tg:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--blue); }

.online {
  margin: 16px 0 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.online strong { color: var(--green); font-size: 14px; }

.status {
  min-height: 18px;
  margin: 12px 0 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.status.error { color: var(--red); }

.global-board {
  margin-top: 20px;
  text-align: left;
  border-top: 3px solid var(--stroke-light);
  padding-top: 14px;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--yellow) transparent;
}

.global-board::-webkit-scrollbar { width: 8px; }
.global-board::-webkit-scrollbar-thumb { background: var(--yellow); }

.final {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 18px 0;
}

.final div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  border: 3px solid var(--stroke-light);
  box-shadow: 4px 4px 0 var(--blue);
}

.final div:nth-child(2) { box-shadow: 4px 4px 0 var(--green); }

.final .label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--yellow);
}

.final strong { font-family: var(--font-mono); font-size: 22px; }

.hint {
  margin: 18px 0 0;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.7;
}

/* ---------- анимации ---------- */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
}

@media (max-width: 520px) {
  #room-board { width: 154px; font-size: 11px; padding: 8px 10px; }
  #minimap { width: 88px; height: 88px; }
  #touch-controls { bottom: calc(env(safe-area-inset-bottom) + 112px); }
  #stats { gap: 10px; padding: 8px 10px; }
  .stat { min-width: 46px; }
  .panel { padding: 22px 16px; box-shadow: 7px 7px 0 var(--red); }
  .final { gap: 12px; }
}
