:root {
  --yellow: #f2eee7;
  --red: #c20d18;
  --dark-red: #560006;
  --blue: #111;
  --ink: #050505;
}

* { box-sizing: border-box; }
html, body {
  width: 100%;
  min-height: 100%;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: radial-gradient(circle at 50% 0, #5a0007 0, #130002 33%, #050505 66%);
  font-family: Arial, Helvetica, sans-serif;
  color: white;
  overflow-x: hidden;
}

.page-shell { width: min(calc(100vw - 24px), calc((100dvh - 180px) * 1.333333), 1040px); padding: 8px; margin-top: 17px; }
.game-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 8px solid #090909;
  outline: 4px solid #777;
  box-shadow: 0 0 0 4px #222, 0 16px 50px #000;
  background: #080808;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
canvas { display: block; width: 100%; height: 100%; image-rendering: auto; touch-action: none; -webkit-touch-callout: none; }

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.18);
}
.hidden { display: none !important; }

.title-card, .panel {
  position: relative;
  text-align: center;
  border: 5px solid #050505;
  outline: 3px solid #eee;
  border-radius: 12px;
  color: white;
  background:
    linear-gradient(180deg, rgba(255,255,255,.18), transparent 20%),
    linear-gradient(150deg, #080808, #620007 58%, #b30b15);
  box-shadow: 10px 12px 0 rgba(0,0,0,.7), inset 0 0 34px rgba(194,13,24,.3);
}
.title-card {
  width: min(78%, 680px);
  padding: 21px 34px 18px;
  transform: rotate(-1deg);
}
.title-card::before,
.title-card::after {
  content: "";
  position: absolute;
  width: 44px;
  height: 44px;
  background: var(--yellow);
  border: 4px solid #000;
  transform: rotate(45deg);
  z-index: -1;
}
.title-card::before { left: -18px; top: 50px; }
.title-card::after { right: -18px; bottom: 60px; }
.eyebrow {
  font-family: Georgia, serif;
  font-weight: 900;
  letter-spacing: .12em;
  font-size: clamp(13px, 2vw, 22px);
  text-shadow: 2px 2px #000;
}
h1 {
  margin: 2px 0 4px;
  line-height: .78;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(62px, 11vw, 112px);
  letter-spacing: -.045em;
  transform: skew(-7deg) rotate(-1deg);
  -webkit-text-stroke: 5px #090909;
  paint-order: stroke fill;
  filter: drop-shadow(7px 8px 0 #1e0606);
}
h1 span { display: block; }
h1 span:first-child {
  color: #f2eee7;
  background: linear-gradient(#fff 10%, #d9d0c8 48%, #817872 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
h1 span:last-child {
  color: #f22;
  background: linear-gradient(#ff8b54 5%, #ef231c 45%, #8e0506 96%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.tagline {
  display: inline-block;
  margin: 10px 0 14px;
  padding: 5px 10px;
  background: #050505;
  color: var(--yellow);
  border: 2px solid white;
  font: 900 clamp(11px, 1.6vw, 17px) / 1 Arial, sans-serif;
  letter-spacing: .08em;
  transform: rotate(1deg);
}

.flash-button {
  cursor: pointer;
  min-width: 230px;
  padding: 12px 24px 10px;
  border: 5px solid #070707;
  border-radius: 8px;
  outline: 2px solid white;
  color: white;
  background: linear-gradient(#ff5c36, #c00c09 52%, #730300 54%, #d11812);
  box-shadow: 0 7px 0 #3a0302, 0 11px 14px rgba(0,0,0,.5), inset 0 3px rgba(255,255,255,.45);
  font: 900 clamp(20px, 3vw, 32px) / 1 Impact, "Arial Black", sans-serif;
  letter-spacing: .06em;
  text-shadow: 3px 3px #500;
}
.flash-button:hover { filter: brightness(1.18); transform: translateY(-1px); }
.flash-button:active { transform: translateY(5px); box-shadow: 0 2px 0 #3a0302; }
.instructions {
  margin-top: 18px;
  font-size: clamp(11px, 1.65vw, 17px);
  line-height: 1.35;
  text-shadow: 2px 2px #000;
}
.fake-site { margin-top: 12px; opacity: .75; font: 700 10px monospace; }

.loading-overlay { background: #080808; }
.small-panel { width: min(70%, 520px); padding: 28px; }
.loading-title { font: 900 36px Impact, sans-serif; letter-spacing: .08em; text-shadow: 4px 4px #000; }
.meter { height: 28px; margin: 18px 0 10px; border: 4px solid #000; background: #333; box-shadow: inset 0 0 0 2px white; padding: 4px; }
#meterFill { width: 0; height: 100%; background: repeating-linear-gradient(90deg, #f2eee7 0 20px, #c20d18 20px 40px); }
.tiny-copy { font: 700 13px monospace; }

.gameover-panel { width: min(70%, 560px); padding: 30px; }
.gameover-title { font: 900 clamp(39px, 6vw, 65px)/.95 Impact, sans-serif; color: var(--yellow); -webkit-text-stroke: 3px black; paint-order: stroke fill; transform: rotate(-2deg); }
.final-score { margin: 18px 0 4px; font: 900 clamp(24px, 4vw, 42px) monospace; }
.best-score { margin-bottom: 20px; font: 900 clamp(15px, 2vw, 23px) monospace; color: #f2eee7; }

.sound-button {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 5;
  cursor: pointer;
  border: 3px solid #000;
  color: white;
  background: #870009;
  box-shadow: inset 0 2px rgba(255,255,255,.35);
  font: 900 12px Arial, sans-serif;
  padding: 7px 9px;
}
.outside-note { text-align: center; color: #c9c0b9; font: 12px monospace; letter-spacing: .08em; margin: 14px 0 0; }

@media (max-width: 650px), (max-height: 650px) {
  .page-shell { padding: 2px; }
  .game-frame { border-width: 4px; outline-width: 1px; }
  .overlay { padding: 10px; }
  .title-card { width: 88%; padding: 14px 16px 12px; }
  h1 { -webkit-text-stroke-width: 3px; }
  .flash-button { min-width: 180px; padding: 9px 18px; border-width: 3px; }
  .sound-button { right: 5px; bottom: 5px; transform: scale(.8); transform-origin: bottom right; }
}

@media (orientation: portrait) and (max-width: 650px) {
  body { align-content: center; }
}

@media (max-width: 650px) {
  .title-card { padding: 14px; }
  .title-card .eyebrow { font-size: 11px; }
  .title-card h1 { font-size: clamp(36px, 12vw, 78px); }
  .title-card .tagline, .title-card .fake-site { display: none; }
  .title-card .flash-button { min-height: 44px; margin-top: 12px; }
  .title-card .instructions { margin-top: 12px; font-size: 10px; }
  .outside-note { font-size: 10px; }
  .gameover-panel { width: 88%; padding: 18px; }
  .gameover-title { font-size: clamp(24px, 7vw, 39px); }
  .gameover-panel .final-score { margin-top: 12px; font-size: 22px; }
  .gameover-panel .best-score { margin-bottom: 12px; font-size: 13px; }
  .gameover-panel .flash-button { min-height: 44px; font-size: 20px; }
  .gameover-panel .instructions { margin-top: 12px; font-size: 10px; }
}

:focus-visible { outline: 3px solid #f2eee7; outline-offset: 4px; }

@media (max-width: 480px) {
  .page-shell { width: min(calc(100vw - 24px), calc((100dvh - 230px) * 1.333333)); }
}
