:root {
  color-scheme: light;
  --ink: #202431;
  --cream: #fff4c7;
  --yellow: #f7cf46;
  --orange: #ef7351;
  --blue: #4f8fc0;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--yellow);
  color: var(--ink);
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
}

button { font: inherit; }

#game {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background: var(--yellow);
}

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

.hud {
  position: absolute;
  z-index: 3;
  top: max(16px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: flex-start;
  gap: 22px;
  pointer-events: none;
  text-shadow: 0 2px 0 rgba(255,255,255,.4);
}

.hud strong { display: block; font-size: clamp(22px, 4vw, 34px); line-height: 1; }
.hud #best { display: block; margin-top: 5px; font-size: 10px; letter-spacing: .13em; }
.collectibles { display: flex; gap: 12px; padding-top: 3px; font-size: 16px; }

.icon-button, .comfort-button {
  position: absolute;
  z-index: 7;
  top: max(14px, env(safe-area-inset-top));
  border: 3px solid var(--ink);
  background: var(--cream);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
}

.icon-button { right: max(16px, env(safe-area-inset-right)); width: 42px; height: 42px; font-size: 22px; }
.comfort-button { right: calc(max(16px, env(safe-area-inset-right)) + 53px); height: 42px; padding: 0 10px; font-size: 10px; letter-spacing: .08em; }
.icon-button:active, .comfort-button:active, .main-button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.panel {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background: rgba(247, 207, 70, .87);
  backdrop-filter: blur(3px);
}

.panel[hidden] { display: none; }
.panel h1 { margin: 4px 0; font-size: clamp(58px, 13vw, 112px); line-height: .76; letter-spacing: -.07em; transform: rotate(-2deg); }
.panel h2 { margin: 4px 0 0; font-size: clamp(68px, 15vw, 130px); line-height: 1; letter-spacing: -.07em; }
.eyebrow { margin: 0 0 10px; font: 800 12px/1.2 ui-monospace, monospace; letter-spacing: .12em; }
.tagline { margin: 18px 0 20px; font-weight: 900; letter-spacing: .12em; }
.how-to { display: grid; margin-bottom: 14px; font-size: 21px; font-weight: 900; }
.how-to small, .keyboard-note { font-size: 11px; letter-spacing: .1em; }
.main-button { border: 4px solid var(--ink); background: var(--orange); color: #fff; padding: 13px 24px; font-weight: 900; letter-spacing: .08em; box-shadow: 5px 5px 0 var(--ink); cursor: pointer; }
.keyboard-note { margin-top: 16px; opacity: .7; }
.death-panel { background: rgba(239, 115, 81, .9); color: #fff; }
.death-panel .main-button { margin-top: 18px; background: var(--yellow); color: var(--ink); }
.death-panel p { margin: 5px; font-weight: 900; }

.touch-guide {
  position: absolute;
  z-index: 4;
  inset: 52% 0 0;
  display: none;
  pointer-events: none;
  opacity: 0;
}

.touch-guide.show { display: flex; animation: guideFade 3.4s ease both; }
.touch-guide div { flex: 1; display: grid; place-content: center; text-align: center; border-top: 2px dashed rgba(32,36,49,.22); }
.touch-guide div + div { border-left: 2px dashed rgba(32,36,49,.22); }
.touch-guide span { font-size: clamp(17px, 4vw, 28px); font-weight: 900; }
.touch-guide small { margin-top: 4px; font-weight: 900; letter-spacing: .12em; }

.announcement {
  position: absolute;
  z-index: 5;
  top: 24%;
  left: 50%;
  min-width: 160px;
  transform: translate(-50%, -10px) rotate(-2deg);
  text-align: center;
  font-size: clamp(18px, 4vw, 34px);
  font-weight: 1000;
  letter-spacing: .04em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, transform .15s;
  text-shadow: 2px 2px 0 var(--cream);
}
.announcement.show { opacity: 1; transform: translate(-50%, 0) rotate(-2deg); }

@keyframes guideFade { 0% { opacity: 0; } 12%, 70% { opacity: 1; } 100% { opacity: 0; } }

@media (max-width: 560px) {
  .comfort-button { top: calc(max(14px, env(safe-area-inset-top)) + 51px); right: max(16px, env(safe-area-inset-right)); }
  .hud { gap: 12px; }
  .collectibles { display: grid; gap: 2px; }
}

@media (max-height: 500px) {
  .panel { padding: 8px 70px 8px 12px; }
  .panel h1 { font-size: 72px; }
  .panel h2 { font-size: 72px; }
  .eyebrow { margin-bottom: 4px; font-size: 10px; }
  .tagline { margin: 7px 0 8px; }
  .how-to { margin-bottom: 7px; font-size: 18px; }
  .main-button { padding: 10px 20px; }
  .keyboard-note { margin-top: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .touch-guide.show { animation-duration: .01ms; }
  .announcement { transition: none; }
}
