@font-face {
  font-family: 'Press Start 2P';
  src: url('fonts/PressStart2P-Regular.ttf') format('truetype');
  font-display: block;
}
@font-face {
  font-family: 'VT323';
  src: url('fonts/VT323-Regular.ttf') format('truetype');
  font-display: block;
}

:root {
  --bg: #181425;
  --panel: #262b44;
  --panel2: #3a4466;
  --panel3: #5a6988;
  --line: #0d0b14;
  --text: #ead4aa;
  --muted: #8b9bb4;
  --wine: #a22633;
  --red: #e43b44;
  --gold: #feae34;
  --yellow: #fee761;
  --green: #63c74d;
  --blue: #0099db;
  --px: 4px;
  --head: 'Press Start 2P', monospace;
  --body: 'VT323', monospace;
  --pixel-border: calc(-1 * var(--px)) 0 0 0 var(--line), var(--px) 0 0 0 var(--line),
    0 calc(-1 * var(--px)) 0 0 var(--line), 0 var(--px) 0 0 var(--line);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 22px;
  line-height: 1.15;
  -webkit-font-smoothing: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body.in-game {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

h1,
h2,
h3 {
  font-family: var(--head);
  font-weight: normal;
  margin: 0 0 16px;
  line-height: 1.4;
}
h2 {
  font-size: 18px;
  color: var(--yellow);
}
h3 {
  font-size: 12px;
  color: var(--gold);
  margin-top: 8px;
}
p {
  margin: 0 0 12px;
}
b {
  color: var(--yellow);
  font-weight: normal;
}

/* ───────── Canvas ───────── */

#screen {
  position: fixed;
  left: 0;
  top: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transform-origin: 0 0;
}
#overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ───────── Screens ───────── */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(72px, calc(env(safe-area-inset-bottom) + 56px)) max(16px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at center, rgba(24, 20, 37, 0.55), rgba(24, 20, 37, 0.9));
}
.screen.active {
  display: flex;
}
.screen > *,
.screen > .panel {
  margin: auto;
}
.screen.hud {
  display: none;
  background: none;
  pointer-events: none;
  overflow: hidden;
  padding: 0;
}
.screen.hud.active {
  display: block;
}

/* ───────── Panels & Buttons ───────── */

.panel {
  background: var(--panel);
  padding: 20px;
  margin: var(--px);
  box-shadow: var(--pixel-border), inset 0 var(--px) 0 0 rgba(255, 255, 255, 0.07),
    inset 0 calc(-1 * var(--px)) 0 0 rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 560px;
}
.panel.wide {
  max-width: 1040px;
}
.panel-lite {
  background: rgba(24, 20, 37, 0.82);
  box-shadow: var(--pixel-border);
  padding: 8px 10px;
}

.btn {
  font-family: var(--head);
  font-size: 12px;
  line-height: 1.3;
  color: var(--text);
  background: var(--panel2);
  border: 0;
  padding: 14px 18px;
  margin: var(--px);
  cursor: pointer;
  box-shadow: var(--pixel-border), inset calc(-1 * var(--px)) calc(-1 * var(--px)) 0 0 rgba(0, 0, 0, 0.3),
    inset var(--px) var(--px) 0 0 rgba(255, 255, 255, 0.12);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.btn:hover:not(:disabled) {
  background: var(--panel3);
}
.btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: var(--pixel-border), inset var(--px) var(--px) 0 0 rgba(0, 0, 0, 0.3);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn:focus-visible,
.icon-btn:focus-visible,
.tab:focus-visible,
.seg button:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 6px;
}
.btn-primary {
  background: var(--red);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: #f0525a;
}
.btn-small {
  font-size: 10px;
  padding: 10px 12px;
}
.btn.on {
  background: var(--green);
  color: var(--line);
}

.icon-btn {
  font-family: var(--head);
  font-size: 14px;
  width: 40px;
  height: 40px;
  padding: 8px;
  margin: var(--px);
  border: 0;
  color: var(--text);
  background: var(--panel2);
  box-shadow: var(--pixel-border);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}
.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}
.icon-btn svg .slash {
  display: none;
  fill: var(--red);
}
.icon-btn.off svg .slash {
  display: inline;
}
.icon-btn.off {
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field span,
.label {
  font-family: var(--head);
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
}
input {
  font-family: var(--body);
  font-size: 24px;
  color: var(--text);
  background: var(--bg);
  border: 0;
  padding: 6px 10px;
  margin: var(--px);
  box-shadow: var(--pixel-border), inset var(--px) var(--px) 0 0 rgba(0, 0, 0, 0.4);
  outline: none;
  min-width: 0;
}
input:focus {
  background: #0f0c1a;
  box-shadow: calc(-1 * var(--px)) 0 0 0 var(--gold), var(--px) 0 0 0 var(--gold), 0 calc(-1 * var(--px)) 0 0 var(--gold),
    0 var(--px) 0 0 var(--gold);
}
input::placeholder {
  color: var(--panel3);
}

.bar {
  position: relative;
  height: 12px;
  background: var(--bg);
  box-shadow: var(--pixel-border);
  margin: 8px 4px 4px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  background: var(--gold);
  transition: width 0.3s steps(8);
}

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.seg button {
  font-family: var(--head);
  font-size: 9px;
  color: var(--text);
  background: var(--panel2);
  border: 0;
  padding: 8px 10px;
  margin: var(--px);
  box-shadow: var(--pixel-border);
  cursor: pointer;
}
.seg button.active {
  background: var(--gold);
  color: var(--line);
}
.seg button:disabled {
  cursor: default;
}
.seg button:disabled:not(.active) {
  opacity: 0.5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}
.hint {
  color: var(--muted);
  font-size: 20px;
}

/* ───────── Titel ───────── */

.title-wrap {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
}
.logo {
  text-align: center;
  font-size: clamp(30px, 8.5vw, 60px);
  line-height: 1.1;
  margin: 12px 0 0;
  color: var(--yellow);
  text-shadow: 4px 4px 0 var(--wine), 8px 8px 0 var(--line);
  letter-spacing: 2px;
  animation: bob 2.4s steps(6) infinite;
}
.logo span {
  display: block;
}
.logo-sub {
  color: #fff;
  font-size: 0.62em;
  letter-spacing: 0.4em;
  margin-top: 8px;
  text-shadow: 3px 3px 0 var(--blue), 6px 6px 0 var(--line);
}
@keyframes bob {
  50% {
    transform: translateY(-4px) rotate(-1deg);
  }
}
.ios-hint {
  text-align: center;
  font-size: 18px;
  color: var(--text);
  background: rgba(24, 20, 37, 0.85);
  padding: 8px 12px;
  margin: 0 var(--px);
  box-shadow: var(--pixel-border);
}
.ios-hint[hidden] {
  display: none;
}
.tagline {
  text-align: center;
  color: var(--text);
  text-shadow: 2px 2px 0 var(--line);
  margin: 0;
}
.title-items {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 6px;
}
.title-items canvas {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  filter: drop-shadow(3px 3px 0 rgba(13, 11, 20, 0.6));
  animation: hop 1.6s steps(4) infinite;
}
.title-items canvas:nth-child(2) {
  animation-delay: 0.2s;
}
.title-items canvas:nth-child(4) {
  animation-delay: 0.4s;
}
.title-items canvas:nth-child(5) {
  animation-delay: 0.6s;
}
.title-items canvas:nth-child(6) {
  animation-delay: 0.8s;
}
.title-items .sep {
  width: 4px;
  height: 32px;
  margin: 0 10px 8px;
  background: var(--panel3);
}
@keyframes hop {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-6px);
  }
}

.profile {
  display: flex;
  gap: 16px;
  align-items: center;
}
.profile-char {
  display: flex;
  align-items: center;
}
#char-preview {
  width: 96px;
  height: 96px;
  image-rendering: pixelated;
  background: radial-gradient(ellipse at 50% 85%, rgba(0, 0, 0, 0.35) 0 25%, transparent 26%), var(--panel2);
  box-shadow: var(--pixel-border);
  margin: var(--px);
}
.profile-fields {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.char-name {
  font-family: var(--head);
  font-size: 10px;
  color: var(--gold);
  margin-top: 4px;
}
.rank-box {
  margin-top: 4px;
}
.rank-title {
  font-family: var(--head);
  font-size: 10px;
  color: var(--yellow);
}
.rank-meta {
  font-size: 18px;
  color: var(--muted);
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menu .btn {
  width: calc(100% - 2 * var(--px));
}
.menu-row {
  display: flex;
  gap: 8px;
}
.menu-row .btn {
  flex: 1;
}

/* ───────── Räume ───────── */

.code-form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
#code-input {
  width: 160px;
  font-size: 34px;
  text-transform: uppercase;
  letter-spacing: 6px;
}
.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
}
.list-head h3 {
  margin: 0;
}
.room-list,
.player-list,
.chat-log,
.feed,
.awards,
.item-help {
  list-style: none;
  margin: 0;
  padding: 0;
}
.room-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.room-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel2);
  padding: 6px 6px 6px 14px;
  margin: var(--px);
  box-shadow: var(--pixel-border);
}
.room-list .code {
  font-family: var(--head);
  font-size: 14px;
  color: var(--yellow);
}
.room-list .meta {
  flex: 1;
  color: var(--text);
}
.room-list .empty {
  justify-content: center;
  color: var(--muted);
  padding: 16px;
}

/* ───────── Lobby ───────── */

.lobby-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}
.room-code {
  font-family: var(--head);
  font-size: 32px;
  color: var(--yellow);
  letter-spacing: 8px;
  text-shadow: 3px 3px 0 var(--wine);
  user-select: all;
}
.lobby-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap: 20px;
}
.lobby-col {
  min-width: 0;
}
.player-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.player-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel2);
  padding: 4px 8px;
  margin: var(--px);
  box-shadow: var(--pixel-border);
  border-left: 6px solid var(--c, var(--muted));
}
.player-list li.offline {
  opacity: 0.5;
}
.player-list canvas {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  flex: none;
}
.player-list .who {
  flex: 1;
  min-width: 0;
}
.player-list .pname {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
}
.player-list .prank {
  display: block;
  font-size: 17px;
  color: var(--muted);
}
.badge {
  font-family: var(--head);
  font-size: 8px;
  padding: 4px 6px;
  background: var(--bg);
  color: var(--muted);
  white-space: nowrap;
}
.badge.ready {
  background: var(--green);
  color: var(--line);
}
.badge.host {
  background: var(--gold);
  color: var(--line);
}
.kick {
  font-family: var(--head);
  font-size: 10px;
  background: var(--wine);
  color: #fff;
  border: 0;
  padding: 6px 8px;
  cursor: pointer;
}
.settings .setting {
  margin-bottom: 12px;
}
.settings .setting > span {
  display: block;
  font-family: var(--head);
  font-size: 9px;
  color: var(--muted);
  margin-bottom: 4px;
}
.map-preview {
  width: 100%;
  image-rendering: pixelated;
  box-shadow: var(--pixel-border);
  margin: var(--px) 0 4px;
  display: block;
  background: var(--bg);
}
.map-sub {
  color: var(--muted);
  font-size: 18px;
  margin-bottom: 12px;
}
.chat-col {
  display: flex;
  flex-direction: column;
  min-height: 280px;
}
.chat-log {
  flex: 1;
  background: var(--bg);
  box-shadow: var(--pixel-border);
  margin: var(--px);
  padding: 8px;
  overflow-y: auto;
  max-height: 320px;
  min-height: 160px;
  font-size: 20px;
  word-wrap: break-word;
}
.chat-log li {
  margin-bottom: 4px;
}
.chat-log .sys {
  color: var(--muted);
  font-style: italic;
}
.chat-log .from {
  color: var(--c, var(--gold));
}
.chat-form {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.chat-form input {
  flex: 1;
  font-size: 20px;
}
.name-form {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  margin-bottom: 10px;
}
.name-form .field {
  flex: 1;
  min-width: 0;
}
.name-form input {
  width: 100%;
  font-size: 22px;
}

/* ───────── HUD ───────── */

.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0
    max(10px, env(safe-area-inset-left));
  gap: 10px;
}
.hud-left,
.hud-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 220px;
}
.hud-right {
  align-items: flex-end;
}
.hud-left {
  position: relative;
}
.hud-menu {
  pointer-events: auto;
  position: absolute;
  left: 0;
  top: 0;
}
.pegel {
  margin: 4px 4px 4px 56px;
}
.pegel-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
}
.pegel-label {
  font-family: var(--head);
  font-size: 8px;
  color: var(--muted);
  text-transform: uppercase;
}
.pegel-value {
  font-family: var(--head);
  font-size: 13px;
  color: #fff;
  white-space: nowrap;
}
.pegel-name {
  font-size: 18px;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pegel-bar {
  height: 10px;
  margin: 6px 0 2px;
}
.pegel-bar .bar-fill {
  transition: width 0.25s linear, background 0.25s;
}
.bar-mark {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 94%;
  width: 2px;
  background: #fff;
  opacity: 0.6;
}
.pegel.warn {
  animation: warn 0.5s steps(2) infinite;
}
@keyframes warn {
  50% {
    background: rgba(162, 38, 51, 0.85);
  }
}
.feed {
  font-size: 18px;
  text-shadow: 2px 2px 0 var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.feed li {
  animation: fade 4s forwards;
}
@keyframes fade {
  0%,
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.timer {
  font-family: var(--head);
  font-size: 18px;
  color: #fff;
  min-width: 110px;
  text-align: center;
  margin: 4px;
}
.timer.urgent {
  color: var(--red);
  animation: warn 1s steps(2) infinite;
}
.score-line {
  font-family: var(--head);
  font-size: 10px;
  color: var(--yellow);
  text-shadow: 2px 2px 0 var(--line);
}
.mini-rank {
  list-style: none;
  margin: 4px;
  width: 200px;
  font-size: 19px;
}
.mini-rank li {
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}
.mini-rank .dot {
  width: 10px;
  height: 10px;
  flex: none;
  background: var(--c);
  box-shadow: 0 0 0 2px var(--line);
}
.mini-rank .n {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-rank .me {
  color: var(--yellow);
}
.mini-rank .pts {
  font-family: var(--head);
  font-size: 10px;
}
.minimap {
  image-rendering: pixelated;
  box-shadow: var(--pixel-border);
  margin: 4px;
  opacity: 0.9;
}

.toast,
.zone-toast,
.countdown {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-family: var(--head);
  pointer-events: none;
  white-space: nowrap;
}
.toast {
  top: 30%;
  font-size: clamp(14px, 3.4vw, 24px);
  color: var(--yellow);
  text-shadow: 3px 3px 0 var(--wine), 5px 5px 0 var(--line);
  opacity: 0;
}
.toast.show {
  animation: pop 2.2s forwards;
}
@keyframes pop {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.6);
  }
  10% {
    opacity: 1;
    transform: translateX(-50%) scale(1.1);
  }
  18%,
  80% {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) scale(1);
  }
}
/* ───────── Schobbegewitter ───────── */

.gewitter {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
  overflow: hidden;
  z-index: 4;
}
.gewitter.show {
  display: block;
}
.gewitter-flash {
  position: absolute;
  inset: 0;
  background: #fff7c2;
  opacity: 0;
}
.gewitter.show .gewitter-flash {
  /* zwei gedämpfte Blitze, deutlich unter der Grenze für Lichtempfindliche */
  animation: gw-flash 0.8s steps(1) forwards;
}
@keyframes gw-flash {
  0% {
    opacity: 0.45;
  }
  10% {
    opacity: 0;
  }
  35% {
    opacity: 0.3;
  }
  45%,
  100% {
    opacity: 0;
  }
}
.gewitter .bolt {
  position: absolute;
  top: 6%;
  width: clamp(48px, 9vw, 110px);
  fill: var(--yellow);
  filter: drop-shadow(0 0 10px #fff) drop-shadow(4px 4px 0 var(--wine));
  opacity: 0;
}
.gewitter .bolt-l {
  left: 8%;
  transform: rotate(-12deg);
}
.gewitter .bolt-r {
  right: 8%;
  transform: scaleX(-1) rotate(-12deg);
}
.gewitter.show .bolt {
  animation: gw-bolt 2.4s steps(1) forwards;
}
.gewitter.show .bolt-r {
  animation-delay: 0.12s;
}
@keyframes gw-bolt {
  0%,
  8%,
  18%,
  30% {
    opacity: 1;
  }
  5%,
  14%,
  24% {
    opacity: 0.2;
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
.gewitter-text {
  position: absolute;
  left: 50%;
  top: 20%;
  transform: translateX(-50%) rotate(-5deg);
  text-align: center;
  font-family: var(--head);
  line-height: 1.15;
  white-space: nowrap;
}
.gewitter.show .gewitter-text {
  animation: gw-shake 0.45s steps(3) 0.25s 3;
}
.gewitter-text .line {
  display: block;
}
.gewitter-text .l1 {
  font-size: clamp(18px, 5vw, 44px);
}
.gewitter-text .l2 {
  font-size: clamp(26px, 8.6vw, 80px);
}
.gewitter-text .l3 {
  margin-top: 0.4em;
  font-size: clamp(12px, 2.6vw, 22px);
  color: #2ce8f5;
  text-shadow: 2px 2px 0 var(--line);
  opacity: 0;
}
.gewitter.show .gewitter-text .l3 {
  animation: gw-letter 2.5s 0.75s both;
}
.gewitter-text .ch {
  display: inline-block;
  color: var(--yellow);
  text-shadow: 3px 3px 0 var(--red), 6px 6px 0 var(--line), 0 0 18px rgba(44, 232, 245, 0.9);
  opacity: 0;
}
.gewitter.show .gewitter-text .ch {
  animation: gw-letter 2.5s calc(var(--i) * 45ms) both, gw-color 0.3s steps(1) infinite;
}
@keyframes gw-letter {
  0% {
    opacity: 0;
    transform: translateY(-140px) scale(2.4);
  }
  12% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  17% {
    transform: translateY(-10px) scale(1.08);
  }
  22%,
  82% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(24px) scale(0.9);
  }
}
@keyframes gw-color {
  0% {
    color: var(--yellow);
  }
  33% {
    color: #fff;
  }
  66% {
    color: #2ce8f5;
  }
}
@keyframes gw-shake {
  0% {
    transform: translate(-50%, 0) rotate(-5deg);
  }
  33% {
    transform: translate(calc(-50% - 6px), 4px) rotate(-3deg);
  }
  66% {
    transform: translate(calc(-50% + 6px), -4px) rotate(-7deg);
  }
}
body.gw-shake #screen {
  animation: gw-screen 0.5s steps(4) 2;
}
@keyframes gw-screen {
  25% {
    translate: 4px -3px;
  }
  50% {
    translate: -4px 3px;
  }
  75% {
    translate: 3px 3px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .gewitter.show .gewitter-flash,
  body.gw-shake #screen {
    animation: none;
  }
}

.zone-toast {
  bottom: max(22%, 150px);
  font-size: 11px;
  color: #fff;
  background: rgba(24, 20, 37, 0.8);
  padding: 8px 12px;
  box-shadow: var(--pixel-border);
  opacity: 0;
}
.zone-toast.show {
  animation: fade-in-out 2.4s forwards;
}
@keyframes fade-in-out {
  0% {
    opacity: 0;
  }
  15%,
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
.countdown {
  top: 38%;
  font-size: clamp(40px, 12vw, 96px);
  color: #fff;
  text-shadow: 6px 6px 0 var(--wine), 10px 10px 0 var(--line);
}
.countdown.go {
  color: var(--yellow);
}
.countdown:empty {
  display: none;
}

.emotes {
  position: absolute;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  max-width: 320px;
  pointer-events: auto;
}
.emotes button {
  font-family: var(--head);
  font-size: 9px;
  color: var(--text);
  background: rgba(38, 43, 68, 0.9);
  border: 0;
  padding: 9px 8px;
  margin: var(--px);
  box-shadow: var(--pixel-border);
  cursor: pointer;
}
.emotes button:active {
  background: var(--gold);
  color: var(--line);
}
.emotes kbd {
  color: var(--muted);
  font-family: inherit;
  margin-right: 4px;
}

.joystick {
  position: absolute;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  display: none;
  pointer-events: none;
  background: rgba(234, 212, 170, 0.12);
  clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%);
}
.joystick.active {
  display: block;
}
.joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  background: rgba(254, 231, 97, 0.7);
  clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%);
}
.spectator {
  display: none;
  position: absolute;
  bottom: 18%;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--head);
  font-size: 10px;
  color: #fff;
  background: rgba(24, 20, 37, 0.85);
  padding: 10px 14px;
  box-shadow: var(--pixel-border);
}
.spectator.show {
  display: block;
}

/* ───────── Ergebnis ───────── */

.podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 12px;
  margin: 0 0 12px;
  min-height: 130px;
}
.podium .place {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 130px;
}
.podium canvas {
  width: 72px;
  height: 72px;
  image-rendering: pixelated;
}
.podium .pname {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
}
.podium .step {
  width: 100%;
  display: grid;
  place-items: center;
  font-family: var(--head);
  font-size: 22px;
  color: var(--line);
  box-shadow: var(--pixel-border);
  margin-top: 6px;
}
.podium .p1 .step {
  height: 58px;
  background: var(--yellow);
}
.podium .p2 .step {
  height: 40px;
  background: #c0cbdc;
}
.podium .p3 .step {
  height: 28px;
  background: #d77643;
}
.podium .pts {
  font-family: var(--head);
  font-size: 10px;
  color: var(--gold);
  margin-top: 2px;
}
.personal {
  text-align: center;
  margin-bottom: 12px;
}
.personal .line {
  display: block;
  font-family: var(--head);
  font-size: 10px;
  color: var(--yellow);
  line-height: 1.8;
}
.table-wrap {
  overflow-x: auto;
  margin: var(--px);
  box-shadow: var(--pixel-border);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 20px;
  background: var(--bg);
}
.table th {
  font-family: var(--head);
  font-size: 8px;
  color: var(--muted);
  font-weight: normal;
  text-align: right;
  padding: 10px 8px;
  background: var(--panel2);
  white-space: nowrap;
}
.table td {
  padding: 5px 8px;
  text-align: right;
  white-space: nowrap;
  border-top: 2px solid var(--panel);
}
.table th:nth-child(2),
.table td:nth-child(2) {
  text-align: left;
}
.table td:nth-child(2) {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.table tr.me td {
  background: rgba(254, 174, 52, 0.15);
  color: var(--yellow);
}
.table .empty {
  text-align: center;
  color: var(--muted);
  padding: 24px;
}
.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  background: var(--c);
}
.awards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 4px 8px;
}
.awards li {
  background: var(--panel2);
  padding: 6px 10px;
  margin: var(--px);
  box-shadow: var(--pixel-border);
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.awards .at {
  display: block;
  font-family: var(--head);
  font-size: 8px;
  color: var(--gold);
  margin-bottom: 3px;
}
.awards .aw {
  color: #fff;
}
.awards .ax {
  color: var(--muted);
}

/* ───────── Bestenliste & Hilfe ───────── */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}
.tab {
  font-family: var(--head);
  font-size: 10px;
  color: var(--muted);
  background: var(--panel2);
  border: 0;
  padding: 10px 12px;
  margin: var(--px);
  box-shadow: var(--pixel-border);
  cursor: pointer;
}
.tab.active {
  background: var(--red);
  color: #fff;
}
.board-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}
.board-filters.hidden {
  display: none;
}
.chips {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chips li {
  background: var(--bg);
  padding: 4px 10px;
  margin: var(--px);
  box-shadow: var(--pixel-border);
  border-left: 6px solid var(--c, var(--gold));
  font-size: 19px;
}
.chips b {
  font-family: var(--head);
  font-size: 8px;
  color: var(--muted);
}
#board-table tbody tr:nth-child(1) td:first-child {
  color: var(--yellow);
}
#board-table tbody tr:nth-child(2) td:first-child {
  color: #c0cbdc;
}
#board-table tbody tr:nth-child(3) td:first-child {
  color: #d77643;
}
.item-help {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.item-help li {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--panel2);
  padding: 6px 10px;
  margin: var(--px);
  box-shadow: var(--pixel-border);
}
.item-help canvas {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  flex: none;
}
.item-help .iname {
  display: block;
  font-family: var(--head);
  font-size: 9px;
  color: var(--yellow);
  margin-bottom: 4px;
}

/* ───────── Overlays ───────── */

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(13, 11, 20, 0.7);
  padding: 16px;
  z-index: 20;
}
.modal[hidden] {
  display: none;
}
.modal .panel {
  max-width: 400px;
  text-align: center;
}

.corner {
  position: fixed;
  left: max(8px, env(safe-area-inset-left));
  bottom: max(8px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 2px;
  z-index: 30;
}
body.in-game:not(.menu-open) .corner,
body.in-game .version {
  display: none;
}
.version {
  position: fixed;
  right: max(8px, env(safe-area-inset-right));
  bottom: max(6px, env(safe-area-inset-bottom));
  font-size: 12px;
  color: var(--muted);
  opacity: 0.7;
  pointer-events: none;
  z-index: 30;
}
.conn {
  width: 12px;
  height: 12px;
  margin: 0 8px;
  background: var(--muted);
  box-shadow: 0 0 0 3px var(--line);
}
.conn.open {
  background: var(--green);
}
.conn.closed {
  background: var(--red);
}

.notice {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  font-family: var(--head);
  font-size: 10px;
  line-height: 1.6;
  color: #fff;
  background: var(--wine);
  padding: 10px 14px;
  box-shadow: var(--pixel-border);
  max-width: calc(100vw - 32px);
  text-align: center;
  display: none;
}
.notice.show {
  display: block;
}
.notice.info {
  background: var(--panel2);
}

.rotate-hint {
  display: none;
  position: fixed;
  bottom: 30%;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--head);
  font-size: 9px;
  line-height: 1.6;
  text-align: center;
  color: #fff;
  background: rgba(24, 20, 37, 0.85);
  padding: 10px 14px;
  box-shadow: var(--pixel-border);
  width: max-content;
  max-width: 80vw;
  pointer-events: none;
  z-index: 5;
}
.rotate-hint.show {
  display: block;
}

/* ───────── Responsiv ───────── */

@media (max-width: 900px) {
  .lobby-grid {
    grid-template-columns: 1fr;
  }
  .panel.lobby {
    display: flex;
    flex-direction: column;
  }
  .lobby-head {
    order: -2;
  }
  .lobby .actions {
    order: -1;
    margin: 0 0 16px;
  }
  .lobby .actions .btn {
    flex: 1;
  }
  .chat-log {
    max-height: 200px;
  }
}

@media (max-height: 520px) {
  .minimap {
    display: none;
  }
  .feed {
    display: none;
  }
}

@media (max-width: 640px), (max-height: 520px) {
  body {
    font-size: 20px;
  }
  .panel {
    padding: 14px;
  }
  .corner .icon-btn {
    width: 34px;
    height: 34px;
    padding: 7px;
  }
  .hud-left,
  .hud-right {
    width: 160px;
  }
  .pegel {
    margin-left: 52px;
  }
  .pegel-value {
    font-size: 10px;
  }
  .pegel-name {
    font-size: 15px;
  }
  .timer {
    font-size: 13px;
    min-width: 80px;
  }
  .mini-rank {
    width: 150px;
    font-size: 16px;
  }
  .feed {
    font-size: 15px;
  }
  /* Ortshinweis klein am unteren Rand statt mitten im Bild (Sprüche sitzen rechts daneben) */
  .zone-toast {
    bottom: max(10px, env(safe-area-inset-bottom));
    font-size: 8px;
    padding: 5px 8px;
  }
  .emotes {
    max-width: 200px;
  }
  .emotes button {
    font-size: 8px;
    padding: 8px 6px;
  }
  .emotes kbd {
    display: none;
  }
  .profile {
    flex-direction: column;
  }
  .podium .place {
    width: 96px;
  }
}

@media (max-width: 480px) {
  .hud-left {
    width: 150px;
  }
  .hud-right {
    width: 116px;
  }
  .mini-rank {
    width: 112px;
  }
  .pegel {
    margin-left: 50px;
  }
  .pegel-label {
    display: none;
  }
}

.emotes .emote-toggle {
  display: none;
}

@media (hover: none) {
  .emotes kbd {
    display: none;
  }
}

@media (pointer: coarse) {
  .emotes .emote-toggle {
    display: inline-block;
    min-width: 40px;
  }
  .emotes:not(.open) .extra {
    display: none;
  }
  .emotes button {
    padding: 12px 10px;
  }
}
