:root {
  --bg: #0b0413;
  --purple: #4a0e8f;
  --purple-bright: #7b2fd6;
  --gold: #f39c12;
  --neon: #00ff88;
  --stone: #383448;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: #e8e0d0;
  font-family: "Courier New", ui-monospace, monospace;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #0b0413;
  max-width: 100%;
  max-height: 100%;
}

/* ------------------------------------------------------------- overlay */

#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, #1a0a2e 0%, #06020f 75%);
  z-index: 10;
}

#overlay.hidden, .hidden { display: none !important; }

/* After a win or a wipe the arena stays visible behind the panel. */
#overlay.result { background: rgba(6, 2, 15, 0.72); }

.panel {
  width: min(92vw, 460px);
  padding: 28px 26px 22px;
  border: 3px solid var(--stone);
  background: rgba(10, 4, 20, 0.92);
  box-shadow: 0 0 0 3px #0b0413, 0 18px 60px rgba(0, 0, 0, 0.7);
  text-align: center;
}

h1 {
  font-size: 34px;
  letter-spacing: 5px;
  color: var(--gold);
  text-shadow: 0 3px 0 #7a4a08;
}

h1 span { color: var(--purple-bright); }

.sub {
  margin-top: 6px;
  font-size: 12px;
  letter-spacing: 3px;
  color: #7f6f9a;
  text-transform: uppercase;
}

#joinBox, .row {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  justify-content: center;
}

input, button {
  font-family: inherit;
  font-size: 14px;
  padding: 11px 14px;
  border: 2px solid var(--stone);
  background: #150a24;
  color: #e8e0d0;
  letter-spacing: 1px;
}

input { flex: 1; min-width: 0; }
input:focus { outline: none; border-color: var(--purple-bright); }

button {
  cursor: pointer;
  background: var(--purple);
  border-color: var(--purple-bright);
  font-weight: bold;
}

button:hover { background: var(--purple-bright); }
button:active { transform: translateY(1px); }
button.on { background: var(--neon); color: #06020f; border-color: var(--neon); }

ul { list-style: none; margin-top: 18px; }

li {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-left: 4px solid var(--stone);
  background: #150a24;
  font-size: 13px;
}

li.ready { border-left-color: var(--neon); }
li .tag { color: var(--gold); font-size: 11px; }

.hint, .status, .keys {
  margin-top: 14px;
  font-size: 11px;
  color: #6d5f88;
  line-height: 1.6;
}

.status { color: var(--neon); }

/* --------------------------------------------------------- touch pads */

#touch {
  position: fixed;
  inset: auto 0 0 0;
  display: flex;
  justify-content: space-between;
  padding: 16px;
  pointer-events: none;
  z-index: 5;
}

.pad { display: flex; gap: 12px; align-items: flex-end; pointer-events: auto; }

.tbtn {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  font-size: 13px;
  opacity: 0.75;
  background: rgba(74, 14, 143, 0.8);
}

.tbtn.big { width: 92px; height: 92px; }
.tbtn.small { width: 58px; height: 58px; font-size: 10px; }
.tbtn.held { background: var(--neon); color: #06020f; }

/* ------------------------------------------------------------ result table */

#resultBox {
  margin-top: 18px;
  border: 2px solid var(--stone);
  background: #120722;
  padding: 14px 12px;
  text-align: left;
}

#resultBox .rank {
  display: block;
  text-align: center;
  font-size: 46px;
  font-weight: bold;
  line-height: 1;
  letter-spacing: 4px;
}

#resultBox .verdict {
  display: block;
  text-align: center;
  font-size: 12px;
  letter-spacing: 3px;
  margin: 6px 0 14px;
  color: #7f6f9a;
}

#resultBox table { width: 100%; border-collapse: collapse; font-size: 12px; }
#resultBox th {
  text-align: left;
  color: #6d5f88;
  font-weight: normal;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--stone);
}
#resultBox td { padding: 5px 0; color: #b6a8cc; }
#resultBox td.num { text-align: right; color: #e8e0d0; }
#resultBox tr.me td { color: var(--neon); }
#resultBox .broke { margin-top: 10px; font-size: 11px; color: var(--gold); }

/* -------------------------------------------------------------- the road */

#stageBox { margin-top: 16px; text-align: left; max-height: 40vh; overflow-y: auto; }
.stagehead {
  font-size: 11px; letter-spacing: 3px; color: #7f6f9a; margin-bottom: 8px;
}
.stage {
  padding: 8px 10px; margin-bottom: 6px; cursor: pointer;
  border-left: 4px solid var(--stone); background: #150a24;
}
.stage:hover { border-left-color: var(--purple-bright); }
.stage.on { border-left-color: var(--neon); background: #1d1030; }
.stage.done { border-left-color: var(--gold); }
.stage.locked { opacity: 0.4; cursor: default; }
.stage b { display: block; font-size: 12px; color: var(--bone); }
.stage.on b { color: var(--neon); }
.stage span { font-size: 10px; color: #7f6f9a; line-height: 1.5; }
.stage i { display: block; font-size: 10px; color: var(--gold); font-style: normal; margin-top: 3px; }

/* The story replay lives outside the lobby box so it is reachable before joining. */
.storyline { margin: 10px 0 4px; text-align: center; }
button.link {
  background: none;
  border: none;
  color: #b6a8cc;
  font: 12px "Courier New", monospace;
  letter-spacing: 2px;
  cursor: pointer;
  padding: 4px 8px;
}
button.link:hover { color: #f39c12; }
