:root {
  --glow: 1;              /* lowered by script.js as the night goes on */
  --gold: #f6c453;
  --gold-dark: #a8741a;
  --red: #b3122b;
  --red-dark: #4a0611;
  --ig-blue: #3797f0;
  --ig-purple: #8c3aea;
  --ig-pink: #d62976;
  --dm-bg: #000;
  --dm-text: #f5f5f5;
  --dm-muted: #a8a8a8;
  --dm-incoming: #262626;
  --speed: 1;              /* animation multiplier; reduced-motion lowers it */
}

@media (prefers-reduced-motion: reduce) {
  :root { --speed: 0.25; }
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 60, 90, calc(.18 * var(--glow))), transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(120, 30, 200, calc(.2 * var(--glow))), transparent 60%),
    #0b0710;
  color: var(--dm-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
  transition: background 2s;
}

.stage {
  height: 100vh;
  height: 100dvh;   /* dynamic viewport: excludes mobile browser bars */
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 16px;
}

/* ───────── Cabinet ───────── */
.machine {
  position: relative;
  width: min(440px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 14px 18px 16px;
  border-radius: 34px 34px 22px 22px;
  /* Instagram logo gradient: yellow → orange → pink → purple → blue */
  background:
    linear-gradient(180deg, rgba(255,255,255,.22), transparent 18%),
    radial-gradient(circle at 15% 105%, #feda75 0%, #fa7e1e 18%, #d62976 42%, #962fbf 68%, #4f5bd5 100%);
  border: 6px solid rgba(255, 255, 255, .85);
  box-shadow:
    inset 0 0 0 3px rgba(255, 255, 255, .35),
    inset 0 0 40px rgba(60, 0, 40, .45),
    0 0 calc(60px * var(--glow)) rgba(214, 41, 118, calc(.55 * var(--glow))),
    0 30px 60px rgba(0,0,0,.7);
  filter: saturate(calc(.4 + .6 * var(--glow)));
  transition: filter 2s, box-shadow 2s;
}

/* Marquee bulbs */
.bulbs {
  display: flex;
  justify-content: space-between;
  padding: 0 6px;
}
.bulbs-top { margin-bottom: 8px; }
.bulbs-bottom { margin-top: 12px; }
.bulb {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #fff6c8;
  box-shadow: 0 0 calc(10px * var(--glow)) 2px rgba(255, 220, 120, var(--glow));
  animation: blink calc(1.2s / var(--speed)) infinite;
  opacity: calc(.35 + .65 * var(--glow));
}
.bulb:nth-child(odd) { animation-delay: calc(.6s / var(--speed)); }
@keyframes blink {
  0%, 49% { background: #fff6c8; }
  50%, 100% { background: #7a4b12; box-shadow: none; }
}

.machine.bust .bulb { animation: none; background: #3b2a10; box-shadow: none; }

/* Title */
.marquee { text-align: center; margin-bottom: 10px; }
.neon {
  margin: 0;
  font-family: "Brush Script MT", "Snell Roundhand", cursive;
  font-weight: 400;
  font-size: 26px;
  line-height: 1;
  color: #ffe9f2;
  text-shadow:
    0 0 4px #fff,
    0 0 calc(12px * var(--glow)) #ff4f9a,
    0 0 calc(26px * var(--glow)) #ff2d6f;
  animation: flicker 6s infinite;
}
.neon span {
  font-family: "Impact", "Arial Black", sans-serif;
  font-size: 30px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #fff3c4;
  text-shadow:
    0 0 4px #fff,
    0 0 calc(12px * var(--glow)) var(--gold),
    0 0 calc(24px * var(--glow)) #ff9d00;
}
@keyframes flicker {
  0%, 92%, 96%, 100% { opacity: 1; }
  94% { opacity: .55; }
}

/* ───────── Reels ───────── */
.reel-panel {
  background: linear-gradient(180deg, #2a2a2a, #111);
  border: 3px solid #c9c9c9;
  border-radius: 14px;
  padding: 10px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,.8);
}
.reels {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.reel {
  height: 64px;
  border-radius: 8px;
  background: linear-gradient(180deg, #bdbdbd 0%, #fff 30%, #fff 70%, #bdbdbd 100%);
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: inset 0 0 8px rgba(0,0,0,.5);
}
.sym {
  font-size: 36px;
  line-height: 1;
  display: block;
}
.reel.spinning .sym {
  filter: blur(2px);
  animation: roll calc(.09s / var(--speed)) linear infinite;
}
.reel.slow .sym {
  filter: blur(1px);
  animation: roll calc(.5s / var(--speed)) linear infinite;
}
@keyframes roll {
  from { transform: translateY(-40%); }
  to   { transform: translateY(40%); }
}
.reel.landed .sym { animation: land calc(.25s / var(--speed)) ease-out; }
@keyframes land {
  0% { transform: translateY(-30%); }
  70% { transform: translateY(8%); }
  100% { transform: translateY(0); }
}

.payline {
  position: absolute;
  left: -4px; right: -4px; top: 50%;
  height: 2px;
  background: rgba(255, 40, 60, .6);
  pointer-events: none;
}
.reels.win .reel { animation: winflash calc(.3s / var(--speed)) 6 alternate; }
.reels.win .payline { background: #ffe25b; box-shadow: 0 0 10px #ffe25b; height: 3px; }
@keyframes winflash {
  from { box-shadow: inset 0 0 8px rgba(0,0,0,.5); }
  to   { box-shadow: inset 0 0 8px rgba(0,0,0,.5), 0 0 18px 4px #ffe25b; }
}
.reels.heartbreak .reel { animation: heartflash calc(.5s / var(--speed)) 3 alternate; }
.reels.heartbreak .payline { background: #ff2d55; box-shadow: 0 0 10px #ff2d55; }
@keyframes heartflash {
  from { box-shadow: inset 0 0 8px rgba(0,0,0,.5); }
  to   { box-shadow: inset 0 0 8px rgba(0,0,0,.5), 0 0 16px 3px rgba(255, 45, 85, .8); }
}
.reels.near .reel:nth-child(-n+2) { box-shadow: inset 0 0 8px rgba(0,0,0,.5), 0 0 12px 2px rgba(255, 60, 60, .7); }

.meters {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.meter {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  background: #000;
  border-radius: 6px;
  padding: 4px 10px;
  font-family: "Courier New", monospace;
  border: 1px solid #333;
}
.meter-label { font-size: 11px; color: #ff9f43; letter-spacing: 1px; }
.meter-value {
  font-size: 18px;
  font-weight: 700;
  color: #ff3b3b;
  text-shadow: 0 0 6px rgba(255, 59, 59, .8);
}
.meter-value.up { color: #4dff7a; text-shadow: 0 0 6px rgba(77,255,122,.8); }

/* ───────── Phone / DM ───────── */
.phone {
  position: relative;
  margin-top: 14px;
  border-radius: 22px;
  border: 6px solid #111;
  outline: 2px solid #555;
  background: var(--dm-bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;          /* fill whatever height is left in the cabinet */
  min-height: 0;
}

.dm-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #262626;
  background: #000;
  z-index: 2;
}
.back { font-size: 28px; line-height: 1; color: var(--dm-text); margin-top: -4px; }
.avatar {
  position: relative;
  flex: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 38%, #cfcfcf 0 22%, transparent 23%),
    radial-gradient(circle at 50% 100%, #cfcfcf 0 45%, transparent 46%),
    #5a5a5a;
}
.avatar.small { width: 28px; height: 28px; }
.avatar.big { width: 84px; height: 84px; }
.active-dot {
  position: absolute;
  right: -1px; bottom: -1px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #1ed760;
  border: 2px solid #000;
  transform: scale(0);
  transition: transform .3s;
}
.active-dot.on { transform: scale(1); }
.who { flex: 1; min-width: 0; }
.name { font-weight: 600; font-size: 15px; }
.status { font-size: 12px; color: var(--dm-muted); min-height: 15px; transition: color .3s; }
.status.active { color: var(--dm-muted); }
.icons { display: flex; gap: 14px; color: var(--dm-text); }
.icons svg { width: 22px; height: 22px; }

/* Notification banner */
.notif {
  position: absolute;
  top: 8px; left: 8px; right: 8px;
  z-index: 5;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(40, 40, 40, .95);
  backdrop-filter: blur(8px);
  font-size: 13px;
  line-height: 1.3;
  transform: translateY(-140%);
  transition: transform calc(.45s / var(--speed)) cubic-bezier(.2, .9, .3, 1.2);
}
.notif span { color: #d0d0d0; }
.notif.show { transform: translateY(0); }

.thread {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}
.thread::-webkit-scrollbar { width: 0; }

.intro {
  margin: auto 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-bottom: 20px;
}
.intro-name { font-weight: 600; font-size: 18px; margin-top: 6px; }
.intro-sub { color: var(--dm-muted); font-size: 13px; }

.timestamp {
  align-self: center;
  color: var(--dm-muted);
  font-size: 11px;
  margin: 8px 0 6px;
}

.msg {
  position: relative;
  max-width: 82%;
  padding: 9px 14px;
  border-radius: 22px;
  font-size: 15px;
  line-height: 1.35;
  white-space: pre-line;
  word-wrap: break-word;
  animation: pop calc(.3s / var(--speed)) ease-out;
}
.msg.out {
  align-self: flex-end;
  color: #fff;
  background: linear-gradient(160deg, var(--ig-blue), var(--ig-purple));
  background-attachment: fixed;
}
.msg.in {
  align-self: flex-start;
  background: var(--dm-incoming);
  margin-left: 36px;
}
.msg.in::before {
  content: "";
  position: absolute;
  left: -36px; bottom: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 38%, #cfcfcf 0 22%, transparent 23%),
    radial-gradient(circle at 50% 100%, #cfcfcf 0 45%, transparent 46%),
    #5a5a5a;
}
.msg.liked { margin-bottom: 14px; }
.heart {
  position: absolute;
  bottom: -14px; left: 10px;
  font-size: 11px;
  background: #262626;
  border: 2px solid #000;
  border-radius: 12px;
  padding: 1px 5px;
  animation: heartpop calc(.5s / var(--speed)) cubic-bezier(.3, 1.8, .5, 1);
}
@keyframes heartpop { from { transform: scale(0); } to { transform: scale(1); } }

@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

/* blurred placeholder for their unread message */
.ghost-lines { display: flex; flex-direction: column; gap: 6px; padding: 3px 0; filter: blur(2.5px); }
.ghost-lines i { display: block; height: 9px; border-radius: 5px; background: #8a8a8a; }
.ghost-lines i:nth-child(1) { width: 130px; }
.ghost-lines i:nth-child(2) { width: 80px; }

.receipt {
  align-self: flex-end;
  color: var(--dm-muted);
  font-size: 11px;
  margin: 2px 6px 6px 0;
  animation: pop calc(.3s / var(--speed)) ease-out;
}
.receipt.seen { color: #d8d8d8; }

.sysline {
  align-self: center;
  color: var(--dm-muted);
  font-size: 12px;
  margin: 8px 0;
  animation: pop calc(.3s / var(--speed)) ease-out;
}

.typing {
  align-self: flex-start;
  margin-left: 36px;
  position: relative;
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--dm-incoming);
  border-radius: 22px;
  animation: pop calc(.3s / var(--speed)) ease-out;
}
.typing::before {
  content: "";
  position: absolute;
  left: -36px; bottom: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #5a5a5a;
}
.typing i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #a8a8a8;
  animation: dot 1s infinite;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
.typing.gone { opacity: 0; transform: scale(.8); transition: all .4s; }

.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 10px 10px;
  padding: 6px 8px;
  border-radius: 22px;
  background: #262626;
  color: var(--dm-muted);
  font-size: 14px;
}
.cam {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  color: #fff;
  background: var(--ig-blue);
}

/* ───────── Controls ───────── */
.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.spin-btn {
  font: 800 18px/1 "Impact", "Arial Black", sans-serif;
  letter-spacing: 4px;
  color: #3a1500;
  padding: 14px 44px;
  border: none;
  border-radius: 40px;
  cursor: pointer;
  background: radial-gradient(circle at 50% 30%, #fff2a8, var(--gold) 50%, #c47d0e);
  box-shadow: 0 6px 0 #7a4a06, 0 0 calc(22px * var(--glow)) rgba(255, 200, 60, var(--glow));
  transition: transform .08s, box-shadow .08s;
}
.spin-btn:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 #7a4a06; }
.spin-btn:disabled { cursor: wait; filter: grayscale(.5) brightness(.85); }
.spin-btn:focus-visible, .lever:focus-visible, .replay:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.replay {
  background: none;
  border: none;
  color: #ffd6d6;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  opacity: .8;
}

/* ───────── Lever ───────── */
.lever {
  position: absolute;
  right: -46px;
  top: 150px;
  width: 40px;
  height: 190px;
  cursor: grab;
  perspective: 400px;
}
.lever-arm {
  position: absolute;
  left: 50%;
  bottom: 30px;
  width: 10px;
  height: 150px;
  margin-left: -5px;
  border-radius: 5px;
  background: linear-gradient(90deg, #777, #f3f3f3 45%, #888);
  transform-origin: 50% 100%;
}
.lever-knob {
  position: absolute;
  top: -22px; left: 50%;
  width: 34px; height: 34px;
  margin-left: -17px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff9aa6, #e0112f 45%, #6d0010);
  box-shadow: 0 0 calc(14px * var(--glow)) rgba(255, 40, 70, calc(.8 * var(--glow)));
}
.lever-base {
  position: absolute;
  bottom: 0; left: 0;
  width: 40px; height: 50px;
  border-radius: 8px 14px 14px 8px;
  background: linear-gradient(90deg, #8a8a8a, #e8e8e8 50%, #777);
  box-shadow: 0 4px 10px rgba(0,0,0,.6);
}
.lever.pulled .lever-arm { animation: pull calc(.7s / var(--speed)) ease-in-out; }
/* negative rotateX swings the knob toward the viewer and down, like a real pull */
@keyframes pull {
  0%   { transform: rotateX(0); }
  40%  { transform: rotateX(-150deg); }
  55%  { transform: rotateX(-145deg); }
  100% { transform: rotateX(0); }
}
.lever.disabled { cursor: wait; }
.lever.dead { cursor: not-allowed; filter: grayscale(.8) brightness(.6); }
.lever.dead .lever-knob { box-shadow: none; }
.spin-btn:disabled { cursor: not-allowed; }

/* Coins */
.coins { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 20; }
.coin {
  position: absolute;
  top: -40px;
  font-size: 26px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

/* Narrow screens: lever moves below the cabinet, beside the button */
@media (max-width: 560px) {
  /* full-screen machine on phones */
  .stage { padding: 0; }
  .machine {
    width: 100%;
    border: none;
    border-radius: 0;
    padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  }
  .lever { display: none; }
  .neon { font-size: 22px; }
  .neon span { font-size: 25px; }
}
