:root {
  --bg: #0a1628;
  --panel: rgba(8, 14, 28, 0.92);
  --line: rgba(255, 255, 255, 0.1);
  --text: #e8eefc;
  --muted: #8b9bb8;
  --accent: #00d4aa;
  --danger: #ff5a6e;
  --font: "Segoe UI", "Avenir Next", "Trebuchet MS", sans-serif;
  --chrome: 0;
}

* { box-sizing: border-box; }

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

#app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: none;
  margin: 0;
  padding: 0;
}

.topbar, .foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.15rem;
  flex-shrink: 0;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
}

.brand span { color: var(--accent); }

.meta, .foot, .hint, .muted, .eyebrow, .sub {
  color: var(--muted);
  font-size: 0.88rem;
}

.meta {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.stage-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.4);
  display: grid;
  place-items: center;
}

#game {
  display: block;
  position: relative;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  background: #050b14;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  overflow: auto;
  padding: 0.5rem;
}

.overlay.active {
  pointer-events: auto;
  background: rgba(3, 6, 14, 0.45);
  backdrop-filter: blur(2px);
}

.panel {
  width: min(520px, calc(100% - 1rem));
  max-height: min(92%, 100%);
  overflow: auto;
  padding: 1.25rem 1.15rem 1.1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.panel.hidden { display: none; }

.panel h1, .panel h2 {
  margin: 0.2rem 0 0.45rem;
  letter-spacing: 0.04em;
}

.panel h1 { font-size: clamp(1.7rem, 6vw, 2.8rem); }

.world-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin: 0.85rem 0 0.65rem;
}

.world-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 12px;
  padding: 0.6rem 0.55rem;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.world-btn:hover { transform: translateY(-1px); border-color: rgba(0, 212, 170, 0.45); }

.world-btn.active {
  border-color: var(--accent);
  background: rgba(0, 212, 170, 0.12);
  box-shadow: 0 0 0 1px rgba(0, 212, 170, 0.25) inset;
}

.world-btn .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.world-btn .dot.city { background: #2dd4bf; }
.world-btn .dot.forest { background: #b6f27d; }
.world-btn .dot.desert { background: #ffe08a; }
.world-btn .dot.space { background: #ff4fd8; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.2rem;
  font-weight: 700;
  cursor: pointer;
  margin: 0.2rem;
}

.btn.compact {
  padding: 0.32rem 0.75rem;
  font-size: 0.78rem;
  margin: 0;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #5eead4);
  color: #042f2e;
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.scoreline { margin: 0.3rem 0; font-size: 1rem; }
.scoreline strong { color: var(--accent); }

.touch-pad {
  display: none;
  flex-shrink: 0;
  gap: 0.55rem;
  padding: 0.55rem 0.1rem 0.15rem;
  touch-action: none;
}

.touch-pad button {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border-radius: 16px;
  font-weight: 800;
  font-size: 1rem;
  min-height: 56px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.touch-pad button:active,
.touch-pad button.is-down {
  background: rgba(0, 212, 170, 0.22);
  border-color: rgba(0, 212, 170, 0.55);
  color: var(--accent);
}

.touch-pad [data-dir="left"],
.touch-pad [data-dir="right"] {
  flex: 0 0 22%;
  font-size: 1.35rem;
}

.touch-pad [data-dir="jump"] {
  flex: 1;
  letter-spacing: 0.08em;
}

@media (max-width: 900px) {
  .meta span { display: none; }
  .world-pick { grid-template-columns: 1fr; }
  .hint { font-size: 0.8rem; }
}

/* phones / touch: show on-screen controls, use more vertical space */
@media (max-width: 820px), (pointer: coarse) {
  .touch-pad { display: flex; }
  .foot span:first-child { display: none; }
  .panel { padding: 1rem 0.9rem; }
  .panel h1 { font-size: clamp(1.55rem, 8vw, 2.2rem); }
}
