:root {
  --bg: #15110c;
  --panel: #241d14;
  --gold: #e3b341;
  --gold-dark: #a9792a;
  --text: #f1e7d0;
  --muted: #b5a88d;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

/* ---------- Landing ---------- */
body.landing { min-height: 100dvh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 0%, #3a2c17 0%, var(--bg) 60%); }
.hero { max-width: 520px; width: 100%; padding: 32px 22px calc(32px + var(--safe-bottom)); text-align: center; }
.hero .logo { width: 96px; height: 96px; margin-bottom: 8px; }
.hero h1 { font-size: 2.2rem; margin: 0 0 6px; letter-spacing: 0.5px; }
.hero h1 span { color: var(--gold); }
.tagline { color: var(--muted); margin: 0 0 24px; }
.btn { display: inline-block; width: 100%; padding: 16px 20px; margin: 6px 0; border-radius: 14px; font-size: 1.1rem; font-weight: 700; text-decoration: none; border: 0; cursor: pointer; }
.btn-primary { background: linear-gradient(180deg, var(--gold), var(--gold-dark)); color: #1b1710; box-shadow: 0 6px 20px rgba(227, 179, 65, 0.25); }
.btn-primary:disabled { opacity: 0.45; box-shadow: none; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid rgba(255,255,255,0.18); }
.btn-ghost:disabled { opacity: 0.45; }
.tips { text-align: left; color: var(--muted); padding-left: 20px; margin: 26px 0 0; line-height: 1.5; }
.tips b { color: var(--text); }
.foot, .small { color: var(--muted); font-size: 0.85rem; margin-top: 18px; }
.form { text-align: left; }
.form label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 0.9rem; }
.form input { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.15); background: var(--panel); color: var(--text); font-size: 1rem; }
.msg { margin-top: 14px; padding: 12px; border-radius: 10px; display: none; }
.msg.ok { display: block; background: rgba(76, 175, 80, 0.15); color: #a5e0a8; }
.msg.err { display: block; background: rgba(244, 67, 54, 0.15); color: #f5a09a; }

/* ---------- Game ---------- */
body.game { overflow: hidden; background: #000; height: 100dvh; width: 100vw; position: fixed; inset: 0; touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
#stage { position: fixed; inset: 0; background: #000; }
#viewport { position: absolute; inset: 0; overflow: hidden; }
#player-host { position: absolute; left: 0; top: 0; width: 100%; height: 100%; transform-origin: 0 0; will-change: transform; }
#player-host ruffle-player, #player-host ruffle-object, #player-host ruffle-embed { width: 100%; height: 100%; display: block; }

#hud { position: absolute; top: calc(6px + var(--safe-top)); right: calc(6px + var(--safe-right)); display: flex; flex-direction: column; gap: 6px; z-index: 20; }
#hud.hidden { display: none; }
.hud-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.25); background: rgba(20, 16, 10, 0.72); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); touch-action: manipulation; }
.hud-btn:active { background: rgba(227, 179, 65, 0.6); }
#btn-show { position: absolute; top: calc(6px + var(--safe-top)); right: calc(6px + var(--safe-right)); z-index: 20; opacity: 0.55; }
.hidden { display: none !important; }

#kbd { position: absolute; left: calc(8px + var(--safe-left)); right: calc(56px + var(--safe-right)); bottom: calc(8px + var(--safe-bottom)); display: flex; gap: 6px; z-index: 25; }
#kbd input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.25); background: rgba(20,16,10,0.9); color: #fff; font-size: 16px; }
#kbd button { padding: 0 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.25); background: rgba(227,179,65,0.85); color: #1b1710; font-weight: 700; font-size: 14px; }
#kbd button[type=button] { background: rgba(20,16,10,0.9); color: #fff; }

#splash { position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; background: radial-gradient(circle at 50% 0%, #3a2c17 0%, #0b0906 70%); }
#splash img { width: 84px; height: 84px; }
#splash h2 { margin: 0; }
#splash p { color: var(--muted); margin: 0; }
#splash .btn { max-width: 360px; }
#splash.hidden { display: none; }

#rotate { position: absolute; inset: 0; z-index: 40; display: none; flex-direction: column; align-items: center; justify-content: center; background: rgba(0,0,0,0.92); color: var(--text); text-align: center; padding: 24px; }
.rotate-icon { font-size: 64px; animation: spin 1.6s ease-in-out infinite alternate; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(90deg); } }
@media (orientation: portrait) and (max-width: 900px) { body.game.playing #rotate { display: flex; } }

/* ---------- Site (paginas) ---------- */
body.site { min-height: 100dvh; background: radial-gradient(circle at 50% 0%, #3a2c17 0%, var(--bg) 55%); display: block; }
.nav { display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-top: calc(10px + var(--safe-top)); background: rgba(10, 8, 5, 0.75); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 10; border-bottom: 1px solid rgba(255,255,255,0.08); }
.nav .brand { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--gold); text-decoration: none; font-size: 1.1rem; }
.nav .brand img { width: 28px; height: 28px; }
.nav .links { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav .links::-webkit-scrollbar { display: none; }
.nav .links a { color: var(--muted); text-decoration: none; padding: 8px 10px; border-radius: 8px; white-space: nowrap; font-size: 0.95rem; }
.nav .links a.active, .nav .links a:hover { color: var(--text); background: rgba(255,255,255,0.07); }
.nav .play { background: linear-gradient(180deg, var(--gold), var(--gold-dark)); color: #1b1710; font-weight: 800; padding: 8px 16px; border-radius: 10px; text-decoration: none; white-space: nowrap; }
body.site .hero { padding: 28px 18px 10px; max-width: 720px; margin: 0 auto; }
body.site .hero .logo { width: 84px; height: 84px; }
.cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.cta .btn { width: auto; min-width: 180px; }
.status { color: var(--muted); font-size: 0.95rem; margin: 4px 0 18px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #777; margin-right: 6px; }
.dot.on { background: #4fd36a; box-shadow: 0 0 8px #4fd36a; }
.wrap { max-width: 980px; margin: 0 auto; padding: 14px 12px calc(30px + var(--safe-bottom)); }
.wrap.narrow { max-width: 520px; }
.title { font-size: 1.7rem; margin: 10px 0 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }
.card { background: rgba(36, 29, 20, 0.85); border: 1px solid rgba(255,255,255,0.08); border-radius: 14px; padding: 14px; margin: 12px 0; }
.card h2 { font-size: 1.05rem; margin: 0 0 10px; display: flex; justify-content: space-between; align-items: center; }
.card h2 .more { font-size: 0.8rem; color: var(--gold); text-decoration: none; font-weight: 400; }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 0.8rem; padding: 6px 6px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.tbl td { padding: 8px 6px; border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .pos { color: var(--gold); font-weight: 800; width: 2em; }
.tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.pname { color: var(--text); text-decoration: none; font-weight: 600; }
.pname.on::after { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #4fd36a; margin-left: 6px; vertical-align: middle; }
.cls { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; background: #777; }
.cls-1 { background: #3f9ad6; } .cls-2 { background: #5cb85c; } .cls-3 { background: #c8a84b; } .cls-4 { background: #7b6fa8; } .cls-5 { background: #4a90e2; } .cls-6 { background: #e2a04a; } .cls-7 { background: #e86f9e; } .cls-8 { background: #d9534f; } .cls-9 { background: #8bc34a; } .cls-10 { background: #2e8b57; } .cls-11 { background: #b22222; } .cls-12 { background: #a0522d; }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 10px 0; scrollbar-width: none; }
.tabs a { padding: 8px 14px; border-radius: 10px; background: rgba(255,255,255,0.06); color: var(--muted); cursor: pointer; white-space: nowrap; user-select: none; }
.tabs a.active { background: var(--gold); color: #1b1710; font-weight: 700; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sel, .search input { padding: 9px 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.15); background: var(--panel); color: var(--text); font-size: 0.95rem; }
.search { display: flex; gap: 4px; flex: 1; min-width: 200px; }
.search input { flex: 1; min-width: 0; }
.search button, .btn-small { padding: 8px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.08); color: var(--text); cursor: pointer; }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; padding-top: 12px; }
.news { padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.news:last-child { border-bottom: 0; }
.news time { color: var(--gold); font-size: 0.8rem; }
.news h3 { margin: 2px 0 6px; font-size: 1.05rem; }
.news p { margin: 0; color: var(--muted); line-height: 1.5; }
.phead { display: flex; align-items: center; gap: 12px; }
.phead .cls { width: 40px; height: 40px; border-radius: 10px; }
.phead .title { margin: 0; }
.badge { font-size: 0.7rem; background: rgba(255,255,255,0.12); padding: 2px 8px; border-radius: 999px; vertical-align: middle; font-weight: 600; }
.badge.on { background: rgba(79, 211, 106, 0.2); color: #8ff0a5; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 10px 0 16px; }
.stat { background: rgba(0,0,0,0.25); border-radius: 10px; padding: 10px; }
.stat span { display: block; color: var(--muted); font-size: 0.75rem; }
.stat b { font-size: 1.05rem; }
body.site .foot { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 20px; }
body.site .foot a { color: var(--gold); }
.sub { padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.sub:last-child { border-bottom: 0; }
.form h3 { margin: 16px 0 0; font-size: 1rem; }
.small { font-size: 0.85rem; }

/* ---------- Painel admin (HUD) ---------- */
#admin-panel { position: absolute; left: calc(8px + var(--safe-left)); right: calc(56px + var(--safe-right)); top: calc(8px + var(--safe-top)); bottom: calc(8px + var(--safe-bottom)); z-index: 26; background: rgba(20,16,10,0.96); border: 1px solid rgba(227,179,65,0.5); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 6px; max-width: 760px; margin: 0 auto; }
#admin-panel.hidden { display: none; }
.ad-head { display: flex; align-items: center; gap: 8px; color: var(--gold); font-weight: 700; }
.ad-head .muted { flex: 1; font-weight: 400; }
.ad-head button { background: none; border: 0; color: #fff; font-size: 18px; }
.ad-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.ad-tabs a { padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,0.07); color: var(--muted); font-size: 0.85rem; white-space: nowrap; cursor: pointer; user-select: none; }
.ad-tabs a.active { background: var(--gold); color: #1b1710; font-weight: 700; }
#ad-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.ad-search { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.25); background: rgba(0,0,0,0.5); color: #fff; font-size: 16px; }
.ad-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ad-row label { color: var(--muted); font-size: 0.85rem; display: flex; align-items: center; gap: 4px; }
.ad-row input { padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.25); background: rgba(0,0,0,0.5); color: #fff; font-size: 15px; width: 110px; }
.ad-row input#ad-target, .ad-row input#ad-aname, .ad-row input#ad-free-in { flex: 1; min-width: 160px; width: auto; }
.ad-row input[type=checkbox] { width: auto; }
.ad-row button, .ad-grid button, .ad-quick button { padding: 8px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.2); background: rgba(227,179,65,0.85); color: #1b1710; font-weight: 700; font-size: 0.85rem; }
.ad-quick button { background: rgba(255,255,255,0.1); color: #fff; font-weight: 500; }
.ad-row button.danger, .ad-grid button.danger { background: rgba(217,83,79,0.85); color: #fff; }
.ad-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ad-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.ad-list { display: flex; flex-direction: column; gap: 2px; }
.ad-item { padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,0.05); font-size: 0.9rem; cursor: pointer; }
.ad-item:active { background: rgba(227,179,65,0.4); }
#ad-log { max-height: 20%; overflow-y: auto; font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); border-top: 1px solid rgba(255,255,255,0.1); padding-top: 4px; }
#ad-log .ok { color: #a5e0a8; } #ad-log .err { color: #f5a09a; }
