@font-face {
  font-family: 'PressStart';
  src: url('fonts/PressStart2P.woff2') format('woff2');
  font-display: swap;
}

:root {
  --bg: #1c1a2b;
  --panel: #2a2640;
  --edge: #0d0b14;
  --text: #f4ecd8;
  --gold: #f2c230;
  --red: #d63a3a;
  --p1: #3fb6ff;
  --p2: #ffa63f;
  --muted: #a49fbf;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'PressStart', 'Courier New', monospace;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

#hud {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 4px solid var(--edge);
  font-size: 13px;
  line-height: 1.4;
  min-height: 52px;
}
#hud-l { flex: 1 1 0; white-space: nowrap; overflow: hidden; }
#hud-c { flex: 1 1 0; text-align: center; color: var(--muted); font-size: 11px; }
#hud-r { flex: 1 1 0; display: flex; justify-content: flex-end; gap: 8px; }
.p1 { color: var(--p1); }
.p2 { color: var(--p2); }

#stage {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#cv {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  display: block;
}

button {
  font-family: inherit;
  color: var(--text);
  background: #4a4470;
  border: 4px solid var(--edge);
  box-shadow: inset -4px -4px 0 #322d52, inset 4px 4px 0 #6b64a0;
  cursor: pointer;
  touch-action: manipulation;
}
button:active { transform: translateY(2px); box-shadow: inset 4px 4px 0 #322d52; }
button.mini { font-size: 10px; padding: 8px 10px; }
button.big { font-size: 18px; padding: 20px 26px; min-width: 240px; }
button.small { font-size: 12px; padding: 12px 18px; margin-top: 18px; }
button.diff { font-size: 12px; padding: 12px 14px; background: #34304f; color: var(--muted); }
button.diff.on { background: var(--gold); color: #2a1e00; box-shadow: inset -4px -4px 0 #b88c10, inset 4px 4px 0 #ffe27a; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(13, 11, 20, 0.78);
  padding: 16px;
  z-index: 5;
}
.screen.on { display: flex; }

.box {
  background: var(--panel);
  border: 4px solid var(--edge);
  box-shadow: 0 0 0 4px #4a4470, 8px 8px 0 4px rgba(0,0,0,.5);
  padding: 28px 32px;
  text-align: center;
  max-width: 760px;
  width: 100%;
  max-height: 100%;
  overflow: auto;
}

h1 {
  margin: 0 0 18px;
  font-size: 40px;
  line-height: 1.3;
  color: var(--text);
  text-shadow: 4px 4px 0 var(--edge);
}
h1 span { color: var(--red); }
h2 { margin: 0 0 18px; font-size: 24px; color: var(--gold); text-shadow: 3px 3px 0 var(--edge); line-height: 1.4; }
.sub { font-size: 12px; line-height: 1.9; color: var(--muted); margin: 0 0 22px; }

.row { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.diffs { margin-top: 22px; gap: 10px; }

.code {
  font-size: 56px;
  letter-spacing: 16px;
  color: var(--gold);
  text-shadow: 4px 4px 0 var(--edge);
  margin: 6px 0 20px;
}
.stats { margin: 22px auto 0; border-collapse: collapse; font-size: 12px; color: var(--text); }
.stats th { color: var(--muted); font-weight: normal; padding: 0 0 10px 22px; }
.stats td { padding: 6px 0 6px 22px; text-align: center; }
.stats td:first-child { text-align: left; padding-left: 0; }
.err { color: var(--red); font-size: 12px; min-height: 18px; margin-bottom: 10px; }
.wait { font-size: 12px; color: var(--text); min-height: 16px; }
.dots::after { content: ''; animation: dots 1.4s steps(4) infinite; }
@keyframes dots {
  0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; }
}

.pad {
  display: grid;
  grid-template-columns: repeat(3, 96px);
  gap: 10px;
  justify-content: center;
}
.pad button { font-size: 26px; height: 76px; }

#shout {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  font-size: 64px;
  color: var(--gold);
  text-shadow: 5px 5px 0 var(--edge), -2px -2px 0 var(--edge);
  pointer-events: none;
  white-space: nowrap;
  z-index: 4;
  opacity: 0;
}
#shout.go { animation: shout 1.1s ease-out forwards; }
#shout.hold { opacity: 1; }
@keyframes shout {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.4); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  30% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

@media (max-width: 700px), (max-height: 520px) {
  h1 { font-size: 26px; }
  h2 { font-size: 18px; }
  button.big { font-size: 14px; padding: 14px 16px; min-width: 180px; }
  .code { font-size: 40px; }
  .pad { grid-template-columns: repeat(3, 72px); }
  .pad button { height: 56px; font-size: 20px; }
  #hud { font-size: 10px; }
  #hud-c { display: none; }
  #shout { font-size: 40px; }
  .box { padding: 18px; }
}
