:root {
  --bg: #07040f;
  --panel: rgba(12, 8, 28, 0.92);
  --line: #2a1b4d;
  --cyan: #55ffff;
  --pink: #ff4fd8;
  --yellow: #ffcc33;
  --red: #ff3355;
  --text: #f4f1ff;
  --muted: #9aa0b5;
  --font: "Courier New", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, #140a2a 0%, var(--bg) 70%);
}

#stage {
  position: relative;
  width: 480px;
  height: 270px;
  /* scaled from JS to the largest size that fits */
  transform-origin: center center;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  box-shadow: 0 0 0 1px #1b1236, 0 0 40px rgba(255, 79, 216, 0.15);
}

.hidden {
  display: none !important;
}

/* ------------------------------------------------------------------ screens */
#screens {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 18px;
  pointer-events: auto;
  font-size: 10px;
  text-align: center;
}

.screen.dim {
  background: rgba(7, 4, 15, 0.72);
}

.screen.solid {
  background: rgba(7, 4, 15, 0.9);
}

.title {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 3px;
  line-height: 1;
  color: var(--text);
  text-shadow: 2px 0 var(--pink), -2px 0 var(--cyan), 0 0 12px rgba(255, 79, 216, 0.6);
  margin: 0 0 2px;
}

.title .flip {
  display: inline-block;
  transform: scaleY(-1);
  color: var(--cyan);
}

.subtitle {
  color: var(--muted);
  letter-spacing: 3px;
  font-size: 8px;
  margin-bottom: 8px;
}

h2 {
  margin: 0 0 4px;
  font-size: 15px;
  letter-spacing: 3px;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(85, 255, 255, 0.5);
}

h3 {
  margin: 4px 0 2px;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--pink);
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
}

.menu.row {
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
}

button {
  font-family: var(--font);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text);
  background: rgba(20, 12, 44, 0.9);
  border: 1px solid var(--line);
  padding: 4px 10px;
  cursor: pointer;
  text-transform: uppercase;
  outline: none;
  position: relative;
}

button:hover,
button:focus-visible,
button.focus {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(30, 60, 90, 0.6);
  box-shadow: 0 0 8px rgba(85, 255, 255, 0.35);
}

button:hover::before,
button:focus-visible::before {
  content: "▶";
  position: absolute;
  left: -10px;
  color: var(--pink);
}

button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

button.danger {
  border-color: #5a1a2a;
}

button.danger:hover,
button.danger:focus-visible {
  border-color: var(--red);
  color: var(--red);
  background: rgba(80, 10, 30, 0.6);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 8px 10px;
  max-width: 440px;
  width: 100%;
}

.scroll {
  overflow-y: auto;
  max-height: 190px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.blink {
  animation: blink 1.1s steps(2) infinite;
  color: var(--yellow);
  letter-spacing: 3px;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.small {
  font-size: 8px;
  color: var(--muted);
}

/* story menu */
.worlds {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  width: 100%;
  max-width: 452px;
}

.world {
  border: 1px solid var(--line);
  background: rgba(12, 8, 28, 0.9);
  padding: 4px 3px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.world .wname {
  font-size: 8px;
  color: var(--pink);
  letter-spacing: 1px;
  min-height: 18px;
}

.world button {
  font-size: 8px;
  padding: 3px 2px;
  letter-spacing: 0;
  text-align: left;
}

.world button .meta {
  display: block;
  font-size: 7px;
  color: var(--muted);
  letter-spacing: 0;
  font-weight: 400;
}

.world button:hover::before,
.world button:focus-visible::before {
  content: none;
}

.rank {
  color: var(--yellow);
}

/* results */
.stats {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 16px;
  font-size: 10px;
  text-align: left;
  margin: 4px 0 6px;
}

.stats span:nth-child(odd) {
  color: var(--muted);
}

.bigrank {
  font-size: 40px;
  font-weight: 900;
  color: var(--yellow);
  text-shadow: 0 0 12px rgba(255, 204, 51, 0.6);
  line-height: 1;
}

/* settings */
.settings {
  display: grid;
  grid-template-columns: 110px 1fr 36px;
  gap: 4px 8px;
  align-items: center;
  text-align: left;
  font-size: 9px;
}

.settings label {
  color: var(--muted);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
  height: 10px;
}

.seg {
  display: flex;
  gap: 2px;
}

.seg button {
  padding: 2px 5px;
  font-size: 8px;
}

.seg button.on {
  border-color: var(--pink);
  color: var(--pink);
}

.seg button:hover::before,
.seg button:focus-visible::before,
.binds button:hover::before,
.binds button:focus-visible::before {
  content: none;
}

/* controls */
.binds {
  display: grid;
  grid-template-columns: 1fr 64px 64px;
  gap: 2px 6px;
  font-size: 9px;
  text-align: left;
  align-items: center;
}

.binds button {
  font-size: 8px;
  padding: 2px 4px;
  letter-spacing: 0;
}

.binds button.wait {
  border-color: var(--yellow);
  color: var(--yellow);
}

table.board {
  border-collapse: collapse;
  width: 100%;
  font-size: 9px;
}

table.board td,
table.board th {
  padding: 1px 4px;
  text-align: left;
}

table.board th {
  color: var(--pink);
  font-weight: 700;
}

table.board tr.me td {
  color: var(--yellow);
}

input.name {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  width: 110px;
  text-align: center;
  text-transform: uppercase;
  background: #0b0820;
  color: var(--yellow);
  border: 1px solid var(--pink);
  padding: 3px;
  letter-spacing: 3px;
  user-select: text;
  -webkit-user-select: text;
}

.confirm {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  box-shadow: 0 0 0 999px rgba(7, 4, 15, 0.7);
  border: 1px solid var(--red);
  background: rgba(40, 6, 16, 0.95);
  padding: 10px 14px;
}

.credits p {
  margin: 3px 0;
}

/* ------------------------------------------------------------------ dialogue */
#dialog {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 12px;
  min-height: 62px;
  background: rgba(7, 4, 15, 0.94);
  border: 1px solid var(--cyan);
  box-shadow: 0 0 0 1px #07040f, 0 0 16px rgba(85, 255, 255, 0.2);
  padding: 6px 10px 14px;
  font-size: 10px;
  line-height: 1.35;
  cursor: pointer;
  text-align: left;
  z-index: 5;
}

#dialog .who {
  color: var(--pink);
  font-weight: 900;
  letter-spacing: 2px;
  margin-bottom: 2px;
}

#dialog .who.echo {
  color: var(--cyan);
}

#dialog .who.vance {
  color: var(--red);
}

#dialog .who.kai {
  color: var(--yellow);
}

#dialog .hint {
  position: absolute;
  right: 8px;
  bottom: 3px;
  font-size: 7px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ touch controls */
#touch {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

#touch button {
  pointer-events: auto;
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(85, 255, 255, 0.5);
  background: rgba(20, 12, 44, 0.45);
  color: rgba(244, 241, 255, 0.85);
  font-size: 7px;
  letter-spacing: 0;
  padding: 0;
  touch-action: none;
}

#touch button::before {
  content: none !important;
}

#touch button.on {
  background: rgba(85, 255, 255, 0.35);
}

#touch .pad .t-left {
  left: 8px;
  bottom: 30px;
}
#touch .pad .t-right {
  left: 66px;
  bottom: 30px;
}
#touch .pad .t-up {
  left: 37px;
  bottom: 60px;
}
#touch .pad .t-down {
  left: 37px;
  bottom: 2px;
}
#touch .acts .t-jump {
  right: 8px;
  bottom: 10px;
  width: 40px;
  height: 40px;
  border-color: var(--cyan);
}
#touch .acts .t-dash {
  right: 54px;
  bottom: 6px;
  border-color: var(--pink);
}
#touch .acts .t-atk {
  right: 50px;
  bottom: 44px;
}
#touch .acts .t-shot {
  right: 12px;
  bottom: 56px;
}
#touch .acts .t-grav {
  right: 92px;
  bottom: 24px;
  border-color: #a07cff;
}
#touch .acts .t-hook {
  right: 88px;
  bottom: 62px;
}
#touch .acts .t-sprint {
  right: 132px;
  bottom: 8px;
}
#touch .t-pause {
  right: 6px;
  top: 34px;
  width: 22px !important;
  height: 22px !important;
}

/* ------------------------------------------------------------------ world map */
.mapscreen {
  justify-content: flex-start;
  padding: 0;
}

.mapbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 10px;
  background: linear-gradient(rgba(7, 4, 15, 0.95), rgba(7, 4, 15, 0.6));
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.mapname {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--cyan);
  text-shadow: 0 0 6px rgba(85, 255, 255, 0.5);
}

.mapmeta {
  font-size: 8px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.mapmeta .w {
  color: var(--pink);
  letter-spacing: 1px;
}

.mapbar button:hover::before,
.mapbar button:focus-visible::before {
  content: none;
}

.node-hit {
  position: absolute;
  width: 20px;
  height: 22px;
  padding: 0;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.node-hit::before {
  content: none !important;
}

.maphint {
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 7px;
}
