:root {
  --bg: #f4efe6;
  --device: #fffdf8;
  --ink: #1f2430;
  --muted: #6b7280;
  --line: #e7dfd1;
  --party: #3b6fd8;
  --ok: #3aa25d;
  --mid: #e0a020;
  --low: #d64545;
  --stage: #e9f3ff;
  --stage-night: #1c2340;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161c; --device: #1d2029; --ink: #eceef3; --muted: #9aa1ad; --line: #2e3240;
    --stage: #263248; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161c; --device: #1d2029; --ink: #eceef3; --muted: #9aa1ad; --line: #2e3240;
  --stage: #263248; color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 16px/1.5 Rubik, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  display: flex; flex-direction: column; align-items: center; padding: 16px;
}
.device {
  width: 100%; max-width: 460px; background: var(--device); border: 1px solid var(--line);
  border-radius: 28px; padding: 18px; box-shadow: 0 10px 30px #0000001a;
}
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.5px; }
h1 span { color: var(--party); }
h2 { font-size: 1.25rem; margin: 10px 0; }
.countdown { font-size: 0.85rem; font-weight: 600; background: var(--bg); padding: 4px 10px; border-radius: 99px; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.hidden { display: none !important; }
.screen { text-align: center; }
footer { max-width: 460px; text-align: center; color: var(--muted); font-size: 0.75rem; margin-top: 14px; }

.btn {
  font: inherit; border: 1px solid var(--line); background: var(--device); color: var(--ink);
  padding: 10px 16px; border-radius: 14px; cursor: pointer; transition: transform .1s, background .2s;
}
.btn:active { transform: scale(0.96); }
.btn.primary { background: var(--party); color: #fff; border-color: transparent; font-weight: 600; padding: 12px 24px; }
.btn.link { background: none; border: none; color: var(--muted); text-decoration: underline; margin-top: 12px; }
.btn.danger { color: var(--low); }

/* stage */
.stage { width: 220px; height: 240px; margin: 0 auto; position: relative; }
.stage svg { width: 100%; height: 100%; overflow: visible; }
.game-stage {
  width: 100%; height: 290px; background: var(--stage); border-radius: 20px; margin: 10px 0;
  overflow: hidden; transition: background .6s; cursor: pointer;
}
.game-stage.night { background: var(--stage-night); }
.game-stage #pet { position: absolute; left: 50%; bottom: 6px; width: 220px; height: 250px; transform: translateX(-50%); }

/* character animation */
.bob { animation: bob 2.4s ease-in-out infinite; transform-origin: 100px 230px; }
.char-ecstatic .bob { animation: hop .7s ease-in-out infinite; }
.char-sad .bob, .char-miserable .bob { animation: droop 3.5s ease-in-out infinite; }
.char-sleeping .bob { animation: breathe 3s ease-in-out infinite; }
.eyes { animation: blink 4.5s infinite; transform-origin: 100px 105px; }
.tear { animation: tear 1.6s ease-in infinite; }
.tear2 { animation-delay: .8s; }
.zzz { animation: zzz 2.4s ease-out infinite; }
.z2 { animation-delay: 1.2s; }
.fly { animation: fly 1.4s linear infinite; transform-origin: 100px 100px; }
.fly2 { animation-duration: 1.9s; animation-direction: reverse; }
.chew { animation: chew .25s ease-in-out infinite alternate; transform-origin: 100px 138px; }
.char-ecstatic .arm-l { animation: wave-l .7s ease-in-out infinite alternate; transform-origin: 50px 196px; }
.char-ecstatic .arm-r { animation: wave-r .7s ease-in-out infinite alternate; transform-origin: 150px 196px; }

@keyframes bob { 50% { transform: translateY(-4px); } }
@keyframes hop { 50% { transform: translateY(-14px); } }
@keyframes droop { 50% { transform: translateY(3px) rotate(-2deg); } }
@keyframes breathe { 50% { transform: scale(1.02, 0.98); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
@keyframes tear { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(40px); opacity: 0; } }
@keyframes zzz { 0% { transform: translate(0, 0); opacity: 0; } 30% { opacity: 1; } 100% { transform: translate(14px, -24px); opacity: 0; } }
@keyframes fly { to { transform: rotate(360deg); } }
@keyframes chew { to { transform: scaleY(0.4); } }
@keyframes wave-l { to { transform: rotate(40deg); } }
@keyframes wave-r { to { transform: rotate(-40deg); } }

.egg .wobble { animation: wobble 1.2s ease-in-out infinite; transform-origin: 100px 226px; }
.egg.cracking .wobble { animation-duration: .25s; }
@keyframes wobble { 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
.pop { animation: pop .6s cubic-bezier(.3, 1.6, .5, 1); height: 100%; }
@keyframes pop { from { transform: scale(0.2); opacity: 0; } }

/* speech bubble */
.bubble {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%) scale(0.8); z-index: 3;
  max-width: 85%; background: #fff; color: #1f2430; padding: 8px 14px; border-radius: 16px;
  font-size: 0.9rem; box-shadow: 0 3px 10px #0002; opacity: 0; transition: .25s; pointer-events: none;
}
.bubble.show { opacity: 1; transform: translateX(-50%) scale(1); }

/* fx */
#fx { position: absolute; inset: 0; pointer-events: none; }
.fx { position: absolute; bottom: 90px; font-size: 1.8rem; animation: floatup 1.6s ease-out forwards; }
@keyframes floatup { to { transform: translateY(-140px); opacity: 0; } }

/* minigame */
.minigame { position: absolute; inset: 0; background: #ffffffd9; z-index: 4; }
.mg-head { font-weight: 600; padding: 10px; color: #1f2430; }
.ballot {
  position: absolute; font-size: 2rem; background: none; border: none; cursor: pointer;
  animation: pop .25s ease-out; padding: 4px;
}

/* stats */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; text-align: start; font-size: 0.8rem; }
.stat span { display: block; margin-bottom: 2px; }
.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar div { height: 100%; border-radius: 99px; transition: width .4s; }
.bar.ok div { background: var(--ok); }
.bar.mid div { background: var(--mid); }
.bar.low div { background: var(--low); }
.bar.mood div { background: var(--party); }

.actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 14px; }
.btn.action { display: flex; flex-direction: column; align-items: center; padding: 8px 2px; font-size: 1.4rem; }
.btn.action span { font-size: 0.72rem; margin-top: 2px; }
.food-menu { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }
.btn.food { padding: 8px 12px; }

.pet-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: start; font-size: 0.9rem; }
.poll-chip { white-space: nowrap; background: var(--bg); border-radius: 99px; padding: 4px 10px; font-size: 0.8rem; }
.up { color: var(--ok); }
.down { color: var(--low); }

/* polls table */
details.polls, details.others { margin-top: 14px; text-align: start; }
summary { cursor: pointer; font-weight: 600; }
.poll-row { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: 8px; font-size: 0.8rem; padding: 2px 4px; border-radius: 6px; }
.poll-row.mine { background: var(--bg); font-weight: 700; }
.poll-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.poll-bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.poll-bar div { height: 100%; }
.poll-seats { text-align: end; }

/* quiz */
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 10px 0; }
.progress div { height: 100%; background: var(--party); transition: width .3s; }
#quiz-question { min-height: 4.5em; display: flex; align-items: center; justify-content: center; }
.answers { display: flex; flex-direction: column; gap: 8px; }
.btn.answer.chosen { border-color: var(--party); border-width: 2px; }

/* match cards */
.matches { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.card {
  display: flex; align-items: center; gap: 12px; text-align: start; font: inherit; color: var(--ink);
  background: var(--device); border: 2px solid var(--line); border-inline-start: 8px solid var(--party);
  border-radius: 16px; padding: 6px 12px; cursor: pointer;
}
.card:hover { border-color: var(--party); }
.card-pic { width: 70px; height: 84px; flex: none; }
.card-pic svg { width: 100%; height: 100%; }
.card-pic .bob { animation: none; }
.card-text { display: flex; flex-direction: column; }
.card-text span { color: var(--muted); font-size: 0.85rem; }
.card-text em { color: var(--party); font-style: normal; font-weight: 700; font-size: 0.85rem; }
.matches.small .card-pic { width: 50px; height: 60px; }

.name-field { display: flex; flex-direction: column; gap: 4px; max-width: 240px; margin: 0 auto 12px; font-size: 0.85rem; }
.name-field input { font: inherit; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--device); color: var(--ink); text-align: center; }

@media (max-width: 380px) {
  .poll-row { grid-template-columns: 100px 1fr 40px; }
  .actions { gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; }
}

/* accounts */
.userbar { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; margin: -4px 0 6px; }
.userbar .btn.link { margin: 0; padding: 4px 0; }
.tabs { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; margin: 14px auto 12px; max-width: 280px; }
.tab { flex: 1; font: inherit; border: none; background: none; color: var(--muted); padding: 8px; border-radius: 9px; cursor: pointer; }
.tab.active { background: var(--device); color: var(--ink); font-weight: 600; box-shadow: 0 1px 4px #0001; }
.auth-form { display: flex; flex-direction: column; gap: 10px; max-width: 280px; margin: 0 auto; text-align: start; font-size: 0.85rem; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; }
.auth-form input { font: inherit; font-size: 1rem; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--device); color: var(--ink); }
.auth-form input:focus { outline: 2px solid var(--party); outline-offset: 1px; }
.error { color: var(--low); min-height: 1.2em; margin: 0; }
.btn:disabled { opacity: 0.6; cursor: wait; }

/* parody props & signature gestures */
.prop-arm { transform-box: view-box; transform-origin: 136px 198px; animation: gesture 3s ease-in-out infinite; }
@keyframes gesture { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-6deg); } }
.prop-bombchart { animation: present 2.6s ease-in-out infinite; }
@keyframes present { 0%, 100% { transform: rotate(0); } 40%, 60% { transform: rotate(-14deg) translateY(-4px); } }
.redline { stroke-dasharray: 46; animation: drawline 2.6s ease-in-out infinite; }
@keyframes drawline { 0%, 30% { stroke-dashoffset: 46; } 60%, 100% { stroke-dashoffset: 0; } }
.spark { animation: flicker .3s steps(2) infinite; }
@keyframes flicker { 50% { opacity: 0.2; } }
.wave { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }
.phone-screen { animation: pulse 1.4s ease-in-out infinite; }
.flag-cloth { transform-box: fill-box; transform-origin: left center; animation: flutter .9s ease-in-out infinite alternate; }
@keyframes flutter { to { transform: skewY(-6deg) scaleX(0.94); } }
.siren-l { animation: siren-l .5s steps(1) infinite; }
.siren-r { animation: siren-r .5s steps(1) infinite; }
.siren-glow { animation: flicker .25s steps(2) infinite; }
@keyframes siren-l { 50% { fill: #600; } }
@keyframes siren-r { 0% { fill: #001a66; } 50% { fill: #1a5cff; } }
.calc-digits { animation: flicker 1.2s steps(2) infinite; }
.prop-calculator { animation: tap .5s ease-in-out infinite alternate; }
@keyframes tap { to { transform: rotate(-3deg) translateY(2px); } }
.key-swing { transform-box: fill-box; transform-origin: center bottom; animation: jingle 1.2s ease-in-out infinite; }
@keyframes jingle { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
.money { animation: pulse 1.6s ease-in-out infinite; }
.sign-board { transform-box: fill-box; transform-origin: center bottom; animation: jingle 1.6s ease-in-out infinite; }
.deal { animation: pulse 1.8s ease-in-out infinite; }
.prop-megaphone, .prop-mic { animation: present 2s ease-in-out infinite; }
.smoke { animation: smoke 2.2s ease-out infinite; }
.s2 { animation-delay: 1.1s; }
@keyframes smoke { 0% { transform: translate(0, 0) scale(0.5); opacity: 0.8; } 100% { transform: translate(10px, -34px) scale(1.8); opacity: 0; } }
.shine { animation: pulse 2.2s ease-in-out infinite; }
.sparkle { transform-box: fill-box; transform-origin: center; animation: twinkle 2.2s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { transform: scale(0.2); opacity: 0; } 50% { transform: scale(1); opacity: 1; } }
.sweat { animation: tear 1.2s ease-in infinite; }
.pupils { animation: look 6s ease-in-out infinite; }
@keyframes look { 0%, 40%, 100% { transform: translateX(0); } 50%, 60% { transform: translateX(3px); } 70%, 80% { transform: translateX(-3px); } }
.char-ecstatic .prop-arm { animation-duration: .8s; }
.char-sad .prop-arm, .char-miserable .prop-arm { animation: none; transform: rotate(28deg); }
.char-sleeping .prop-arm { animation: none; transform: rotate(36deg); }
.head { transform-box: view-box; transform-origin: 100px 160px; animation: headbob 2.4s ease-in-out infinite; }
@keyframes headbob { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
.char-ecstatic .head { animation-duration: .7s; }
.talking .mouth { transform-box: fill-box; transform-origin: center; animation: talk .18s ease-in-out infinite alternate; }
@keyframes talk { to { transform: scaleY(0.35); } }
.card-pic .head, .card-pic .prop-arm, .card-pic * { animation-play-state: paused; }
.card:hover .card-pic * { animation-play-state: running; }

/* characters are drawn left-to-right regardless of page direction */
.char, .egg { direction: ltr; }

/* social login */
.social { display: flex; flex-direction: column; gap: 8px; max-width: 280px; margin: 14px auto 0; }
.social-btn { display: flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; font-weight: 500; }
.social-btn svg { width: 20px; height: 20px; flex: none; }
.social-btn.apple { background: #000; color: #fff; border-color: #000; }
.social-btn.facebook { background: #1877f2; color: #fff; border-color: #1877f2; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.8rem; margin-top: 4px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* news */
.ticker {
  margin-top: 8px; padding: 6px 12px; border-radius: 10px; background: #d6262e; color: #fff;
  font-size: 0.85rem; text-align: start; animation: pop .3s ease-out;
}
.ticker b { background: #fff; color: #d6262e; border-radius: 4px; padding: 0 6px; margin-inline-end: 6px; }
.news-item { padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 0.85rem; }
.news-item:last-child { border-bottom: none; }
.news-item.mine { font-weight: 500; }
.news-item a { color: inherit; }
.news-item small { display: block; color: var(--muted); font-size: 0.72rem; margin-top: 2px; font-weight: 400; }
.tag { display: inline-block; font-size: 0.7rem; padding: 1px 7px; border-radius: 99px; background: var(--line); margin-inline-end: 6px; }
.tag.up { background: #d9f2e1; color: #1d7a3f; }
.tag.down { background: #fbe0e0; color: #b42323; }

/* campaign events */
.event-card {
  position: absolute; inset: auto 12px 12px; z-index: 5; background: var(--device); color: var(--ink);
  border-radius: 16px; padding: 12px; box-shadow: 0 8px 24px #0003; animation: pop .35s ease-out;
}
.event-card p { margin: 4px 0 10px; font-weight: 500; }
.event-label { font-size: 0.72rem; font-weight: 700; color: var(--party); }
.event-choices { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.event-choices .btn { padding: 8px 12px; font-size: 0.9rem; }

/* sharing */
.share-btn { width: 100%; margin-top: 12px; font-weight: 600; border-color: var(--party); color: var(--party); }
#screen-end .share-btn { margin-bottom: 10px; }
.sheet-backdrop { position: fixed; inset: 0; background: #0008; display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.sheet {
  background: var(--device); color: var(--ink); width: 100%; max-width: 460px; border-radius: 24px 24px 0 0;
  padding: 18px 16px 12px; text-align: center; max-height: 92vh; overflow-y: auto; animation: slideup .25s ease-out;
}
@keyframes slideup { from { transform: translateY(40%); opacity: 0; } }
.sheet h3 { margin: 0 0 10px; }
#share-preview { width: 100%; max-width: 280px; aspect-ratio: 1; border-radius: 16px; background: var(--line); display: block; margin: 0 auto 12px; }
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.share-opt { text-decoration: none; font-size: 0.9rem; padding: 10px 8px; text-align: center; }
#share-whatsapp { background: #25d366; color: #fff; border-color: #25d366; }
#share-facebook { background: #1877f2; color: #fff; border-color: #1877f2; }
#share-x { background: #000; color: #fff; border-color: #000; }
#share-telegram { background: #229ed9; color: #fff; border-color: #229ed9; }
#share-native { grid-column: 1 / -1; background: var(--party); color: #fff; border-color: transparent; }
