:root {
  --ink: #1b1b2b;
  --paper: #fff8ec;
  --hot: #ff7a3d;
  --cool: #5ee6ff;
  --violet: #8f6bff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

[hidden] { display: none !important; }

#screen {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Touch controls */
#controls { position: fixed; inset: 0; pointer-events: none; }
#controls > * { pointer-events: auto; position: absolute; }

#pad {
  left: max(14px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
  width: 172px;
  height: 84px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
#pad span, #jump, #duck, #pause {
  display: grid;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, 0.75);
  background: rgba(27, 27, 43, 0.38);
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  border-radius: 20px;
}
#pad span { pointer-events: none; }
#pad.left span:first-child, #pad.right span:last-child, #jump.down, #duck.down { background: rgba(255, 122, 61, 0.8); }

#jump {
  right: max(18px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  width: 96px;
  height: 96px;
  border-radius: 50%;
  font-size: 36px;
}
#duck {
  right: calc(max(18px, env(safe-area-inset-right)) + 108px);
  bottom: max(14px, env(safe-area-inset-bottom));
  width: 68px;
  height: 68px;
  border-radius: 50%;
  font-size: 26px;
}
#pause {
  top: max(8px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  font-size: 16px;
  border-radius: 12px;
}

/* Menus */
#overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  overflow: auto;
  touch-action: pan-y;
  background:
    radial-gradient(circle at 15% 20%, rgba(94, 230, 255, 0.35), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(255, 95, 162, 0.35), transparent 45%),
    rgba(27, 27, 43, 0.82);
}
#overlay:empty { display: none; }

.panel {
  width: min(680px, 100%);
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 8px 0 var(--ink);
  padding: 14px 16px;
  display: grid;
  gap: 10px;
}
.panel h1 {
  margin: 0;
  font-size: clamp(26px, 6vw, 40px);
  letter-spacing: 1px;
  font-weight: 900;
  text-align: center;
  color: var(--hot);
  -webkit-text-stroke: 2px var(--ink);
}
.panel h2 { margin: 0; font-size: 20px; text-align: center; }
.panel p { margin: 0; text-align: center; font-size: 14px; }
.muted { opacity: 0.7; }

.row { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.split { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; }
.stack { display: grid; gap: 8px; justify-items: center; }
.options { justify-items: start; }

button.btn {
  font: inherit;
  font-weight: 800;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 9px 14px;
  min-height: 44px;
  min-width: 44px;
  box-shadow: 0 3px 0 var(--ink);
}
button.btn:active { transform: translateY(3px); box-shadow: none; }
button.btn:disabled { opacity: 0.4; }
button.btn.primary { background: var(--hot); color: #fff; font-size: 19px; padding: 10px 26px; }
button.btn.on { background: var(--violet); color: #fff; }
button.btn.small { padding: 6px 10px; font-size: 13px; min-height: 38px; }

.hero-card { display: grid; justify-items: center; gap: 2px; min-width: 150px; }
.hero-card strong { font-size: 18px; }
canvas.preview { width: 110px; height: 110px; }
canvas.preview.large { width: 154px; height: 154px; }

.level { font-weight: 800; font-size: 16px; min-width: 76px; text-align: center; }

.group { display: grid; gap: 4px; }
.group > span { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; }
.group .row { justify-content: flex-start; gap: 6px; }

input[type="text"] {
  font: inherit;
  font-weight: 700;
  width: 130px;
  padding: 8px 10px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  user-select: text;
  -webkit-user-select: text;
}
input[type="color"] {
  width: 52px;
  height: 40px;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: #fff;
}
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--ink); padding: 0; }
.swatch.on { outline: 3px solid var(--hot); outline-offset: 2px; }

/* The character editor */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px; border-bottom: 3px solid var(--ink); width: 100%; }
.options { width: 100%; }
.options p { text-align: left; }
.slider { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 8px; width: 100%; font-size: 13px; font-weight: 700; }
input[type="range"] { width: 100%; min-width: 120px; height: 32px; margin: 0; touch-action: none; accent-color: var(--hot); }

@media (max-width: 520px) {
  .split { grid-template-columns: 1fr; justify-items: center; }
}
