:root {
  --pink: #ff2d95;
  --cyan: #00e5ff;
  --gold: #ffd400;
  --display: "Luckiest Guy", "Arial Black", Impact, sans-serif;
  --body: "Fredoka", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #12002b; color: #fff;
  font-family: var(--body);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
body { position: fixed; inset: 0; transition: transform .9s cubic-bezier(.5, 1.5, .5, 1); }
body.flipped { transform: rotate(180deg); }
button { font-family: inherit; }
.hidden { display: none !important; }

#c {
  position: fixed; inset: 0; width: 100%; height: 100%;
  display: block; touch-action: none;
  transition: filter 3.5s ease-in; /* slow fade back to color after a sad spin */
}
#c.sad { filter: grayscale(1) brightness(.75); transition: filter .6s; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 0;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  pointer-events: none; transition: opacity .5s;
}
#meter { flex: 0 0 min(300px, 52vw); } /* fixed width: never squeezed by the stats */
#meter .label {
  font-family: var(--display); font-size: 14px; letter-spacing: 1px;
  color: var(--gold); text-shadow: 2px 2px 0 #000;
}
#meter .bar {
  height: 14px; border: 3px solid #000; border-radius: 10px; background: #2b1640;
  overflow: hidden; box-shadow: 3px 3px 0 #000;
}
#meter .bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, #00e5ff, #ff2d95, #ffd400, #00e5ff);
  background-size: 300% 100%;
  animation: shimmer 2s linear infinite;
  transition: width .7s cubic-bezier(.3, 1.6, .5, 1);
}
#meterName { font-size: 13px; font-weight: 600; margin-top: 5px; text-shadow: 1px 1px 0 #000; }
#meterName.bump { animation: bump .5s; }
.right { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
#mute {
  pointer-events: auto; width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid #000; background: #fff; font-size: 20px; line-height: 1;
  box-shadow: 3px 3px 0 #000; cursor: pointer; touch-action: manipulation; padding: 0;
}
#mute:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
#stats {
  font-size: 13px; font-weight: 600; text-align: right; text-shadow: 1px 1px 0 #000;
  line-height: 1.5;
}

/* ---------- spin button ---------- */
#spin {
  position: fixed; left: 50%; z-index: 6;
  transform: translateX(-50%);
  font-family: var(--display); font-size: 30px; letter-spacing: 2px;
  padding: 12px 46px 6px; color: #fff;
  background: linear-gradient(#ff6cb8, #e0006f);
  border: 4px solid #000; border-radius: 40px;
  box-shadow: 0 6px 0 #000, 0 0 30px rgba(255, 45, 149, .6);
  text-shadow: 3px 3px 0 #000;
  cursor: pointer; touch-action: manipulation;
  animation: pulse 1.1s ease-in-out infinite;
  transition: opacity .4s, filter .3s;
}
#spin:active:not(:disabled) { animation: none; transform: translateX(-50%) translateY(4px); box-shadow: 0 2px 0 #000; }
#spin:disabled { filter: grayscale(.85) brightness(.6); animation: none; cursor: default; }
#hint {
  position: fixed; left: 0; right: 0; z-index: 4; text-align: center;
  font-size: 14px; font-weight: 600; opacity: .8; pointer-events: none;
  text-shadow: 1px 1px 0 #000; transition: opacity .5s;
}
#hint.gone { opacity: 0; }

/* ---------- banner ---------- */
#banner {
  position: fixed; left: 50%; z-index: 7; width: min(94vw, 680px);
  transform: translate(-50%, -50%); text-align: center;
  pointer-events: none; opacity: 0;
}
#banner.show { animation: bannerIn 2.7s ease-out forwards; }
#banner .big {
  font-family: var(--display); font-size: clamp(40px, 12vw, 92px); line-height: 1;
  color: #fff; -webkit-text-stroke: 3px #000;
  text-shadow: 5px 5px 0 #000, 0 0 30px rgba(255, 255, 255, .45);
  paint-order: stroke fill;
}
#banner .small {
  display: inline-block; margin-top: 12px; padding: 7px 13px;
  font-weight: 600; font-size: clamp(15px, 4.2vw, 20px);
  background: rgba(10, 0, 25, .82); border: 2px solid rgba(255, 255, 255, .5); border-radius: 14px;
  box-shadow: 3px 3px 0 #000; max-width: 92%;
}
#banner .small:empty { display: none; }
#banner.bl .big { color: #ff3355; animation: jitter .06s linear infinite; }
#banner.win .big { color: var(--gold); animation: rainbow .5s linear infinite; }
#banner.sad .big { color: #9bb0d0; }
#banner.dread .big { color: #777; font-size: clamp(30px, 9vw, 64px); }

/* ---------- toasts ---------- */
#toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 8;
  width: min(94vw, 460px);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none; transition: opacity .5s;
}
.toast {
  background: rgba(20, 0, 40, .92); border: 2px solid #fff; border-radius: 14px;
  padding: 8px 14px; font-weight: 600; font-size: 14px; text-align: center;
  box-shadow: 3px 3px 0 #000;
  animation: toastIn .4s cubic-bezier(.3, 1.6, .5, 1);
  transition: opacity .4s, transform .4s;
}
.toast.ach { border-color: var(--gold); color: var(--gold); }
.toast.music { border-color: var(--cyan); }
.toast.out { opacity: 0; transform: translateY(-10px); }


/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 20; display: flex;
  padding: calc(env(safe-area-inset-top) + 34px) 14px calc(env(safe-area-inset-bottom) + 20px);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: rgba(10, 0, 25, .6);
}
#title { background: rgba(10, 0, 25, .78); }
.screen > * { margin: auto; }

.btn {
  display: inline-block; text-decoration: none; text-align: center;
  font-family: var(--display); font-size: 20px; letter-spacing: 1px; color: #fff;
  padding: 12px 18px 8px; border: 3px solid #000; border-radius: 16px;
  background: linear-gradient(#ff6cb8, #e0006f); box-shadow: 0 5px 0 #000;
  text-shadow: 2px 2px 0 #000; cursor: pointer; touch-action: manipulation;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #000; }
.btn.big { font-size: 34px; padding: 14px 54px 8px; border-radius: 40px; animation: pulseBtn 1.1s ease-in-out infinite; }
.btn.alt { background: linear-gradient(#4de8ff, #0090c0); }
.btn.ghost {
  background: transparent; border-color: rgba(255, 255, 255, .5); box-shadow: none;
  font-family: var(--body); font-weight: 600; font-size: 16px; text-shadow: none;
}

/* title */
.title-wrap { text-align: center; max-width: 520px; }
.rules-head { font-weight: 700; font-size: 20px; }
.rules-sub { font-size: 17px; font-weight: 600; }
.rules ol { text-align: left; margin: 8px auto; padding-left: 24px; max-width: 400px; }
.rules li { margin: 4px 0; }
.rules-warn { font-size: 15px; }
.logo { font-family: var(--display); line-height: .95; }
.logo .word { font-size: clamp(64px, 20vw, 130px); white-space: nowrap; }
.logo .of { font-size: clamp(22px, 6vw, 34px); color: var(--gold); text-shadow: 3px 3px 0 #000; margin: 2px 0; }
.logo .l {
  display: inline-block; -webkit-text-stroke: 3px #000; paint-order: stroke fill;
  text-shadow: 6px 6px 0 #000; animation: bob 1s ease-in-out infinite;
}
.rules {
  background: rgba(0, 0, 0, .55); border: 2px solid rgba(255, 255, 255, .3);
  border-radius: 16px; padding: 12px 14px; line-height: 1.55; margin-bottom: 22px; font-size: 16px;
}
.gold { color: var(--gold); }
.red { color: #ff3355; }
.title-wrap .btn { margin: 4px; }
.sound-note { margin-top: 16px; font-size: 13px; opacity: .75; }

/* blacklisted */
.panel {
  width: min(92vw, 420px); text-align: center;
  background: #160822; border: 4px solid #000; border-radius: 24px;
  box-shadow: 0 0 0 3px #ff3355, 8px 8px 0 3px #000; padding: 24px 18px;
  animation: cardIn .6s cubic-bezier(.3, 1.6, .5, 1);
}
.dead-title {
  font-family: var(--display); font-size: clamp(36px, 11.5vw, 64px); color: #ff3355;
  -webkit-text-stroke: 3px #000; paint-order: stroke fill; text-shadow: 5px 5px 0 #000; line-height: 1;
}
.bl-icon { font-size: 56px; line-height: 1; margin-bottom: 6px; }
.bl-msg { font-size: 18px; font-weight: 600; margin: 14px 0 0; }
.bl-gap { height: 110px; }
.bl-jk { font-size: 14px; opacity: .75; margin: 0 0 18px; }
.bl-or { margin: 26px 0 8px; font-size: 14px; color: #ff8899; font-style: italic; }
.btn.sac { background: linear-gradient(#c0001f, #5a0010); font-size: 20px; }
.btn.sac:disabled { filter: grayscale(.9) brightness(.55); cursor: default; }
.bl-note { font-size: 12px; opacity: .7; margin: 8px 0 0; }
body.ritual #hud, body.ritual #spin, body.ritual #hint, body.ritual #toasts { opacity: 0; pointer-events: none; }
body.dreading #spin, body.dreading #hint, body.dreading #toasts { opacity: 0; pointer-events: none; }
body.dreading #hud { opacity: .15; }
#meter.full .bar { box-shadow: 3px 3px 0 #000, 0 0 14px 2px var(--gold); }
.panel .btn { margin: 4px; }

/* invite */
.card {
  width: min(94vw, 460px); position: relative; text-align: center;
  background: linear-gradient(160deg, #2a0055, #4a0070 60%, #7a0060);
  border: 4px solid #000; border-radius: 26px;
  box-shadow: 0 0 0 4px var(--gold), 10px 10px 0 4px #000;
  padding: 30px 18px 18px;
  animation: cardIn .7s cubic-bezier(.3, 1.6, .5, 1);
}
.ribbon {
  position: absolute; top: -24px; left: 50%; transform: translateX(-50%) rotate(-3deg);
  background: var(--gold); color: #000; font-family: var(--display); font-size: clamp(18px, 6vw, 26px);
  padding: 7px 22px 2px; border: 3px solid #000; border-radius: 12px; box-shadow: 4px 4px 0 #000;
  white-space: nowrap;
}
.pre { font-size: 14px; opacity: .85; margin-top: 4px; }
.card h1 {
  font-family: var(--display); font-weight: 400; font-size: clamp(32px, 9.5vw, 48px); line-height: 1;
  margin: 10px 0 6px; color: var(--gold);
  -webkit-text-stroke: 2px #000; paint-order: stroke fill; text-shadow: 4px 4px 0 #000;
}
#invHost { font-weight: 600; color: var(--cyan); }
.rows { text-align: left; margin: 14px 0 10px; display: grid; gap: 8px; }
.row {
  display: flex; gap: 10px; align-items: center;
  background: rgba(0, 0, 0, .32); border-radius: 12px; padding: 8px 12px;
  font-weight: 600; font-size: 16px;
}
.row .ico { font-size: 22px; }
.row small { display: block; opacity: .65; font-weight: 400; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
#invMsg { line-height: 1.5; margin: 12px 4px; }
#countdown { margin: 12px 0 16px; font-weight: 600; }
#countdown .units { display: flex; justify-content: center; gap: 8px; margin-bottom: 4px; }
#countdown .u {
  background: #000; border-radius: 10px; padding: 6px 8px; min-width: 56px;
  box-shadow: 0 0 0 2px var(--pink);
}
#countdown .u b { display: block; font-family: var(--display); font-size: 26px; color: var(--gold); font-weight: 400; }
#countdown .u span { font-size: 11px; opacity: .7; text-transform: uppercase; }
.inv-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.inv-btns .btn { flex: 1 1 100%; font-size: 22px; padding: 12px 6px 8px; white-space: nowrap; }
#invStats { font-size: 13px; opacity: .7; margin: 14px 0 6px; }
#keepPlaying { margin-top: 4px; }

/* ---------- animations ---------- */
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.07); } }
@keyframes pulseBtn { 50% { transform: scale(1.07); } }
@keyframes shimmer { to { background-position: 300% 0; } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-12px) rotate(4deg); } }
@keyframes bump { 40% { transform: scale(1.25); color: var(--gold); } }
@keyframes bannerIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.2) rotate(-12deg); }
  10% { opacity: 1; transform: translate(-50%, -50%) scale(1.25) rotate(5deg); }
  18% { transform: translate(-50%, -50%) scale(.94) rotate(-2deg); }
  25% { transform: translate(-50%, -50%) scale(1) rotate(0); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -62%) scale(1); }
}
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.8); } }
@keyframes cardIn { from { opacity: 0; transform: scale(.4) rotate(-8deg); } }
@keyframes rainbow { 0% { color: #ffd400; } 25% { color: #ff2d95; } 50% { color: #00e5ff; } 75% { color: #7cff4f; } }
@keyframes jitter { 0% { transform: translate(-3px, 2px); } 50% { transform: translate(3px, -2px); } 100% { transform: translate(-2px, -3px); } }

@media (max-height: 560px) {
  .logo .word { font-size: 56px; }
  .rules { font-size: 14px; margin-bottom: 12px; }
}
