:root {
  --bg: #000;
  --panel: #111114;
  --line: #26262d;
  --chip: #1c1c22;
  --chip-text: #3d8bff;
  --text: #fff;
  --muted: #9a9aa6;
  --good: #3fd06b;
  --bad: #ff4d4d;
  --epic: #ffc533;
  --paper: #e9d9b0;
  --ink: #3b2610;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; }

/* Barra do topo */
.top {
  position: fixed; inset: 0 0 auto 0; height: 52px; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 16px; background: linear-gradient(#000 70%, transparent);
}
.brand { font-weight: 800; font-size: 15px; white-space: nowrap; }
.tools { display: flex; align-items: center; gap: 6px; }
#mini-bounty { color: var(--epic); font-weight: 700; font-size: 13px; margin-right: 4px; white-space: nowrap; }
.tool {
  background: var(--chip); color: #ddd; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 11px; font-size: 13px; white-space: nowrap;
}
.tool.on { color: var(--chip-text); border-color: #2a4a80; }
@media (max-width: 520px) {
  .brand span { display: none; }
  .tool { padding: 6px 9px; font-size: 12px; }
}

/* Palco */
#stage {
  position: absolute; inset: 52px 0 0 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 8px 16px 24px; user-select: none;
}
.head { text-align: center; width: 100%; max-width: 480px; min-height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
#chip-icon { font-size: 44px; line-height: 1; margin-bottom: 8px; }
#chip {
  background: var(--chip); color: var(--chip-text); font-weight: 700; font-size: 17px;
  padding: 9px 18px; border-radius: 14px; max-width: 100%;
}
#result {
  margin: 14px 0 10px; font-size: 30px; font-weight: 800; min-height: 40px; line-height: 1.2;
  text-shadow: 0 2px 0 rgba(0,0,0,.6);
}
#result.long { font-size: 21px; }
#wheel-wrap { width: min(92vw, 470px, calc(100vh - 290px)); aspect-ratio: 1; transition: opacity .2s; }
#wheel-wrap.hidden { opacity: 0; pointer-events: none; position: absolute; }
#wheel { width: 100%; height: 100%; display: block; }
#tap-hint {
  position: absolute; bottom: 18px; color: var(--muted); font-size: 14px; opacity: 0; transition: opacity .2s;
  animation: pulse 1.2s infinite;
}
#tap-hint.show { opacity: 1; }
@keyframes pulse { 50% { transform: scale(1.06); } }

/* Número grande */
#big { display: none; text-align: center; }
#big.show { display: block; animation: zoom .35s ease-out; }
#big-num { font-size: clamp(56px, 16vw, 104px); font-weight: 900; color: var(--epic); text-shadow: 0 4px 0 #6b4a00; }
#big-suf { font-size: 22px; color: var(--muted); font-weight: 700; margin-top: 4px; }
@keyframes zoom { from { transform: scale(.5); opacity: 0; } }

/* Cartão de reação */
#overlay {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.95); z-index: 10; padding: 16px;
}
#overlay.show { display: flex; }
.card { width: 100%; max-width: 420px; text-align: center; }
.card.pop { animation: pop .38s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(.6) rotate(-3deg); opacity: 0; } }
#card-title { font-size: clamp(28px, 8vw, 40px); font-weight: 900; line-height: 1.1; margin-bottom: 14px; text-transform: none; }
.panel {
  margin: 0 auto; width: min(78vw, 300px); aspect-ratio: 1.2; border-radius: 18px;
  display: flex; align-items: center; justify-content: center; border: 3px solid var(--line);
  background: radial-gradient(circle at 50% 40%, #2b2b33, #0d0d10);
}
#card-emoji { font-size: clamp(90px, 26vw, 140px); animation: wobble 1.4s ease-in-out infinite; }
@keyframes wobble { 25% { transform: rotate(-7deg) scale(1.05); } 75% { transform: rotate(7deg) scale(1.05); } }
#card-sub { margin-top: 16px; font-size: 18px; line-height: 1.45; color: #e8e8ee; }
#card-sub b { color: var(--epic); }
.tone-good #card-title { color: var(--good); }
.tone-good .panel { border-color: #1f6b38; background: radial-gradient(circle at 50% 40%, #1d4a2b, #07130b); }
.tone-bad #card-title { color: var(--bad); }
.tone-bad .panel { border-color: #7a1f1f; background: radial-gradient(circle at 50% 40%, #4a1717, #120505); }
.tone-epic #card-title { color: var(--epic); text-shadow: 0 0 22px rgba(255,197,51,.45); }
.tone-epic .panel { border-color: #8a6a10; background: radial-gradient(circle at 50% 40%, #5a4510, #140f02); box-shadow: 0 0 40px rgba(255,197,51,.25); }

/* Ficha lateral */
#sheet {
  position: fixed; top: 52px; right: 0; bottom: 0; width: min(360px, 92vw); z-index: 25;
  background: var(--panel); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .25s; overflow-y: auto; padding: 0 16px 24px;
}
body.sheet-open #sheet { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--panel); padding: 12px 0 8px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sec { margin-top: 10px; }
.sec h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--chip-text); margin: 10px 0 6px; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid #1d1d23; font-size: 14px; }
.row .k { color: var(--muted); flex-shrink: 0; }
.row .v { text-align: right; font-weight: 600; }
@media (min-width: 1100px) {
  #sheet { transform: none; }
  #stage { right: 360px; }
  #btn-sheet, #sheet-close { display: none; }
}

/* Telas de início e fim */
.screen {
  position: fixed; inset: 0; z-index: 40; background: var(--bg); display: none;
  overflow-y: auto; padding: 24px 16px 40px;
}
.screen.show { display: block; }
.start-box, .final-box { max-width: 460px; margin: 0 auto; }
.start-box { text-align: center; padding-top: 6vh; }
.logo { font-size: 84px; animation: wobble 2.4s ease-in-out infinite; }
.start-box h1 { font-size: 34px; margin: 8px 0 10px; }
.start-box p { color: #c9c9d2; line-height: 1.5; }
.start-box label { display: block; text-align: left; color: var(--muted); font-size: 13px; margin: 22px 0 6px; }
.name-row { display: flex; gap: 8px; }
#name {
  flex: 1; min-width: 0; background: var(--chip); border: 1px solid var(--line); color: #fff; border-radius: 12px;
  padding: 13px 14px; font: inherit; font-size: 18px; font-weight: 700;
}
#name:focus { outline: 2px solid var(--chip-text); }
.primary {
  width: 100%; margin-top: 14px; background: #d81414; color: #fff; border: 0; border-radius: 14px;
  padding: 15px; font-size: 18px; font-weight: 800; box-shadow: 0 4px 0 #7a0808;
}
.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #7a0808; }
.ghost { background: var(--chip); color: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; font-size: 18px; }
.hint { font-size: 13px; color: var(--muted) !important; }
#history { margin-top: 26px; text-align: left; }
#history h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--chip-text); }
.hist { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid #1d1d23; font-size: 14px; }
.hist .v { color: var(--epic); font-weight: 700; white-space: nowrap; }

.poster {
  background: var(--paper); color: var(--ink); text-align: center; padding: 22px 18px 18px;
  border: 6px solid #5a3d1c; border-radius: 4px; font-family: Georgia, "Times New Roman", serif;
  box-shadow: 0 10px 40px rgba(255,197,51,.15); animation: pop .5s cubic-bezier(.2,1.6,.4,1);
}
#poster-head { font-size: clamp(44px, 13vw, 64px); font-weight: 900; letter-spacing: .04em; line-height: 1; }
#poster-sub { font-weight: 700; font-size: 18px; margin: 6px 0 12px; }
.poster-photo { background: #d8c496; border: 4px solid var(--ink); aspect-ratio: 1.25; display: flex; align-items: center; justify-content: center; }
#poster-emoji { font-size: clamp(90px, 28vw, 130px); }
#poster-name { font-size: clamp(30px, 9vw, 42px); font-weight: 900; margin-top: 12px; word-break: break-word; }
#poster-epithet { font-style: italic; font-size: 18px; min-height: 22px; }
#poster-bounty { font-size: clamp(26px, 8vw, 36px); font-weight: 900; margin-top: 6px; }
#poster-cause { font-size: 14px; margin-top: 6px; opacity: .8; }
.final-title { margin: 26px 0 0; font-size: 20px; }
.final-actions { display: flex; flex-direction: column; gap: 4px; margin-top: 18px; }
.final-actions .ghost { width: 100%; margin-top: 8px; }
.share-msg { margin: 16px 0 0; font-size: 14px; color: #a9b0c0; text-align: center; }
#btn-share:disabled { opacity: .75; cursor: default; }

.mode-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0 4px; }
.mode { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; border-radius: 12px;
  background: var(--chip); color: #fff; border: 2px solid var(--line); }
.mode b { font-size: 16px; }
.mode span { font-size: 12px; color: #a9b0c0; }
.mode.on { border-color: var(--chip-text); background: #15233d; }
.mural-link { display: block; margin-top: 14px; color: var(--chip-text); font-weight: 700; text-decoration: none; }
.mural-link:hover { text-decoration: underline; }
