:root {
  --bg: #070b08;
  --fg: #8dfc9c;
  --hot: #e8ffec;
  --dim: #3e7a49;
  --faint: #1f3b25;
  --mono: ui-monospace, "Cascadia Mono", "Roboto Mono", "Droid Sans Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); height: 100%; }
body {
  margin: 0 auto; max-width: 560px; height: 100dvh; overflow: hidden;
  display: grid; grid-template-rows: auto 1fr auto auto auto; gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom));
  background: var(--bg); color: var(--fg); font: 16px/1.3 var(--mono);
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
/* Faint CRT scanlines over everything; never intercepts taps. */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 10;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, .22) 2px 3px);
}
header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h1 { margin: 0; font-size: 18px; font-weight: 400; text-shadow: 0 0 6px rgba(141, 252, 156, .5); }
.cursor { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cursor { animation: none; } }

#screen-wrap { position: relative; min-height: 0; display: grid; place-items: center; overflow: hidden; }
#screen {
  margin: 0; font-family: var(--mono); white-space: pre; line-height: 1.15; font-size: 16px;
  text-shadow: 0 0 5px rgba(141, 252, 156, .45); touch-action: none; cursor: pointer;
}
#screen .e { color: var(--faint); text-shadow: none; }
#screen .g { color: var(--dim); text-shadow: none; }
#screen .p { color: var(--hot); text-shadow: 0 0 8px rgba(141, 252, 156, .9); }
#screen .l { color: var(--dim); }
#screen .m { color: var(--hot); }
#screen.flash { color: var(--hot); }
#probe { position: absolute; visibility: hidden; font: 100px/1 var(--mono); white-space: pre; }

button {
  font: inherit; color: var(--fg); background: transparent; border: 1px solid var(--dim); border-radius: 0;
  min-height: 44px; min-width: 44px; padding: 0 10px; cursor: pointer;
}
button:active:not(:disabled) { background: var(--fg); color: var(--bg); }
button:focus-visible { outline: 2px solid var(--hot); outline-offset: 2px; }
button:disabled { color: var(--faint); border-color: var(--faint); }
button.small { font-size: 14px; border-color: transparent; color: var(--dim); }
#menu { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
#pad button { min-height: 60px; font-size: 24px; }
#pad button[data-act="hard"] { color: var(--hot); }
#lab-offline-status { margin: 0; font-size: 12px; color: var(--dim); text-align: center; }
#lab-offline-status:empty { display: none; }
dialog { max-width: min(26rem, 90vw); background: var(--bg); color: var(--fg); border: 1px solid var(--fg); border-radius: 0; font-family: var(--mono); }
dialog::backdrop { background: rgba(0, 0, 0, .7); }
dialog h2 { font-size: 18px; font-weight: 400; margin-top: 0; }
dialog button { margin: 4px 4px 0 0; }
@media (min-height: 760px) { #pad button { min-height: 66px; } }
