:root {
  color-scheme: dark;
  --ink: #171221;
  --cream: #fff2cf;
  --paper: #f4dfb4;
  --red: #d93b3b;
  --red-dark: #791e2d;
  --gold: #f4c84c;
  --green: #71c84b;
  --purple: #5a315f;
  --line: rgba(255, 242, 207, .18);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body { overflow: hidden; background: #08070c; color: var(--cream); }
button, input { font: inherit; }
button { border: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
[hidden] { display: none !important; }

.game-shell { height: 100dvh; display: grid; grid-template-rows: 78px minmax(0, 1fr); }
.hud { position: relative; z-index: 5; display: grid; grid-template-columns: 122px minmax(130px, 1fr) 110px minmax(130px, 1fr) 108px 48px; align-items: center; gap: clamp(10px, 2vw, 28px); padding: 8px clamp(12px, 2.3vw, 34px); border-bottom: 4px solid #6f4a31; background: linear-gradient(#251b2b, #14101b); box-shadow: 0 6px 25px #000; }
.brand { position: relative; height: 59px; text-transform: uppercase; transform: rotate(-2deg); }
.brand-friday { display: block; margin-top: 4px; color: var(--cream); font-size: 14px; letter-spacing: .12em; }
.brand strong { position: absolute; right: 12px; bottom: -3px; color: var(--red); font-size: 49px; line-height: .8; text-shadow: 3px 3px 0 #421522; }
.meter { display: grid; gap: 5px; }
.meter > div:first-child { display: flex; justify-content: space-between; gap: 8px; color: #dbc8a4; font: 800 11px/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; }
.meter output { color: white; }
.meter-track { height: 15px; overflow: hidden; border: 2px solid #6c5a55; border-radius: 999px; background: #09070d; box-shadow: inset 0 2px 4px #000; }
.meter-track i { display: block; width: 100%; height: 100%; transform-origin: left; transition: transform .3s ease; }
.chance-meter i { background: repeating-linear-gradient(105deg, #65b940 0 14px, #8cdb52 14px 22px); box-shadow: 0 0 13px #76d84c; }
.terror-meter i { transform: scaleX(0); background: repeating-linear-gradient(105deg, #7e244d 0 14px, #c82f4d 14px 22px); box-shadow: 0 0 13px #ca3152; }
.clock-block, .score-block { text-align: center; }
.clock-block span, .score-block span { display: block; color: #bca98a; font: 800 9px/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: .12em; text-transform: uppercase; }
.clock-block time { color: var(--gold); font-size: 31px; line-height: 1; text-shadow: 2px 2px #5b3619; }
.score-block output { font-size: 20px; letter-spacing: .07em; }
.icon-button { width: 45px; height: 45px; border: 2px solid #69584e; border-radius: 50%; background: #2f2434; color: var(--cream); font-size: 19px; box-shadow: 0 3px 0 #0c090f; }

.stage { position: relative; min-height: 0; overflow: hidden; isolation: isolate; background: #171220; touch-action: none; }
#game-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; cursor: crosshair; }
.screen-flash { position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: 0; background: white; }
.announcement { position: absolute; z-index: 8; left: 50%; top: 42%; width: min(730px, calc(100% - 36px)); translate: -50% -50%; text-align: center; text-transform: uppercase; filter: drop-shadow(7px 9px 0 rgba(0,0,0,.45)); pointer-events: none; animation: announce-in .32s cubic-bezier(.2,1.5,.3,1); }
.announcement span { display: inline-block; padding: 5px 13px; border: 3px solid var(--ink); background: var(--gold); color: var(--ink); font-size: clamp(12px, 2vw, 18px); transform: rotate(-2deg); }
.announcement strong { display: block; color: white; font-size: clamp(42px, 9vw, 105px); line-height: .82; -webkit-text-stroke: clamp(2px, .4vw, 5px) var(--ink); }
.announcement p { display: inline-block; margin: 13px 0 0; padding: 8px 15px; border: 3px solid var(--ink); background: var(--red); color: white; font: 800 clamp(12px, 2vw, 17px)/1.2 ui-sans-serif, system-ui, sans-serif; transform: rotate(1deg); }
.objective-card { position: absolute; z-index: 3; left: 18px; top: 18px; width: min(330px, calc(100% - 36px)); padding: 12px 15px 13px; border: 3px solid #18101f; border-radius: 3px; background: rgba(245, 224, 183, .94); color: var(--ink); box-shadow: 6px 7px 0 rgba(10,7,14,.65); transform: rotate(-.5deg); pointer-events: none; }
.objective-card > span { color: #8b3033; font: 900 10px/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: .1em; text-transform: uppercase; }
.objective-card strong { display: block; margin-top: 4px; font-size: 22px; line-height: 1; text-transform: uppercase; }
.objective-card p { margin: 5px 0 9px; color: #55434c; font: 700 12px/1.3 ui-sans-serif, system-ui, sans-serif; }
.objective-time { height: 6px; overflow: hidden; background: #a99172; }
.objective-time i { display: block; width: 100%; height: 100%; background: var(--red); transform-origin: left; }
.combo { position: absolute; z-index: 3; right: 22px; top: 20px; color: var(--gold); text-align: right; transform: rotate(3deg); text-shadow: 3px 3px var(--ink); pointer-events: none; }
.combo span { display: block; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
.combo strong { font-size: 52px; line-height: .8; }
.power-hint { position: absolute; z-index: 3; right: 20px; bottom: 18px; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 2px solid var(--cream); border-radius: 8px; background: rgba(16,12,22,.9); color: white; font: 800 12px/1 ui-sans-serif, system-ui, sans-serif; box-shadow: 0 4px 0 #050308; }
.power-hint:disabled { opacity: .52; cursor: not-allowed; }
kbd { min-width: 48px; padding: 5px 7px; border: 1px solid #8e7f70; border-bottom-width: 4px; border-radius: 5px; background: #362a3d; color: white; text-align: center; }
.toast-region { position: absolute; z-index: 9; left: 50%; bottom: 20px; display: grid; gap: 8px; translate: -50% 0; pointer-events: none; }
.toast { min-width: min(390px, calc(100vw - 30px)); padding: 10px 16px; border: 3px solid var(--ink); border-radius: 3px; color: white; font: 900 13px/1.2 ui-sans-serif, system-ui, sans-serif; text-align: center; box-shadow: 5px 5px 0 rgba(0,0,0,.45); animation: toast-in .22s ease-out, toast-out .25s 1.4s forwards; }
.toast.good { background: #477f36; }
.toast.bad { background: var(--red); }

.comic-dialog { width: min(660px, calc(100% - 28px)); max-height: calc(100dvh - 28px); overflow-y: auto; padding: clamp(23px, 5vw, 44px); border: 5px solid var(--ink); border-radius: 4px; background: var(--paper); color: var(--ink); text-align: center; box-shadow: 14px 14px 0 rgba(0,0,0,.5); }
.comic-dialog::backdrop { background: rgba(5,3,9,.82); backdrop-filter: blur(5px); }
.comic-dialog h1, .comic-dialog h2 { margin: 3px 0 12px; text-transform: uppercase; line-height: .86; }
.comic-dialog h1 { font-size: clamp(40px, 8vw, 72px); }
.comic-dialog h2 { font-size: clamp(34px, 7vw, 58px); }
.comic-dialog h1 em { color: var(--red); font-style: normal; }
.comic-dialog > p:not(.eyebrow) { max-width: 510px; margin: 12px auto 20px; color: #584552; font: 700 15px/1.45 ui-sans-serif, system-ui, sans-serif; }
.eyebrow { margin: 0 0 8px; color: #8d3134; font: 950 11px/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: .14em; text-transform: uppercase; }
.moon-logo { position: relative; width: 100px; height: 100px; margin: -13px auto 10px; border: 5px solid var(--ink); border-radius: 50%; background: var(--gold); box-shadow: 5px 5px 0 var(--red-dark); transform: rotate(-4deg); }
.moon-logo span { position: absolute; inset: 18px 0 0; color: var(--red); font-size: 60px; line-height: 1; }
.moon-logo i { position: absolute; right: -33px; bottom: -16px; font: normal 45px/1 ui-sans-serif, system-ui, sans-serif; transform: rotate(17deg); }
.seed-field { display: grid; gap: 7px; width: min(360px, 100%); margin: 18px auto; text-align: left; }
.seed-field span { color: #785b54; font: 900 10px/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: .12em; text-transform: uppercase; }
.seed-field input { width: 100%; min-height: 48px; padding: 10px 13px; border: 3px solid var(--ink); border-radius: 3px; background: #fff8df; color: var(--ink); font: 900 16px/1 ui-monospace, monospace; text-align: center; text-transform: uppercase; }
.dialog-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.primary-button, .secondary-button { min-height: 50px; padding: 10px 20px; border: 3px solid var(--ink); border-radius: 3px; font-weight: 950; text-transform: uppercase; box-shadow: 0 5px 0 var(--ink); }
.primary-button { background: var(--red); color: white; }
.secondary-button { background: #f4c84c; color: var(--ink); }
.primary-button:active, .secondary-button:active { translate: 0 3px; box-shadow: 0 2px 0 var(--ink); }
.comic-dialog small { display: block; margin-top: 20px; color: #796a63; font: 700 11px/1.4 ui-sans-serif, system-ui, sans-serif; }
.how-to-play { width: min(510px, 100%); margin: 0 auto 18px; border: 2px solid #9a8064; background: #ead09d; color: #59484b; text-align: left; font: 750 12px/1.4 ui-sans-serif, system-ui, sans-serif; }
.how-to-play summary { min-height: 42px; padding: 12px 14px; color: var(--ink); font-weight: 950; cursor: pointer; text-transform: uppercase; }
.how-to-play ul { margin: 0; padding: 0 28px 14px 36px; }
.how-to-play li + li { margin-top: 5px; }
.reward-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.reward-card { min-height: 190px; padding: 15px 11px; border: 3px solid var(--ink); border-radius: 3px; background: #f7e8c3; color: var(--ink); box-shadow: 0 6px 0 #846d57; }
.reward-card:hover { translate: 0 -4px; background: #fff5d9; box-shadow: 0 10px 0 #846d57; }
.reward-card:active { translate: 0 3px; box-shadow: 0 3px 0 #846d57; }
.reward-card > span { display: block; color: #ac343a; font: 900 55px/1 Georgia, serif; }
.reward-card strong { display: block; margin: 9px 0 7px; font-size: 18px; line-height: 1; text-transform: uppercase; }
.reward-card small { margin: 0; color: #6a5554; font: 700 11px/1.35 ui-sans-serif, system-ui, sans-serif; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 20px 0; }
.result-grid div { padding: 12px 8px; border: 2px solid #9a8064; background: #ead09d; }
.result-grid dt { color: #745e55; font: 800 9px/1 ui-sans-serif, system-ui, sans-serif; text-transform: uppercase; }
.result-grid dd { margin: 5px 0 0; font-size: 24px; }
.seed-result { margin: 0 0 18px; color: #755d55; font: 800 12px/1 ui-sans-serif, system-ui, sans-serif; }
.pause-overlay { position: fixed; z-index: 20; inset: 78px 0 0; display: grid; place-content: center; justify-items: center; gap: 18px; background: rgba(7,5,10,.88); text-align: center; }
.pause-overlay strong { font-size: clamp(40px, 8vw, 75px); text-transform: uppercase; }

@keyframes announce-in { from { opacity: 0; transform: scale(.35) rotate(-8deg); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(18px) rotate(-2deg); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(12px); } }

@media (max-width: 800px) {
  .game-shell { grid-template-rows: 64px minmax(0, 1fr); }
  .hud { grid-template-columns: 72px 1fr 82px 1fr 42px; gap: 8px; padding: 6px 8px; }
  .brand { height: 48px; }
  .brand-friday { font-size: 9px; }
  .brand strong { right: 5px; font-size: 38px; }
  .score-block { display: none; }
  .clock-block time { font-size: 23px; }
  .clock-block span, .meter output { display: none; }
  .meter > div:first-child { font-size: 9px; }
  .meter-track { height: 12px; }
  .icon-button { width: 38px; height: 38px; }
  .objective-card { left: 9px; top: 9px; width: min(280px, calc(100% - 80px)); padding: 9px 11px; }
  .objective-card strong { font-size: 17px; }
  .objective-card p { font-size: 10px; }
  .combo { right: 9px; top: 12px; }
  .combo strong { font-size: 38px; }
  .pause-overlay { inset-block-start: 64px; }
}

@media (max-width: 560px) {
  .reward-options, .result-grid { grid-template-columns: 1fr 1fr; }
  .comic-dialog { padding: 22px 16px; }
  .power-hint { right: 9px; bottom: 9px; min-height: 48px; }
  .power-hint kbd { display: none; }
}

@media (max-height: 560px) {
  .game-shell { grid-template-rows: 54px minmax(0, 1fr); }
  .hud { padding-block: 3px; }
  .brand { height: 43px; }
  .objective-card { top: 6px; padding-block: 7px; }
  .objective-card p { margin-block: 3px 5px; }
  .comic-dialog { max-height: calc(100dvh - 12px); padding-block: 18px; }
  .moon-logo { display: none; }
  .pause-overlay { inset-block-start: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
