/* RODNEY DANGERFIELD SIMULATOR — lost SNES cartridge aesthetic */

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

:root {
  --panel: #1a1c4e;
  --panel2: #2a2d7a;
  --border-out: #10102a;
  --gold: #ffd23e;
  --red: #e83b3b;
  --green: #63e05c;
  --cyan: #4fd8eb;
  --text: #f4f0e6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #0b0b16;
  overflow: hidden;
  font-family: 'PressStart', monospace;
  color: var(--text);
  image-rendering: pixelated;
}

img { image-rendering: pixelated; }

#stage-wrap {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#stage {
  position: relative;
  width: 960px;
  height: 540px;
  background: #000;
  overflow: hidden;
  transform-origin: center center;
  box-shadow: 0 0 0 4px #000, 0 0 60px #000;
}

/* faint scanlines — this cartridge ships with its own TV */
#stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  background: repeating-linear-gradient(
    to bottom, transparent 0 2px, rgba(0, 0, 0, 0.14) 2px 4px);
}

.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

.backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.backdrop.dim { filter: brightness(0.45); }

/* ---------- SNES RPG dialog boxes ---------- */

.rpg-box {
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 4px solid #fff;
  outline: 4px solid var(--border-out);
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px var(--border-out);
  padding: 14px;
}

.rpg-btn {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 3px solid #fff;
  outline: 3px solid var(--border-out);
  border-radius: 4px;
  padding: 12px 18px;
  cursor: pointer;
  text-shadow: 2px 2px 0 #000;
}
.rpg-btn:hover { background: linear-gradient(180deg, #3b3fa8, var(--panel2)); }
.rpg-btn:active { transform: translateY(2px); }
.rpg-btn.small { font-size: 9px; padding: 8px 10px; }
.rpg-btn.corner { position: absolute; top: 12px; right: 12px; z-index: 10; }
.rpg-btn:disabled { opacity: 0.45; cursor: default; }

.blink { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- loading ---------- */

#screen-loading { background: #0b0b16; }
.load-box {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 560px;
  font-size: 11px;
  text-align: center;
}
.load-bar { margin-top: 14px; height: 18px; border: 3px solid #fff; background: #000; }
#load-fill { height: 100%; width: 0%; background: var(--gold); transition: width 0.15s steps(4); }

/* ---------- title ---------- */

.title-logo {
  position: absolute;
  top: 26px;
  width: 100%;
  text-align: center;
  z-index: 2;
}
.title-logo h1 {
  font-size: 34px;
  line-height: 1.35;
  color: var(--gold);
  text-shadow: 4px 4px 0 var(--red), 8px 8px 0 #000;
  letter-spacing: 2px;
}
.title-logo h1 span { color: var(--cyan); }
.tagline { margin-top: 10px; font-size: 11px; color: var(--red); text-shadow: 2px 2px 0 #000; }

#btn-start {
  position: absolute;
  left: 50%; bottom: 120px;
  transform: translateX(-50%);
  z-index: 2;
  font-size: 18px;
}
.title-note {
  position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%);
  font-size: 9px; color: var(--cyan); text-shadow: 2px 2px 0 #000; z-index: 2;
}
.title-foot {
  position: absolute; bottom: 40px; width: 100%;
  display: flex; justify-content: center; gap: 16px; z-index: 2;
}
.disclaimer {
  position: absolute; bottom: 8px; width: 100%;
  text-align: center; font-size: 7px; color: #9aa;
  text-shadow: 1px 1px 0 #000; z-index: 2;
}

/* ---------- circuit map ---------- */

.map-head {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 28px; font-size: 10px; z-index: 2; padding: 10px 16px;
  white-space: nowrap;
}
#map-laughs { color: var(--gold); }

#venue-list {
  position: absolute; top: 66px; left: 50%; transform: translateX(-50%);
  width: 640px; display: flex; flex-direction: column; gap: 8px; z-index: 2;
}
.venue-card {
  display: flex; align-items: center; gap: 14px;
  padding: 7px 12px; cursor: pointer; font-size: 11px;
  transition: transform 0.1s steps(2);
}
.venue-card:hover:not(.locked) { transform: translateX(8px); }
.venue-card.locked { opacity: 0.55; cursor: default; filter: grayscale(0.7); }
.venue-thumb { width: 80px; height: 45px; object-fit: cover; border: 3px solid #fff; outline: 2px solid var(--border-out); }
.venue-info { flex: 1; }
.venue-name { color: var(--gold); margin-bottom: 6px; }
.venue-sub { font-size: 8px; color: var(--cyan); margin-bottom: 4px; }
.venue-best { font-size: 8px; color: #9aa; }
.venue-state { font-size: 20px; width: 34px; text-align: center; }
.venue-card.beaten .venue-state { color: var(--green); }

.map-foot {
  position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  font-size: 7px; color: var(--gold); padding: 8px 14px; max-width: 920px;
  white-space: nowrap;
}

/* ---------- gig ---------- */

#spotlight {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse 300px 420px at 50% 78%,
    rgba(255, 244, 200, 0.28), rgba(0, 0, 0, 0.55) 70%);
  transition: background 0.3s;
}
#screen-gig.standoff #spotlight {
  background: radial-gradient(ellipse 280px 400px at 50% 78%,
    rgba(255, 60, 60, 0.35), rgba(20, 0, 0, 0.8) 70%);
}

#rodney {
  position: absolute; left: 50%; bottom: 96px;
  transform: translateX(-50%);
  height: 240px; z-index: 2;
}
#rodney.tug { animation: tug-jitter 0.18s steps(2) infinite; }
@keyframes tug-jitter { 50% { transform: translateX(-50%) translateY(-3px) scale(1.02, 0.98); } }
#rodney.bombed { filter: saturate(0.6) brightness(0.85); }

#sweat-fx { position: absolute; left: 50%; bottom: 260px; z-index: 3; pointer-events: none; }
.sweat-drop {
  position: absolute; width: 8px; height: 8px; background: var(--cyan);
  box-shadow: 2px 2px 0 #000;
  animation: sweat-fly 0.7s steps(6) forwards;
}
@keyframes sweat-fly {
  to { transform: translate(var(--dx), 70px); opacity: 0; }
}

#hud {
  position: absolute; top: 10px; left: 10px; right: 10px;
  display: flex; gap: 10px; align-items: stretch; z-index: 5;
}
.hud-block { flex: 1; padding: 8px 10px; font-size: 8px; }
.hud-label { color: var(--cyan); margin-bottom: 6px; letter-spacing: 1px; }
#gig-round { font-size: 10px; color: var(--text); margin-bottom: 4px; }
#sweat-row { font-size: 10px; color: var(--cyan); min-height: 12px; }

.meter { position: relative; height: 20px; background: #000; border: 3px solid #fff; }
#crowd-fill {
  height: 100%; width: 50%;
  background: linear-gradient(90deg, var(--red), var(--gold), var(--green));
  transition: width 0.4s steps(8);
}
#redline { position: absolute; top: -4px; bottom: -4px; width: 4px; background: var(--red); }

.hud-block.respect { max-width: 150px; text-align: center; }
.dial {
  position: relative; width: 84px; height: 46px; margin: 0 auto;
  border: 3px solid var(--gold); border-bottom: none;
  border-radius: 84px 84px 0 0; background: #000;
  overflow: hidden;
}
.dial.big { width: 220px; height: 118px; border-radius: 220px 220px 0 0; border-width: 6px; }
#respect-needle, #finale-needle {
  position: absolute; bottom: 0; left: 50%;
  width: 4px; height: 38px; background: var(--red);
  transform-origin: bottom center;
  transform: rotate(-84deg);
  transition: transform 0.5s;
}
#finale-needle { height: 104px; width: 8px; }
.dial-pin {
  position: absolute; bottom: -5px; left: 50%; transform: translateX(-50%);
  width: 10px; height: 10px; background: var(--gold); border-radius: 50%;
}
.dial.gold { border-color: #fff; box-shadow: 0 0 24px var(--gold), inset 0 0 18px var(--gold); }

#btn-tie { align-self: center; }

#dialog {
  position: absolute; left: 20px; right: 20px; bottom: 14px;
  min-height: 96px; z-index: 6; font-size: 12px; line-height: 1.8;
}
#dialog-name {
  position: absolute; top: -16px; left: 14px;
  background: var(--red); color: #fff; font-size: 9px;
  padding: 4px 10px; border: 3px solid #fff; outline: 2px solid var(--border-out);
}
#dialog-text { min-height: 44px; }
#dialog-next { position: absolute; right: 12px; bottom: 6px; animation: bob 0.7s steps(2) infinite; }
@keyframes bob { 50% { transform: translateY(3px); } }

#punchlines {
  position: absolute; left: 50%; bottom: 130px; transform: translateX(-50%);
  display: flex; gap: 12px; z-index: 7; width: 92%;
  justify-content: center;
}
.cue-card {
  flex: 1; max-width: 300px;
  background: #f4ecd0; color: #23231f;
  border: 4px solid #23231f; border-radius: 4px;
  padding: 12px; font-size: 10px; line-height: 1.7;
  cursor: pointer; transform: rotate(-1deg);
  box-shadow: 4px 4px 0 rgba(0,0,0,0.5);
}
.cue-card:nth-child(2) { transform: rotate(1deg); }
.cue-card:nth-child(3) { transform: rotate(-2deg); }
.cue-card:hover { transform: rotate(0deg) translateY(-8px); background: #fffbe8; }

#timing {
  position: absolute; left: 50%; bottom: 140px; transform: translateX(-50%);
  width: 70%; z-index: 7; text-align: center;
}
.timing-label { font-size: 13px; color: var(--gold); text-shadow: 2px 2px 0 #000; margin-bottom: 10px; }
.key-hint { color: var(--cyan); font-size: 9px; }
#timing-bar {
  position: relative; height: 34px; background: #000;
  border: 4px solid #fff; outline: 3px solid var(--border-out);
}
#timing-zone { position: absolute; top: 0; bottom: 0; background: #2c6d2f; }
#timing-sweet { position: absolute; top: 0; bottom: 0; background: var(--green); }
#timing-marker {
  position: absolute; top: -8px; bottom: -8px; width: 8px;
  background: var(--gold); box-shadow: 2px 2px 0 #000;
}
#timing-cover {
  position: absolute; top: -4px; bottom: -4px; width: 30%;
  background: repeating-linear-gradient(45deg, #777 0 8px, #999 8px 16px);
  border: 2px solid #fff;
}

#heckle-bubble {
  position: absolute; right: 60px; top: 150px; z-index: 8;
  max-width: 320px; background: #fff; color: #111;
  border: 4px solid #111; border-radius: 10px;
  padding: 12px; font-size: 10px; line-height: 1.7;
  cursor: pointer; text-align: center;
  animation: heckle-in 0.2s steps(3);
}
#heckle-bubble::after {
  content: ''; position: absolute; bottom: -18px; left: 40px;
  border: 10px solid transparent; border-top-color: #111;
}
#heckle-bubble b { color: var(--red); }
@keyframes heckle-in { from { transform: scale(0); } }

#reaction {
  position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%);
  z-index: 8; font-size: 30px; color: var(--gold);
  text-shadow: 4px 4px 0 var(--red), 7px 7px 0 #000;
  text-align: center; line-height: 1.5;
  animation: reaction-pop 0.25s steps(3);
}
#reaction .sub { display: block; font-size: 11px; color: var(--text); text-shadow: 2px 2px 0 #000; }
@keyframes reaction-pop { from { transform: translate(-50%, -50%) scale(0.2); } }

#float-layer { position: absolute; inset: 0; z-index: 8; pointer-events: none; overflow: hidden; }
.float-ha {
  position: absolute; font-size: 14px; color: var(--gold);
  text-shadow: 2px 2px 0 #000;
  animation: ha-rise 1.4s steps(10) forwards;
}
@keyframes ha-rise { to { transform: translateY(-130px) rotate(var(--rot)); opacity: 0; } }

#standoff-overlay {
  position: absolute; inset: 0; z-index: 4; pointer-events: none;
  background: rgba(120, 0, 0, 0.25);
  animation: pulse-red 0.8s steps(4) infinite;
}
@keyframes pulse-red { 50% { background: rgba(120, 0, 0, 0.42); } }

/* hitstop: freeze all CSS animation for a beat */
#stage.hitstop * { animation-play-state: paused !important; transition: none !important; }
#stage.shake { animation: shake 0.25s steps(6); }
@keyframes shake {
  25% { transform: translate(-6px, 3px); }
  50% { transform: translate(5px, -4px); }
  75% { transform: translate(-3px, 2px); }
}

#flash {
  position: absolute; inset: 0; background: #fff; opacity: 0;
  pointer-events: none; z-index: 80;
}
#flash.on { animation: flash-fade 0.3s steps(4); }
@keyframes flash-fade { from { opacity: 0.9; } to { opacity: 0; } }

/* ---------- interlude ---------- */

.vignette-box {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 700px; font-size: 11px; line-height: 2; z-index: 2; padding: 22px;
}
.vignette-title { color: var(--gold); font-size: 13px; margin-bottom: 14px; }
#vignette-choices { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
#vignette-choices .rpg-btn { font-size: 10px; text-align: left; line-height: 1.6; }
.material-line { color: var(--cyan); }

/* ---------- finale ---------- */

#finale-box {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 640px; text-align: center; z-index: 2; padding: 26px;
  font-size: 11px; line-height: 2;
}
#finale-text { margin-top: 16px; min-height: 80px; }
#finale-needle.dropped {
  transition: transform 0.6s cubic-bezier(0.6, -0.3, 1, 1), bottom 0.6s ease-in;
  transform: rotate(140deg) !important;
  bottom: -80px;
}

#credits {
  position: absolute; inset: 0; z-index: 3;
  background: rgba(0, 0, 0, 0.85);
  text-align: center; font-size: 11px; line-height: 2.4;
  overflow: hidden;
}
#credits .roll { animation: credits-roll 26s linear forwards; padding-top: 540px; }
@keyframes credits-roll { to { transform: translateY(-160%); } }
#credits h2 { color: var(--gold); font-size: 16px; margin: 18px 0; }
#credits .ach {
  display: inline-block; margin: 12px 0; padding: 14px 20px;
  border: 4px solid var(--gold); color: var(--gold); font-size: 13px;
}
