:root {
  --bg: #120c09;
  --panel: rgba(28, 19, 14, 0.92);
  --panel-solid: #1f1510;
  --line: rgba(255, 220, 160, 0.16);
  --text: #f6ead6;
  --muted: #c2ab8c;
  --gold: #ffcf5a;
  --gold-dark: #2a1d05;
  --radius: 10px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed;
  inset: 0;
}

#game canvas {
  display: block;
}

[hidden] {
  display: none !important;
}

/* ---------- top bar ---------- */

#topbar {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

#topbar > * {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
}

#pub-name {
  font-weight: 700;
  color: var(--gold);
}

#status {
  color: #ffb4a0;
}

#rename {
  margin-left: auto;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* ---------- chat ---------- */

#chat {
  position: fixed;
  left: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  width: min(360px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#chat-log {
  list-style: none;
  margin: 0;
  padding: 0 4px;
  max-height: 30vh;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.35;
  text-shadow: 0 1px 2px #000;
  mask-image: linear-gradient(to bottom, transparent 0, #000 24px);
}

#chat-log li {
  padding: 1px 0;
  overflow-wrap: anywhere;
}

#chat-log b {
  color: var(--gold);
}

#chat-log li.mine b {
  color: #9fe0a8;
}

#chat-log li.notice {
  color: var(--muted);
  font-style: italic;
}

#chat-input {
  width: 100%;
  font: inherit;
  font-size: 16px; /* stops iOS zooming in */
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  outline: none;
}

#chat-input:focus {
  border-color: var(--gold);
}

/* ---------- prompt ---------- */

#prompt {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

kbd {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  background: var(--gold);
  color: var(--gold-dark);
  border-radius: 4px;
  padding: 0 5px;
  font-family: inherit;
  font-weight: 800;
}

/* ---------- touch pad ---------- */

#pad {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: 168px;
  height: 168px;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  gap: 4px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#pad button {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 18px;
  touch-action: none;
}

#pad [data-dir='up'] {
  grid-area: 1 / 2;
}
#pad [data-dir='left'] {
  grid-area: 2 / 1;
}
#pad [data-dir='right'] {
  grid-area: 2 / 3;
}
#pad [data-dir='down'] {
  grid-area: 3 / 2;
}
#pad .pad-a {
  grid-area: 2 / 2;
  border-radius: 50%;
  background: var(--gold);
  color: var(--gold-dark);
  font-weight: 800;
}

@media (pointer: coarse) {
  #chat {
    width: calc(100vw - 210px);
    min-width: 150px;
  }
  #prompt {
    bottom: calc(196px + env(safe-area-inset-bottom));
  }
}

/* ---------- panels ---------- */

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 16px;
}

.card {
  width: min(420px, 100%);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.card h2 {
  margin: 0 0 8px;
  font-size: 19px;
  color: var(--gold);
}

.card p {
  margin: 0 0 10px;
  color: var(--text);
  line-height: 1.45;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#panel-close {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

.soon-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold-dark);
  background: var(--gold);
  border-radius: 999px;
  padding: 2px 10px;
}

#name-form input {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: #120c09;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 4px 0 12px;
  outline: none;
}

#name-form input:focus {
  border-color: var(--gold);
}

.btn {
  font: inherit;
  font-weight: 700;
  color: var(--gold-dark);
  background: var(--gold);
  border: 0;
  border-radius: var(--radius);
  padding: 10px 16px;
  cursor: pointer;
}
