:root {
  --bg: #14141c;
  --panel: #1f1f2b;
  --panel-2: #2a2a3a;
  --text: #f1f1f6;
  --muted: #9a9ab0;
  --accent: #ffb703;
  --accent-ink: #1b1300;
  --danger: #ff6b6b;
  --radius: 12px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 50% 0%, #23233a, var(--bg) 60%) fixed;
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#app {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

[hidden] {
  display: none !important;
}

.screen {
  width: 100%;
}

.card {
  max-width: 420px;
  margin-top: 8vh;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.logo {
  margin: 0;
  text-align: center;
  font-size: 44px;
  letter-spacing: 6px;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 3px 3px 0 #b34700;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.error {
  color: var(--danger);
  margin: 0;
}

a {
  color: var(--accent);
}

input,
button,
select {
  font: inherit;
  border-radius: 10px;
  border: 0;
  padding: 11px 14px;
}

input {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  outline: 2px solid transparent;
}

select {
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  border: 0;
  padding: 9px 12px;
}

input:focus {
  outline-color: var(--accent);
}

button {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  filter: brightness(1.08);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button.big {
  padding: 14px;
  font-size: 18px;
}

button.ghost {
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
  padding: 8px 12px;
}

form,
.row {
  display: flex;
  gap: 8px;
}

#login-form {
  flex-direction: column;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 14px;
}

#home-code {
  text-transform: uppercase;
  letter-spacing: 3px;
  font-weight: 700;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--panel-2);
}

.help summary {
  cursor: pointer;
  color: var(--muted);
}

.help p {
  color: var(--muted);
  font-size: 14px;
}

.room-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.room-code b {
  letter-spacing: 3px;
  color: var(--accent);
  font-size: 20px;
}

.spacer {
  flex: 1;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 20px;
}

.timer.danger {
  color: var(--danger);
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.pcard {
  background: var(--panel);
  border-radius: 10px;
  padding: 8px 10px;
  border-left: 6px solid var(--c);
  min-width: 0;
}

.pcard.empty {
  opacity: 0.35;
  border-left-color: var(--panel-2);
}

.pcard.dead {
  opacity: 0.55;
}

.pcard .name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pcard .stats {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.pcard .wins {
  color: var(--accent);
  letter-spacing: 2px;
}

.stage {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}

canvas {
  display: block;
  /* Scale the 480x416 arena up as far as the window allows, keeping its shape. */
  width: min(100%, calc((100vh - 190px) * 15 / 13));
  height: auto;
  aspect-ratio: 15 / 13;
  border-radius: 8px;
  image-rendering: pixelated;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-size: clamp(28px, 7vw, 64px);
  font-weight: 900;
  text-align: center;
  color: #fff;
  text-shadow:
    0 4px 0 #000,
    0 0 30px rgba(0, 0, 0, 0.8);
}

.lobby {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, 90%);
  background: rgba(20, 20, 28, 0.94);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.lobby h2 {
  margin: 0;
}

.lobby ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lobby li {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border-radius: 8px;
  padding: 8px 10px;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid rgba(255, 255, 255, 0.3);
  flex: none;
}

.tag {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}

.status {
  text-align: center;
  color: var(--muted);
}

.touch {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.dpad {
  display: grid;
  grid-template-areas:
    ". up ."
    "left . right"
    ". down .";
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  gap: 4px;
}

.dpad button,
.bomb-btn {
  background: var(--panel-2);
  color: var(--text);
  font-size: 22px;
  padding: 0;
  touch-action: none;
}

.dpad .up {
  grid-area: up;
}
.dpad .down {
  grid-area: down;
}
.dpad .left {
  grid-area: left;
}
.dpad .right {
  grid-area: right;
}

.dpad button.on,
.bomb-btn.on {
  background: var(--accent);
}

.bomb-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  font-size: 40px;
}

.credits {
  margin-top: auto;
  padding-top: 20px;
  font-size: 13px;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--panel-2);
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

@media (max-width: 640px) {
  .hud {
    grid-template-columns: repeat(2, 1fr);
  }
  #room-copy {
    order: 10;
    width: 100%;
  }
}

.overlay small {
  font-size: 0.45em;
  background: rgba(0, 0, 0, 0.45);
  padding: 8px 16px;
  border-radius: 10px;
}

.lobby li .remove {
  margin-left: 6px;
  padding: 2px 8px;
  font-size: 13px;
  background: transparent;
  color: var(--muted);
}

.lobby li .remove:hover {
  color: var(--danger);
}

/* ---------- Room layout with the chat panel ---------- */

#app:has(#screen-room:not([hidden])) {
  max-width: 1240px;
}

#screen-room {
  display: flex;
  flex-direction: column;
}

.play-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
  align-items: start;
}

.chat {
  background: var(--panel);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  height: min(calc(100vh - 190px), 624px);
  min-height: 240px;
}

.chat-log {
  list-style: none;
  margin: 0;
  padding: 10px 12px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.chat-log .who {
  font-weight: 700;
  color: var(--c);
  margin-right: 6px;
}

.chat-log .who.dark {
  color: #b7b7c9;
}

.chat-log .notice {
  color: var(--muted);
  font-style: italic;
  font-size: 13px;
}

.chat-log .empty {
  color: var(--muted);
  margin: auto;
  text-align: center;
}

.chat-form {
  padding: 8px;
  border-top: 1px solid var(--panel-2);
}

.chat-form input {
  padding: 9px 12px;
}

@media (max-width: 900px) {
  .play-area {
    display: contents;
  }
  .chat {
    order: 1;
    height: 220px;
    min-height: 0;
    margin-top: 12px;
  }
  .status {
    order: 2;
  }
}

/* ---------- Bombermaaan look ---------- */

.ico {
  display: inline-block;
  width: 16px;
  height: 16px;
  vertical-align: -3px;
  margin: 0 2px 0 4px;
  background: url(/gfx/arena_item.png) no-repeat;
  background-size: 330.5px 17px;
  image-rendering: pixelated;
  border-radius: 3px;
}

.action-btns {
  display: flex;
  align-items: center;
  gap: 14px;
}

.b-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--text);
  font-size: 22px;
  padding: 0;
  touch-action: none;
}

.b-btn.on {
  background: var(--accent);
}

.help p + p {
  margin-top: 6px;
}

/* Seat colours and item icons as classes: the site CSP blocks inline style attributes. */
.seat0 {
  --c: #f4f4f8;
}
.seat1 {
  --c: #55556a;
}
.seat2 {
  --c: #e63946;
}
.seat3 {
  --c: #3d8bfd;
}
.ico.i0 {
  background-position: -0.5px -0.5px;
}
.ico.i1 {
  background-position: -33.5px -0.5px;
}
.ico.i2 {
  background-position: -66.5px -0.5px;
}
.ico.i3 {
  background-position: -99.5px -0.5px;
}
.ico.i4 {
  background-position: -132.5px -0.5px;
}
.ico.i5 {
  background-position: -165.5px -0.5px;
}
.ico.i6 {
  background-position: -198.5px -0.5px;
}
.ico.i7 {
  background-position: -231.5px -0.5px;
}
.ico.i8 {
  background-position: -264.5px -0.5px;
}
.ico.i9 {
  background-position: -297.5px -0.5px;
}
