:root {
  --ink: #12101c;
  --paper: #f2f0eb;
  --warm: #ffd08a;
  --panel: rgba(18, 16, 30, 0.82);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: #12101c;
  font: 14px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--paper);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#hud {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  display: flex;
  gap: 10px;
  align-items: center;
  pointer-events: none;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}

#hud .label {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chip {
  padding: 2px 9px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.chip.locked { opacity: 0.5; }

.chip.have {
  color: #12101c;
  background: var(--warm);
  border-color: var(--warm);
  text-shadow: none;
}

#tools {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  align-items: center;
}

#tools button {
  font: inherit;
  padding: 3px 10px;
  border: 2px solid rgba(242, 240, 235, 0.6);
  border-radius: 999px;
  background: var(--panel);
  color: var(--paper);
  cursor: pointer;
  touch-action: manipulation;
}

#restart { font-size: 16px; line-height: 1; padding: 4px 11px; }

#tuner {
  position: fixed;
  top: calc(50px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  width: 290px;
  max-height: calc(100vh - 72px);
  overflow-y: auto;
  padding: 2px 14px 14px;
  border: 2px solid rgba(242, 240, 235, 0.35);
  background: var(--panel);
  backdrop-filter: blur(6px);
  font-size: 12px;
}

#tuner.hidden { display: none; }

#tuner label {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  margin: 14px 0 0;
}

#tuner label b {
  font-variant-numeric: tabular-nums;
  color: var(--warm);
}

#tuner small {
  grid-column: 1 / -1;
  opacity: 0.5;
  line-height: 1.3;
  margin-top: 2px;
}

#tuner input[type='range'] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--warm);
}

.tuner-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.tuner-actions button {
  flex: 1;
  font: inherit;
  font-size: 12px;
  padding: 5px;
  border: 2px solid rgba(242, 240, 235, 0.5);
  background: transparent;
  color: var(--paper);
  cursor: pointer;
}

.tuner-note {
  margin: 12px 0 0;
  opacity: 0.5;
  line-height: 1.35;
}

#toast {
  position: fixed;
  top: 52px;
  left: 12px;
  padding: 6px 12px;
  border: 2px solid var(--warm);
  border-radius: 4px;
  background: var(--panel);
  color: var(--warm);
  pointer-events: none;
}

#toast.hidden { display: none; }

#banner {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(18, 16, 30, 0.72);
  pointer-events: none;
}

#banner.hidden { display: none; }

#banner-text {
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.04em;
  color: var(--warm);
}

#banner-text small {
  display: block;
  margin-top: 10px;
  font-size: 14px;
  font-weight: 400;
  opacity: 0.7;
  color: var(--paper);
}


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

#touch {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 calc(16px + env(safe-area-inset-left)) calc(18px + env(safe-area-inset-bottom))
    calc(16px + env(safe-area-inset-right));
  pointer-events: none;
}

@media (pointer: coarse) { #touch { display: flex; } }
body.touch #touch { display: flex; }

#touch .pad {
  display: flex;
  gap: 14px;
  align-items: flex-end;
}

.tbtn {
  pointer-events: auto;
  touch-action: none;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 2px solid rgba(242, 240, 235, 0.5);
  background: rgba(18, 16, 30, 0.5);
  backdrop-filter: blur(3px);
  color: rgba(242, 240, 235, 0.85);
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 90ms, transform 90ms;
}

.tbtn.jump {
  width: 92px;
  height: 92px;
  border-color: rgba(255, 208, 138, 0.75);
  color: var(--warm);
  font-size: 28px;
}

.tbtn.drop { width: 58px; height: 58px; font-size: 17px; }

.tbtn.down {
  background: rgba(255, 208, 138, 0.35);
  transform: scale(0.94);
}

/* a phone in portrait gets a narrower slice of the world; keep the chrome small */
@media (max-height: 520px) {
  .tbtn { width: 62px; height: 62px; }
  .tbtn.jump { width: 78px; height: 78px; }
  .tbtn.drop { width: 50px; height: 50px; }
}
