:root { --bg:#fbf9f7; --card:#fff; --mem:#ece6e4; --ink:#1f1b1c; --soft:#5d5557; --ghost:#8f8789; --line:#e4dedc; --red:#b3243b; --ok:#1d6b43; --warn:#8a5a00; color-scheme:light; }
:root[data-theme=dark] { --bg:#151314; --card:#1d1a1b; --mem:#322d2e; --ink:#f1ecec; --soft:#b9b0b2; --ghost:#8a8183; --line:#2e2a2b; --red:#ec6a7e; --ok:#6fcf9b; --warn:#e2b25a; color-scheme:dark; }
* { box-sizing:border-box; }
html { -webkit-text-size-adjust:100%; }
body { margin:0; background:var(--bg); color:var(--ink); font:16px/1.45 "Avenir Next","Segoe UI",system-ui,sans-serif; -webkit-tap-highlight-color:transparent; }
h1 { font-size:24px; margin:0; } h2 { font-size:17px; margin:0; } p { margin:0; }
a { color:var(--red); }
.wrap { max-width:820px; margin:0 auto; padding:16px 16px 32px; display:flex; flex-direction:column; gap:16px; }
.brand { font-weight:800; letter-spacing:-.01em; color:var(--ink); font-size:20px; display:inline-flex; align-items:center; gap:8px; }
.brand img { border-radius:7px; display:block; }
.brand b { color:var(--red); margin-left:-8px; }
.top { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.lbl { font-size:13px; color:var(--soft); }
.stack { display:flex; flex-direction:column; gap:12px; }
.row { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.card { background:var(--card); border:1px solid var(--line); border-radius:12px; padding:16px; display:flex; flex-direction:column; gap:12px; min-width:0; }

/* botões e campos: alvo de toque de 44px no celular */
button, .btn { font:inherit; color:var(--ink); background:var(--card); border:1px solid var(--line); border-radius:10px; padding:10px 14px; min-height:44px; cursor:pointer; text-decoration:none; display:inline-flex; align-items:center; justify-content:center; gap:6px; text-align:center; }
button:disabled { cursor:default; opacity:.6; }
.primary { background:#b3243b; border-color:#b3243b; color:#fff; font-weight:700; }
.round { width:40px; min-height:40px; height:40px; padding:0; border-radius:50%; flex:none; }
button[aria-pressed=false].round { color:var(--ghost); }
.small { min-height:36px; padding:6px 10px; font-size:14px; }
input, select, textarea { font:inherit; font-size:16px; color:var(--ink); background:var(--card); border:1px solid var(--line); border-radius:10px; padding:10px 12px; min-height:44px; width:100%; min-width:0; }
textarea { resize:vertical; font-family:inherit; }
fieldset { border:1px solid var(--line); border-radius:10px; padding:10px 12px; margin:0; display:flex; flex-direction:column; gap:8px; min-width:0; }
legend { font-size:14px; color:var(--soft); padding:0 4px; }
.install svg { vertical-align:-4px; }
label { display:flex; flex-direction:column; gap:4px; font-size:14px; color:var(--soft); }
form { display:flex; flex-direction:column; gap:12px; }
:focus-visible { outline:2px solid var(--red); outline-offset:2px; }
.msg { font-size:14px; padding:10px 12px; border-radius:10px; border:1px solid var(--line); }
.msg.bad { color:var(--red); border-color:var(--red); }
.msg.good { color:var(--ok); border-color:var(--ok); }
[hidden] { display:none !important; }

/* navegação: barra embaixo no celular, em cima no computador */
.tabs { position:fixed; left:0; right:0; bottom:0; z-index:5; display:flex; background:var(--card); border-top:1px solid var(--line); padding-bottom:env(safe-area-inset-bottom); }
.tabs a { flex:1; padding:12px 4px; text-align:center; font-size:13px; color:var(--soft); text-decoration:none; }
.tabs a.on { color:var(--red); font-weight:700; }
body.app { padding-bottom:calc(60px + env(safe-area-inset-bottom)); }
body.playing .tabs { display:none; }
body.playing { padding-bottom:0; }
@media (min-width:720px) {
  .tabs { position:sticky; top:0; bottom:auto; border-top:0; border-bottom:1px solid var(--line); justify-content:center; }
  .tabs a { flex:0 0 auto; padding:14px 22px; font-size:15px; }
  body.app { padding-bottom:0; }
}

/* painel */
.tiles { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
@media (min-width:640px) { .tiles { grid-template-columns:repeat(4,minmax(0,1fr)); } }
.tile { background:var(--card); border:1px solid var(--line); border-radius:12px; padding:12px; }
.tile b { display:block; font-size:26px; line-height:1.1; }
.tile span { font-size:13px; color:var(--soft); }
.week { display:flex; align-items:flex-end; gap:6px; height:84px; }
.week div { flex:1; display:flex; flex-direction:column; justify-content:flex-end; align-items:center; gap:4px; height:100%; font-size:12px; color:var(--soft); }
.week i { width:100%; max-width:36px; background:var(--red); border-radius:4px 4px 0 0; min-height:2px; }
.chips { display:flex; flex-wrap:wrap; gap:8px; }
.chip { border:1px solid var(--line); background:var(--card); color:var(--ink); border-radius:999px; padding:8px 12px; font-size:14px; text-decoration:none; }
.badge { font-size:12px; font-weight:700; padding:2px 8px; border-radius:999px; border:1px solid currentColor; white-space:nowrap; }
.badge.fraco { color:var(--red); } .badge.dominado { color:var(--ok); } .badge.andamento { color:var(--warn); } .badge.novo { color:var(--soft); }
.bar { height:6px; background:var(--mem); border-radius:3px; overflow:hidden; }
.bar i { display:block; height:100%; background:var(--red); }
.tema { display:flex; flex-wrap:wrap; gap:8px; align-items:center; justify-content:space-between; padding-top:12px; border-top:1px solid var(--line); }
.tema > div:first-child { min-width:0; flex:1 1 180px; display:flex; flex-direction:column; gap:4px; align-items:flex-start; }
ol.steps { margin:0; padding-left:20px; display:flex; flex-direction:column; gap:6px; }

/* jogo */
.playhead { display:flex; align-items:center; justify-content:space-between; gap:12px; font-size:13px; color:var(--soft); }
.clue { border:1px solid var(--line); border-radius:12px; padding:10px 14px 14px; text-align:center; background:
  linear-gradient(var(--line) 1px, transparent 1px) 0 0/100% 24px, linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0/24px 100%; background-color:var(--card); }
.clue svg { width:100%; max-width:440px; height:auto; display:block; margin:0 auto; }
.clue svg text { font-size:11px; fill:var(--soft); }
.clue .q { font-size:clamp(17px,4.4vw,22px); font-weight:600; color:var(--red); margin-top:4px; overflow-wrap:anywhere; }
.opts { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:8px; }
.opts button { min-height:52px; overflow-wrap:anywhere; }
.opts .ok { border-color:var(--ok); color:var(--ok); font-weight:700; opacity:1; }
.opts .bad { border-color:var(--red); color:var(--red); text-decoration:line-through; opacity:1; }
.fb { display:flex; flex-direction:column; gap:10px; }
.typezone { position:relative; display:flex; flex-direction:column; gap:12px; align-items:center; text-align:center; padding:8px 0; }
/* campo invisível sobre a área de digitação: um toque abre o teclado do celular */
.typezone input { position:absolute; inset:0; height:100%; opacity:0; border:0; }
#word { font-size:clamp(26px,8vw,48px); font-weight:700; letter-spacing:.02em; min-height:1.3em; overflow-wrap:anywhere; }
#word b { color:var(--red); }
#word i { color:var(--ghost); font-style:normal; }
#word u { color:var(--ghost); text-decoration:none; margin:0 2px; }
#word .at { box-shadow:-2px 0 0 var(--ink); }
#word.shake { animation:shake .18s; }
@keyframes shake { 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }
#kb { display:flex; flex-direction:column; gap:5px; align-items:center; }
#kb div { display:flex; gap:5px; }
#kb span { width:34px; height:34px; display:grid; place-items:center; border:1px solid var(--line); border-radius:6px; font-size:13px; color:var(--soft); background:var(--card); text-transform:uppercase; }
#kb span.hit { background:var(--ink); color:var(--bg); border-color:var(--ink); }
@media (max-width:560px) { #kb { display:none; } }
.result { text-align:center; align-items:center; }
.result b { font-size:56px; line-height:1; }

/* desenhos: o fármaco é sempre a peça vermelha (a animação fica no próprio SVG, em scenes.js) */
.drug { fill:var(--red); }

/* digitando no celular com o teclado aberto: tudo compacto para caber acima do teclado */
@media (max-width:560px) {
  body.typing .wrap { gap:8px; padding-top:8px; }
  body.typing .clue { padding:6px 10px 8px; }
  body.typing .clue svg { width:196px; height:92px; }
  body.typing .clue .lbl, body.typing .typezone > .lbl:not(#hint) { display:none; }
  body.typing .clue .q { font-size:16px; margin:0; }
  body.typing #word { font-size:30px; }
  body.typing .typezone { gap:6px; padding:0; }
}

/* admin */
.user { display:flex; flex-direction:column; gap:8px; padding-top:12px; border-top:1px solid var(--line); }
.user .who { display:flex; flex-wrap:wrap; gap:6px 10px; align-items:center; overflow-wrap:anywhere; }
table { border-collapse:collapse; width:100%; font-size:13px; }
td, th { text-align:left; padding:6px 8px; border-bottom:1px solid var(--line); }
.scroll { overflow-x:auto; }

/* ranking e desafios */
.rank { display:flex; align-items:center; gap:10px; padding:10px 0; border-top:1px solid var(--line); }
.rank .pos { width:28px; flex:none; font-weight:800; color:var(--soft); text-align:center; }
.rank .who { flex:1; min-width:0; overflow-wrap:anywhere; }
.rank.eu .who, .rank.eu .pos { color:var(--red); font-weight:800; }
.rank .pts { font-weight:700; white-space:nowrap; }
.seg { display:flex; gap:8px; }

/* boas-vindas */
dialog { border:1px solid var(--line); border-radius:14px; background:var(--card); color:var(--ink); padding:20px; width:min(440px, calc(100vw - 32px)); max-height:calc(100dvh - 32px); overflow:auto; }
dialog::backdrop { background:rgba(0,0,0,.55); }
ul.steps { margin:0; padding-left:20px; display:flex; flex-direction:column; gap:6px; }
.pick { flex-direction:row; align-items:center; gap:10px; font-size:16px; color:var(--ink); min-height:44px; }
.pick input { width:22px; min-height:22px; flex:none; }
@media (max-width:420px) { .tabs a { font-size:12px; padding:12px 2px; } }

/* reportar erro, medalhas */
.report { display:flex; flex-direction:column; gap:8px; align-items:flex-end; }
.report form { width:100%; }
.linkbtn { background:none; border:0; min-height:32px; padding:4px 0; font-size:13px; color:var(--soft); text-decoration:underline; }
@media (max-width:560px) { body.typing .report { display:none; } }
.medals { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:10px; }
.medal { border:1px solid var(--line); border-radius:10px; padding:10px; display:flex; flex-direction:column; gap:6px; align-items:flex-start; min-width:0; }
.medal.on { border-color:var(--ok); }
.medal .bar { width:100%; }

/* desenho das medalhas (ranking e conquistas) */
.medalsvg { display:block; flex:none; --rib1:#b3243b; --rib2:#7d1528; }
.medalsvg.gold { --m1:#c9971c; --m2:#f2cf63; --m3:#6b4a00; }
.medalsvg.silver { --m1:#8e98a3; --m2:#dfe5ea; --m3:#3f4850; }
.medalsvg.bronze { --m1:#96592a; --m2:#d99a66; --m3:#4f2a0d; }
.medalsvg.off { --m1:var(--line); --m2:var(--mem); --m3:var(--ghost); --rib1:var(--line); --rib2:var(--mem); }
.rank .pos { width:34px; }
.rank .medalsvg { width:32px; height:40px; }
.medal { align-items:center; text-align:center; }
.sr { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }

/* painel do admin: menu lateral no computador, abas roláveis no celular; uma seção por vez */
.admtop { display:flex; flex-wrap:wrap; gap:8px 12px; align-items:center; justify-content:space-between; padding:12px 16px; border-bottom:1px solid var(--line); background:var(--card); }
.admwrap { max-width:1240px; margin:0 auto; }
.admnav { display:flex; gap:4px; overflow-x:auto; padding:8px 16px; border-bottom:1px solid var(--line); position:sticky; top:0; background:var(--bg); z-index:4; }
.admnav a { flex:none; padding:10px 12px; border-radius:8px; color:var(--soft); text-decoration:none; font-size:14px; white-space:nowrap; display:flex; gap:6px; align-items:center; }
.admnav a.on { background:var(--ink); color:var(--bg); font-weight:700; }
.admmain { padding:16px; display:flex; flex-direction:column; gap:16px; min-width:0; }
@media (min-width:900px) {
  .admwrap { display:grid; grid-template-columns:210px minmax(0,1fr); align-items:start; }
  .admnav { flex-direction:column; border-bottom:0; border-right:1px solid var(--line); padding:16px 12px; top:0; min-height:calc(100vh - 70px); overflow:visible; }
  .admmain { padding:20px 24px 40px; }
  .adm .tiles { grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); }
}
.count { background:var(--red); color:#fff; border-radius:999px; font-size:12px; font-weight:700; padding:1px 7px; }
.cols { display:grid; grid-template-columns:repeat(auto-fit,minmax(280px,1fr)); gap:16px; }
.toolbar { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:10px; align-items:end; }
/* linha compacta que abre para mostrar as ações */
details.lrow { border-top:1px solid var(--line); }
details.lrow:first-child { border-top:0; }
details.lrow summary { display:grid; grid-template-columns:minmax(0,1.2fr) minmax(0,1.6fr) auto auto; gap:6px 12px; align-items:center; padding:10px 4px; cursor:pointer; list-style:none; }
details.lrow summary::-webkit-details-marker { display:none; }
details.lrow summary > * { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
details.lrow[open] summary { font-weight:700; }
details.lrow .body { display:flex; flex-direction:column; gap:10px; padding:4px 4px 14px; }
@media (max-width:640px) { details.lrow summary { grid-template-columns:minmax(0,1fr) auto; } details.lrow summary .hide-s { display:none; } }
.crow { display:grid; grid-template-columns:auto minmax(0,1fr) auto; gap:10px; align-items:center; padding:10px 4px; border-top:1px solid var(--line); }
.crow:first-child { border-top:0; }
.crow .txt { min-width:0; display:flex; flex-direction:column; gap:2px; }
.crow .txt > * { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.pager { display:flex; flex-wrap:wrap; gap:8px; align-items:center; justify-content:space-between; padding-top:12px; border-top:1px solid var(--line); font-size:13px; color:var(--soft); }
.pager:empty { display:none; }
