:root {
  color-scheme: dark;
  --dark: #171522;
  --dark-deep: #100d19;
  --surface: rgba(35, 27, 52, .82);
  --surface-strong: rgba(48, 34, 74, .94);
  --surface-soft: rgba(255, 244, 232, .08);
  --pink: #ff4fa3;
  --purple: #7138b8;
  --blue: #36b9e9;
  --orange: #ff873d;
  --yellow: #f9d65c;
  --white: #fff4e8;
  --muted: #d2c5d6;
  --danger: #ff6b7d;
  --success: #62e3c0;
  --shadow: 0 24px 70px rgba(0, 0, 0, .36);
  --glow-pink: 0 0 28px rgba(255, 79, 163, .35);
  --glow-blue: 0 0 28px rgba(54, 185, 233, .3);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--dark); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100svh;
  overflow-x: hidden;
  color: var(--white);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 79, 163, .26), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(54, 185, 233, .2), transparent 26%),
    linear-gradient(150deg, var(--dark-deep), var(--dark) 52%, #241336);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .45;
  background: url("../assets/urban-grid.svg") center / 820px 820px;
  mix-blend-mode: screen;
}
button, input, select { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--yellow); outline-offset: 4px; }

.app-shell { width: 100%; min-height: 100svh; padding: max(18px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.screen { position: relative; width: min(100%, 760px); min-height: calc(100svh - 40px); margin: 0 auto; display: flex; flex-direction: column; gap: 20px; padding: clamp(24px, 5vw, 52px) clamp(18px, 6vw, 58px); overflow: hidden; border: 1px solid rgba(255, 244, 232, .14); border-radius: 36px; background: linear-gradient(145deg, rgba(35, 27, 52, .9), rgba(23, 21, 34, .82)); box-shadow: var(--shadow); backdrop-filter: blur(18px); animation: screen-in .42s ease both; }
.screen::before, .screen::after { content: ""; position: absolute; pointer-events: none; z-index: 0; }
.screen::before { width: 260px; height: 260px; top: -145px; right: -90px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 135, 61, .24), transparent 68%); }
.screen::after { width: 240px; height: 240px; right: -105px; bottom: -100px; background: url("../assets/digital-scribble.svg") center / contain no-repeat; opacity: .4; }
.screen > * { position: relative; z-index: 1; }
.screen.centered { justify-content: center; align-items: center; text-align: center; }
.home-screen { justify-content: center; gap: clamp(34px, 8vh, 72px); background: radial-gradient(circle at 50% 25%, rgba(113, 56, 184, .3), transparent 40%), linear-gradient(155deg, rgba(35, 27, 52, .92), rgba(23, 21, 34, .88)); }
.home-screen::before { top: 8%; left: -75px; right: auto; width: 210px; height: 130px; background: url("../assets/glitch-stamp.svg") center / contain no-repeat; opacity: .55; }
.brand-art { display: block; width: min(100%, 620px); height: auto; filter: drop-shadow(0 18px 18px rgba(0, 0, 0, .42)); transform: rotate(-3deg); }
.home-character-banner { display: block; width: min(100%, 560px); height: auto; image-rendering: pixelated; filter: drop-shadow(0 16px 18px rgba(0, 0, 0, .42)); animation: sprite-idle 3.2s ease-in-out infinite; }
.eyebrow { color: var(--blue); font-size: .74rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
h1, h2, p { margin: 0; }
h1 { max-width: 650px; color: var(--white); font-size: clamp(2.2rem, 9vw, 4.8rem); font-weight: 800; letter-spacing: -.06em; line-height: .94; text-wrap: balance; }
h2 { font-size: 1.5rem; }
.muted, .hint { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.row { display: flex; align-items: center; gap: 10px; width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; width: 100%; margin-top: auto; }
.button { min-height: 56px; padding: 14px 23px; border: 1px solid transparent; border-radius: 18px; color: var(--dark); background: linear-gradient(135deg, var(--yellow), var(--orange)); box-shadow: 0 10px 24px rgba(255, 135, 61, .2); font-weight: 800; transition: transform .2s ease, filter .2s ease, box-shadow .2s ease; }
.button:hover { transform: translateY(-2px); filter: brightness(1.08); box-shadow: var(--glow-pink); }
.button:active { transform: translateY(2px) scale(.98); }
.button.secondary { color: var(--white); background: rgba(255, 244, 232, .08); border-color: rgba(255, 244, 232, .18); box-shadow: none; }
.button.danger { color: var(--white); background: var(--danger); }
.button:disabled { cursor: not-allowed; opacity: .35; transform: none; box-shadow: none; }
.home-screen .button { min-width: min(100%, 250px); font-size: 1.15rem; }
.home-how-to-play { max-width: 30ch; color: var(--muted); white-space: pre-line; font-size: .98rem; line-height: 1.45; }
.discussion-starter { color: var(--yellow); font-size: clamp(1.1rem, 4vw, 1.5rem); }
.discussion-starter strong { color: var(--white); font-weight: 900; }
.input, .select { width: 100%; min-height: 56px; padding: 14px 16px; color: var(--white); background: rgba(255, 244, 232, .07); border: 1px solid rgba(255, 244, 232, .18); border-radius: 17px; box-shadow: inset 0 1px rgba(255, 255, 255, .06); }
.input::placeholder { color: rgba(255, 244, 232, .56); }
.input:focus, .select:focus { border-color: var(--blue); box-shadow: var(--glow-blue); }
.field { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.field label { color: var(--muted); font-size: .86rem; font-weight: 700; letter-spacing: .04em; }
.error { min-height: 1.25em; color: var(--danger); font-size: .9rem; }
.add-player-button { min-width: 58px; padding-inline: 14px; color: var(--dark); font-size: 1.8rem; line-height: 1; }
.player-list { display: flex; flex-direction: column; gap: 10px; width: 100%; max-height: 38vh; overflow: auto; padding: 4px; }
.player-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 14px 15px; border: 1px solid rgba(255, 244, 232, .12); border-radius: 18px; background: linear-gradient(110deg, rgba(113, 56, 184, .28), rgba(255, 244, 232, .06)); transition: transform .2s ease, border-color .2s ease, opacity .2s ease; }
.player-item:hover { border-color: rgba(54, 185, 233, .65); transform: translateX(3px); }
.player-item span { overflow-wrap: anywhere; }
.drag-handle { cursor: grab; font-weight: 700; }
.player-item.dragging { opacity: .4; border-color: var(--pink); }
.number-control { display: flex; align-items: center; gap: 18px; }
.count-value { min-width: 2ch; color: var(--yellow); text-align: center; font-size: 1.8rem; font-weight: 800; }
.icon-button { min-width: 44px; min-height: 44px; color: var(--white); background: rgba(255, 244, 232, .08); border: 1px solid rgba(255, 244, 232, .18); border-radius: 13px; transition: transform .2s, background .2s; }
.icon-button:hover { background: rgba(255, 79, 163, .2); transform: scale(1.05); }
.secret-card { display: grid; place-items: center; align-content: center; gap: 15px; width: 100%; min-height: min(360px, 46vh); padding: 32px; color: var(--white); border: 1px solid rgba(255, 244, 232, .18); border-radius: 30px; background: linear-gradient(145deg, rgba(255, 79, 163, .2), rgba(113, 56, 184, .32) 50%, rgba(54, 185, 233, .16)); box-shadow: var(--glow-pink), inset 0 1px rgba(255, 255, 255, .12); transition: transform .25s ease, filter .25s ease; }
.secret-card:hover { filter: brightness(1.1); transform: translateY(-3px) rotate(-.4deg); }
.secret-card:active { transform: scale(.98); }
.secret { color: var(--yellow); font-size: clamp(2.5rem, 12vw, 6rem); font-weight: 900; letter-spacing: -.06em; overflow-wrap: anywhere; animation: reveal-word .4s ease both; }
.reveal-icon { display: grid; place-items: center; width: 70px; height: 70px; color: var(--yellow); border: 2px solid var(--blue); border-radius: 50%; box-shadow: var(--glow-blue); font-size: 2rem; }
.timer { color: var(--orange); font-variant-numeric: tabular-nums; font-size: clamp(5rem, 25vw, 11rem); font-weight: 900; letter-spacing: -.09em; line-height: .9; text-shadow: 0 0 28px rgba(255, 135, 61, .32); }
.vote-list { display: grid; gap: 10px; width: 100%; max-height: 43vh; overflow: auto; padding: 3px; }
.vote-option { width: 100%; padding: 18px; color: var(--white); text-align: left; background: rgba(255, 244, 232, .07); border: 1px solid rgba(255, 244, 232, .16); border-radius: 18px; font-weight: 700; transition: transform .2s, border-color .2s, background .2s; }
.vote-option:hover { transform: translateX(4px); border-color: var(--blue); }
.vote-option.selected { color: var(--dark); background: linear-gradient(120deg, var(--blue), var(--success)); border-color: transparent; box-shadow: var(--glow-blue); }
.result-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 16px; border: 1px solid rgba(255, 244, 232, .12); border-radius: 18px; background: rgba(255, 244, 232, .07); }
.results-screen { max-width: 1120px; }
.results-screen h1 { max-width: 760px; }
.results-stage { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(230px, 1.25fr) minmax(150px, 1fr); align-items: end; gap: clamp(14px, 3vw, 32px); width: 100%; margin-top: 6px; }
.results-side-panel, .results-malandro { display: flex; flex-direction: column; align-items: center; min-width: 0; text-align: center; }
.results-side-panel { gap: 10px; padding: 16px 12px; border: 1px solid rgba(255, 244, 232, .12); border-radius: 26px; background: linear-gradient(160deg, rgba(255, 244, 232, .08), rgba(255, 244, 232, .025)); }
.results-correct { border-color: rgba(98, 227, 192, .32); }
.results-incorrect { border-color: rgba(255, 107, 125, .3); }
.results-panel-title { color: var(--white); font-size: 1rem; letter-spacing: -.02em; }
.results-correct .results-panel-title { color: var(--success); }
.results-incorrect .results-panel-title { color: var(--danger); }
.results-names { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; width: 100%; }
.result-name, .results-empty { max-width: 100%; padding: 7px 10px; border-radius: 999px; color: var(--white); background: rgba(255, 244, 232, .1); font-size: .84rem; font-weight: 700; overflow-wrap: anywhere; }
.results-empty { color: var(--muted); font-weight: 500; }
.results-malandro { gap: 5px; padding-bottom: 4px; }
.results-malandro .results-character { transform: scale(1.18); margin-block: 12px 18px; }
.results-role { color: var(--yellow); font-size: .78rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.results-bendito-name { max-width: 100%; color: var(--white); font-size: clamp(1.2rem, 4vw, 1.7rem); overflow-wrap: anywhere; }
.results-character { width: 128px; height: 160px; flex: 0 0 auto; filter: drop-shadow(0 14px 10px rgba(0, 0, 0, .35)); }
.results-character img { display: block; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; animation: sprite-idle 2.4s ease-in-out infinite; }
.character-police img { animation-delay: -.8s; }
.character-otario img { animation-delay: -1.5s; }
.badge { padding: 6px 10px; border-radius: 999px; font-size: .76rem; font-weight: 800; white-space: nowrap; }
.badge.good { color: var(--dark); background: var(--success); }
.badge.bad { color: var(--white); background: var(--danger); }

@keyframes screen-in { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes reveal-word { from { opacity: 0; transform: scale(.86) rotate(-3deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes sprite-idle { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@media (max-width: 700px) {
  .results-stage { grid-template-columns: 1fr 1fr; align-items: start; }
  .results-malandro { grid-column: 1 / -1; grid-row: 1; }
  .results-correct { grid-column: 1; grid-row: 2; }
  .results-incorrect { grid-column: 2; grid-row: 2; }
  .results-malandro .results-character { transform: scale(1.05); margin-block: 4px 12px; }
}
@media (max-width: 520px) {
  .screen { min-height: calc(100svh - 20px); border-radius: 28px; }
  .actions > .button { flex: 1 1 100%; }
  .results-stage { grid-template-columns: 1fr; gap: 14px; }
  .results-malandro { grid-column: 1; grid-row: 1; }
  .results-correct, .results-incorrect { grid-column: 1; }
  .results-correct { grid-row: 2; }
  .results-incorrect { grid-row: 3; }
  .results-side-panel { padding-block: 12px; }
}
@media (orientation: landscape) and (max-height: 600px) {
  .screen { min-height: calc(100svh - 20px); padding-block: 20px; }
  .home-screen { gap: 18px; }
  .brand-art { max-height: 42svh; }
  .home-character-banner { max-height: 30svh; object-fit: contain; }
  .secret-card { min-height: 180px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
