:root {
  --bg: #0a0e14;
  --bg-2: #0f141d;
  --panel: #131a24;
  --panel-2: #172029;
  --line: #223040;
  --text: #d6e2f0;
  --muted: #7c8da0;
  --accent: #f0b429;
  --accent-2: #c9963e;
  --green: #2ecc71;
  --green-dim: #1e8449;
  --red: #ff5c5c;
  --blue: #4aa3ff;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, #16202c 0%, var(--bg) 55%);
  color: var(--text);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

.muted { color: var(--muted); font-weight: 400; }
[hidden] { display: none !important; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; padding-top: calc(12px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--line);
  background: rgba(10, 14, 20, 0.85); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { font-size: 22px; color: var(--accent); letter-spacing: -2px; }
.brand strong { display: block; letter-spacing: 3px; font-size: 15px; }
.brand small { color: var(--muted); font-size: 11px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.whoami { color: var(--accent); font-weight: 600; }
.score-pill {
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px; font-weight: 700;
}
.score-pill em { color: var(--muted); font-style: normal; font-weight: 400; margin-left: 6px; }

/* Botoes */
.btn {
  background: var(--accent); color: #1a1205; border: none;
  padding: 9px 16px; border-radius: 8px; font-weight: 700; cursor: pointer;
  transition: transform .05s, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--accent-2); color: var(--accent); }
.btn.full { width: 100%; padding: 12px; }
.btn.tiny { padding: 5px 10px; font-size: 12px; }

/* Layout do jogo */
.layout {
  display: grid; grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 16px; padding: 16px; max-width: 1400px; margin: 0 auto;
}
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.panel h2 { margin: 0 0 12px; font-size: 15px; letter-spacing: .5px; }

/* Lista de desafios */
.challenge-list { display: flex; flex-direction: column; gap: 10px; }
.challenge {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  background: var(--panel-2); transition: border-color .2s, box-shadow .2s;
}
.challenge.solved {
  border-color: var(--green-dim);
  box-shadow: inset 0 0 0 1px var(--green-dim), 0 0 18px -6px var(--green);
}
.challenge-head { display: flex; align-items: center; gap: 8px; }
.owasp-badge {
  font-family: ui-monospace, monospace; font-size: 11px; font-weight: 700;
  background: #1c2733; color: var(--accent); border: 1px solid var(--line);
  padding: 2px 7px; border-radius: 6px;
}
.challenge.solved .owasp-badge { color: var(--green); border-color: var(--green-dim); }
.challenge-title { font-weight: 700; flex: 1; }
.challenge-points { color: var(--muted); font-size: 12px; }
.check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 12px; color: transparent; }
.challenge.solved .check { border-color: var(--green); background: var(--green); color: #05230f; }
.challenge-brief { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
.hints { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.hint-btn {
  text-align: left; background: transparent; border: 1px dashed var(--line);
  color: var(--muted); padding: 6px 10px; border-radius: 7px; cursor: pointer; font-size: 12px;
}
.hint-btn:hover { border-color: var(--accent-2); color: var(--text); }
.hint-text { background: #0d1620; border-left: 3px solid var(--accent); padding: 7px 10px; font-size: 12.5px; border-radius: 4px; }

/* Chat */
.chat { display: flex; flex-direction: column; min-height: 70vh; }
.chat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.assistant { display: flex; align-items: center; gap: 10px; }
.assistant .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.assistant strong { display: block; }
.assistant small { color: var(--muted); }
.chat-log {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  padding: 6px; min-height: 240px;
}
.msg { max-width: 82%; padding: 10px 13px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: #1d2b3a; border: 1px solid var(--line); }
.msg.bot { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); }
.msg.bot.html { border-color: var(--accent-2); }
.msg .who { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 3px; }

.advanced { background: #0d1620; border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 10px 0; }
.adv-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.adv-row.inline { flex-direction: row; gap: 8px; }
.adv-row label { font-size: 11px; color: var(--muted); }
.adv-row input { background: var(--bg-2); border: 1px solid var(--line); color: var(--text); padding: 7px 10px; border-radius: 6px; }
.adv-out { background: #05090d; border: 1px solid var(--line); border-radius: 6px; padding: 8px; font-size: 11.5px; overflow-x: auto; color: var(--blue); }

.chat-input { display: flex; gap: 8px; margin-top: 10px; }
.chat-input input { flex: 1; background: var(--bg-2); border: 1px solid var(--line); color: var(--text); padding: 12px; border-radius: 8px; }
.chat-input input:focus { outline: none; border-color: var(--accent-2); }

/* Overlays / modais */
.overlay { position: fixed; inset: 0; background: rgba(5, 8, 12, 0.8); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px; width: 100%; max-width: 420px; }
.modal.board { max-width: 560px; }
.logo-big { font-size: 22px; letter-spacing: 4px; color: var(--accent); text-align: center; }
.tagline { text-align: center; color: var(--muted); margin: 6px 0 18px; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab { flex: 1; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); padding: 9px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.tab.active { background: var(--accent); color: #1a1205; border-color: var(--accent); }
#auth-form { display: flex; flex-direction: column; gap: 10px; }
#auth-form input { background: var(--bg-2); border: 1px solid var(--line); color: var(--text); padding: 12px; border-radius: 8px; }
.auth-error { background: #2a1315; border: 1px solid #5a2327; color: var(--red); padding: 8px 12px; border-radius: 8px; font-size: 13px; }

.board-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.board-head h2 { margin: 0; }
.board-table { width: 100%; border-collapse: collapse; }
.board-table th, .board-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.board-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.board-table td:last-child, .board-table th:last-child { text-align: right; font-weight: 700; }
.board-table tr.me { background: #14202b; }
.board-table .rank1 { color: var(--accent); font-weight: 800; }

/* Toasts */
.toast-wrap { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 60; }
.toast { background: var(--panel); border: 1px solid var(--green-dim); border-left: 4px solid var(--green); padding: 12px 16px; border-radius: 10px; box-shadow: 0 10px 30px -10px #000; animation: slidein .25s ease; max-width: 320px; }
.toast.err { border-color: #5a2327; border-left-color: var(--red); }
.toast strong { color: var(--green); }
.toast.err strong { color: var(--red); }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============================================================================
   LOJA (storefront) - tema claro, coexiste com a Arena (tema escuro acima).
   O modo ativo e controlado por body[data-mode].
   ============================================================================ */
:root {
  --shop-bg: #f5f6fa;
  --shop-surface: #ffffff;
  --shop-line: #e6e8ef;
  --shop-text: #1a2232;
  --shop-muted: #6b7688;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-ink: #2c1f8f;
  --offer: #e8590c;
  --star: #f59f00;
}

body[data-mode="shop"] {
  background: var(--shop-bg);
  color: var(--shop-text);
}
body[data-mode="shop"] #arena-view { display: none; }
body[data-mode="arena"] #shop-view { display: none; }
/* O widget da Aria e o carrinho so aparecem no modo loja. */
body[data-mode="arena"] .aria-fab,
body[data-mode="arena"] .aria-panel { display: none !important; }

/* Header da loja */
.shop-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 24px; padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: rgba(255,255,255,0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--shop-line);
}
.shop-brand { font-size: 20px; font-weight: 800; letter-spacing: -.5px; color: var(--shop-text); white-space: nowrap; }
.shop-brand b { color: var(--brand); font-weight: 800; }
.shop-logo { color: var(--brand); margin-right: 4px; }
.shop-search { flex: 1; max-width: 560px; }
.shop-search input {
  width: 100%; padding: 11px 16px; border-radius: 999px;
  border: 1px solid var(--shop-line); background: #f0f2f7; color: var(--shop-text); font-size: 14px;
}
.shop-search input:focus { outline: none; border-color: var(--brand); background: #fff; }
.shop-nav { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.shop-link {
  background: transparent; border: none; color: var(--shop-text); font-weight: 600;
  cursor: pointer; font-size: 14px; padding: 8px 10px; border-radius: 8px;
}
.shop-link:hover { background: #eef0f6; color: var(--brand); }
#go-arena { color: var(--brand-ink); border: 1px solid #d9d5fb; background: #efeafe; }
#go-arena:hover { background: #e5defd; }
.shop-icon { position: relative; background: transparent; border: none; font-size: 20px; cursor: pointer; padding: 6px; }
.cart-count {
  position: absolute; top: -2px; right: -4px; background: var(--offer); color: #fff;
  font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 999px;
  display: grid; place-items: center; padding: 0 4px;
}
.shop-login-btn { background: var(--brand); color: #fff; }
.shop-login-btn:hover { filter: brightness(1.06); }
.shop-user { font-weight: 700; color: var(--brand-ink); }

/* Hero */
.hero {
  margin: 24px auto; max-width: 1200px; padding: 0 24px;
  display: grid; grid-template-columns: 1.3fr .7fr; gap: 20px; align-items: center;
}
.hero-text {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff; border-radius: 20px; padding: 40px 40px;
}
.hero-kicker { display: inline-block; background: rgba(255,255,255,.18); padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .5px; }
.hero-text h1 { font-size: 34px; line-height: 1.15; margin: 14px 0 10px; }
.hero-text h1 span { color: #ffe08a; }
.hero-text p { margin: 0 0 20px; opacity: .95; font-size: 15px; }
.hero-cta { background: #fff; color: var(--brand-ink); font-size: 15px; }
.hero-art {
  background: linear-gradient(135deg, #ffe08a, #ffb703); border-radius: 20px;
  display: grid; place-items: center; height: 100%; min-height: 200px;
}
.hero-art span { font-size: 96px; filter: drop-shadow(0 10px 20px rgba(0,0,0,.15)); }
@media (max-width: 780px) { .hero { grid-template-columns: 1fr; } .hero-art { min-height: 140px; } .hero-text h1 { font-size: 26px; } }

/* Categorias */
.cats { max-width: 1200px; margin: 0 auto; padding: 4px 24px; display: flex; gap: 10px; flex-wrap: wrap; }
.cat-chip {
  background: var(--shop-surface); border: 1px solid var(--shop-line); color: var(--shop-text);
  padding: 8px 16px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 13px;
  transition: all .15s;
}
.cat-chip:hover { border-color: var(--brand); color: var(--brand); }
.cat-chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Catalogo */
.catalog { max-width: 1200px; margin: 20px auto 40px; padding: 0 24px; }
.catalog-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.catalog-head h2 { margin: 0; font-size: 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.card {
  background: var(--shop-surface); border: 1px solid var(--shop-line); border-radius: 16px;
  overflow: hidden; display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 18px 40px -18px rgba(30,40,80,.35); }
.card-thumb { position: relative; height: 150px; display: grid; place-items: center; font-size: 64px;
  background: linear-gradient(135deg, #eef1ff, #f6f0ff); }
.card-tag { position: absolute; top: 10px; left: 10px; background: var(--offer); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.card-tag.sell { background: var(--brand); }
.card-tag.new { background: #0ca678; }
.card-body { padding: 14px 14px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-name { font-weight: 700; font-size: 14.5px; line-height: 1.3; }
.card-desc { color: var(--shop-muted); font-size: 12px; flex: 1; }
.card-rating { color: var(--star); font-size: 12px; font-weight: 600; }
.card-price { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.card-price .now { font-size: 18px; font-weight: 800; color: var(--shop-text); }
.card-price .old { font-size: 12px; color: var(--shop-muted); text-decoration: line-through; }
.card-add { margin-top: 10px; background: var(--brand); color: #fff; border: none; padding: 10px; border-radius: 10px; font-weight: 700; cursor: pointer; transition: filter .15s; }
.card-add:hover { filter: brightness(1.07); }
.empty { text-align: center; padding: 40px; }

.shop-footer { max-width: 1200px; margin: 0 auto; padding: 24px; color: var(--shop-muted); font-size: 13px; border-top: 1px solid var(--shop-line); }
.shop-footer strong { color: var(--shop-text); }

/* Widget da Aria (atendimento) */
.aria-fab {
  position: fixed; bottom: 22px; right: 22px; z-index: 45;
  width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-size: 26px;
  box-shadow: 0 12px 30px -8px rgba(79,70,229,.6); transition: transform .15s;
}
.aria-fab:hover { transform: scale(1.06); }
.aria-panel {
  position: fixed; bottom: 94px; right: 22px; z-index: 46;
  width: 360px; max-width: calc(100vw - 32px); height: 480px; max-height: calc(100vh - 130px);
  background: var(--shop-surface); border: 1px solid var(--shop-line); border-radius: 18px;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 60px -20px rgba(20,30,60,.4);
}
.aria-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.aria-panel-head .assistant strong { color: #fff; }
.aria-panel-head .assistant small { color: rgba(255,255,255,.85); }
.aria-close { background: transparent; border: none; color: inherit; font-size: 24px; cursor: pointer; line-height: 1; }
.aria-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: #f7f8fc; }
.aria-msg { max-width: 85%; padding: 9px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word; }
.aria-msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.aria-msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--shop-line); color: var(--shop-text); border-bottom-left-radius: 4px; }
.aria-msg.typing { color: var(--shop-muted); font-style: italic; }
.aria-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--shop-line); background: #fff; }
.aria-input input { flex: 1; border: 1px solid var(--shop-line); background: #f0f2f7; color: var(--shop-text); padding: 11px 14px; border-radius: 999px; }
.aria-input input:focus { outline: none; border-color: var(--brand); background: #fff; }
.aria-input .btn { border-radius: 50%; width: 42px; height: 42px; padding: 0; background: var(--brand); color: #fff; }

/* Carrinho (drawer) */
.drawer-overlay { position: fixed; inset: 0; background: rgba(20,25,40,.45); z-index: 48; }
.cart-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 49; width: 380px; max-width: 90vw;
  background: var(--shop-surface); border-left: 1px solid var(--shop-line);
  display: flex; flex-direction: column; box-shadow: -20px 0 60px -20px rgba(20,30,60,.4);
  animation: slidein-right .2s ease;
}
@keyframes slidein-right { from { transform: translateX(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.cart-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--shop-line); }
.cart-head h3 { margin: 0; }
.cart-items { flex: 1; overflow-y: auto; padding: 12px 20px; display: flex; flex-direction: column; gap: 12px; }
.cart-empty { color: var(--shop-muted); text-align: center; padding: 40px 0; }
.cart-item { display: flex; align-items: center; gap: 12px; }
.cart-item .ci-thumb { font-size: 30px; width: 48px; height: 48px; display: grid; place-items: center; background: #f0f2f7; border-radius: 10px; }
.cart-item .ci-info { flex: 1; }
.cart-item .ci-name { font-weight: 600; font-size: 13px; }
.cart-item .ci-price { color: var(--shop-muted); font-size: 12px; }
.cart-item .ci-qty { display: flex; align-items: center; gap: 8px; }
.cart-item .ci-qty button { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--shop-line); background: #fff; cursor: pointer; font-weight: 700; color: var(--shop-text); }
.cart-foot { padding: 18px 20px; border-top: 1px solid var(--shop-line); }
.cart-total { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; font-size: 15px; }
.cart-total strong { font-size: 20px; }
.cart-foot .btn { background: var(--brand); color: #fff; }

/* Ajustes de modais no tema claro (login/placar seguem escuros por padrao) */
@media (max-width: 480px) {
  .shop-search { display: none; }
  .aria-panel { bottom: 88px; }
}
