/* Layout: an arcade cabinet. One game screen in a dark bezel, a slim toolbar above, the control card below. */
:root {
  --bezel: #12172e;
  --panel: #1c2347;
  --ink: #eef0ff;
  --muted: #9ba3d4;
  --coin: #ffcf3f;
  --cap: #ff8a3d;
  --easy: #7be08a;
  --hard: #ff6a4a;
  --screen-edge: #070a18;
  --display: "Press Start 2P", ui-monospace, "Courier New", monospace;
  --body: "Rubik", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  color-scheme: dark;
}
html, body { height: 100%; }
body { margin: 0; }
[hidden] { display: none !important; }
body {
  background: var(--bezel);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 18px 28px;
  box-sizing: border-box;
}
.wrap {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.controls { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
@media (max-width: 720px) { .controls { align-items: flex-start; } }
header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
header > div { min-width: 0; }
h1 {
  font-family: var(--display);
  font-size: clamp(16px, 3.4vw, 24px);
  line-height: 1.3;
  margin: 0;
  letter-spacing: 0.02em;
  color: var(--coin);
  text-shadow: 3px 3px 0 #a3461b;
  text-wrap: balance;
}
.sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tools { display: flex; gap: 8px; flex-wrap: wrap; }
.tools button, .diff button {
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid #343e78;
  border-radius: 6px;
  padding: 9px 10px;
  cursor: pointer;
}
.tools button[aria-pressed="false"] { color: var(--muted); }
.tools button:hover, .diff button:hover { border-color: var(--coin); }
button:focus-visible, canvas:focus-visible { outline: 3px solid var(--coin); outline-offset: 2px; }

.diff {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.diff .lbl {
  font-family: var(--display);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 4px;
}
.diff button { display: inline-flex; align-items: baseline; gap: 6px; color: var(--muted); }
.diff button .ar { font-family: var(--body); font-size: 13px; text-transform: none; letter-spacing: 0; }
.diff button[aria-checked="true"] { color: #12172e; }
.diff button[data-d="easy"][aria-checked="true"] { background: var(--easy); border-color: var(--easy); }
.diff button[data-d="medium"][aria-checked="true"] { background: var(--coin); border-color: var(--coin); }
.diff button[data-d="hard"][aria-checked="true"] { background: var(--hard); border-color: var(--hard); }

.screen {
  width: min(100%, calc((100svh - 130px) * 1.0667));
  min-width: min(100%, 480px);
  margin-inline: auto;
  padding: 10px;
  background: var(--screen-edge);
  border-radius: 12px;
  box-shadow: 0 0 0 2px #262f5e, 0 18px 40px -18px #000;
  box-sizing: border-box;
}
canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 256 / 240;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-radius: 4px;
  background: #87c8f2;
  touch-action: none;
  cursor: pointer;
}
.screen:fullscreen {
  width: 100vw; height: 100vh; min-width: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 0; border-radius: 0; background: #000;
}
.screen:fullscreen canvas { width: min(100vw, calc(100vh * 1.0667)); border-radius: 0; }

.worlds {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.world {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--panel);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 0;
}
.world i {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 4px;
  border: 2px solid #0007;
}
.world b { font-family: var(--display); font-size: 8px; display: block; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 4px; }
.world span { font-size: 14px; }

.help {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  background: var(--panel);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 0;
}
.help div { min-width: 0; }
.help dt {
  font-family: var(--display);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.help dd { margin: 0; font-size: 14px; }
kbd {
  font-family: var(--display);
  font-size: 9px;
  background: var(--bezel);
  border: 1px solid #3b4685;
  border-bottom-width: 3px;
  border-radius: 4px;
  padding: 3px 5px;
  margin-right: 2px;
  color: var(--ink);
}

.touch { display: none; justify-content: space-between; gap: 12px; user-select: none; -webkit-user-select: none; }
.touch .pad { display: flex; gap: 10px; }
.touch button {
  width: 68px; height: 68px;
  border-radius: 50%;
  border: 3px solid #3b4685;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--display);
  font-size: 11px;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.touch button.held { background: #343e78; border-color: var(--coin); }
.touch .act-jump { background: #a3461b; border-color: var(--cap); }
.touch .act-jump.held { background: var(--cap); }
@media (pointer: coarse) {
  .touch { display: flex; }
  .help .kb { display: none; }
}
@media (max-width: 380px) {
  .touch button { width: 58px; height: 58px; }
}
