:root {
  --bg: #070b16;
  --bg2: #0d1526;
  --card: #111c33;
  --line: #1e2f52;
  --ink: #e8eefc;
  --dim: #93a5c9;
  --acc: #4ce0b3;
  --acc2: #58a6ff;
  --warn: #ffb454;
  --bad: #ff6b81;
  --glow: 0 0 0 1px rgba(76, 224, 179, .35), 0 8px 30px rgba(76, 224, 179, .18);
  --r: 14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1100px 520px at 80% -10%, #14264a 0%, transparent 60%),
    radial-gradient(900px 500px at 10% 10%, #0d2a3a 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font: 400 16px/1.75 "Segoe UI", Tahoma, "Noto Naskh Arabic", system-ui, sans-serif;
  min-height: 100vh;
}

.masthead {
  display: flex; flex-wrap: wrap; gap: 18px; align-items: center; justify-content: space-between;
  padding: 28px clamp(16px, 4vw, 48px) 18px;
}

.brand { display: flex; gap: 16px; align-items: center; }
.brand .glyph { font-size: 46px; filter: drop-shadow(0 0 18px rgba(76, 224, 179, .55)); }

h1 {
  margin: 0; font-size: clamp(24px, 4vw, 34px); letter-spacing: -.02em;
  background: linear-gradient(90deg, #fff, var(--acc)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { margin: 2px 0 0; color: var(--dim); font-size: 15px; max-width: 62ch; }

.status {
  font-size: 13px; color: var(--dim); border: 1px solid var(--line); background: rgba(17, 28, 51, .7);
  padding: 8px 14px; border-radius: 99px; white-space: nowrap;
}
.status.ok { color: var(--acc); border-color: rgba(76, 224, 179, .4); }
.status.off { color: var(--warn); border-color: rgba(255, 180, 84, .4); }

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px;
  padding: 6px clamp(16px, 4vw, 48px) 18px;
}
.stat {
  background: linear-gradient(180deg, rgba(30, 47, 82, .55), rgba(13, 21, 38, .75));
  border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px;
}
.stat b { display: block; font-size: 26px; color: var(--acc); font-variant-numeric: tabular-nums; }
.stat span { color: var(--dim); font-size: 13px; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 clamp(16px, 4vw, 48px) 14px; }
.tabs button {
  font: inherit; font-size: 14px; color: var(--dim); background: var(--bg2); border: 1px solid var(--line);
  padding: 9px 16px; border-radius: 99px; cursor: pointer; transition: .18s;
}
.tabs button:hover { color: var(--ink); border-color: var(--acc2); }
.tabs button.on { color: #04121b; background: var(--acc); border-color: var(--acc); font-weight: 700; }

main { padding: 0 clamp(16px, 4vw, 48px) 28px; }

.panel {
  background: rgba(13, 21, 38, .8); border: 1px solid var(--line); border-radius: 20px;
  padding: clamp(18px, 3vw, 30px);
}
.hidden { display: none; }
.panel h2 { margin: 0 0 6px; font-size: 22px; }
.panel > p, .game-side > p { color: var(--dim); margin: 0 0 18px; max-width: 70ch; }

.game-panel { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(260px, 340px); gap: 28px; align-items: start; }
@media (max-width: 860px) { .game-panel { grid-template-columns: 1fr; } }

.board {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  aspect-ratio: 1; max-width: 400px; margin-inline: auto;
}
.cell {
  position: relative; border: 1px solid var(--line); border-radius: 12px;
  background: #0a1120; display: grid; place-items: center;
  font-size: 13px; color: #2b3b5c; transition: .16s; user-select: none;
}
.cell.reach { cursor: pointer; border-color: rgba(88, 166, 255, .5); background: #10203c; }
.cell.reach:hover { background: #16305c; transform: translateY(-2px); }
.cell.here {
  background: radial-gradient(circle at 50% 40%, #2b6f5c, #0f2a24);
  border-color: var(--acc); box-shadow: var(--glow); color: #d8fff2; font-weight: 700;
}
.cell.here::after { content: "●"; font-size: 22px; }
.cell.visited { color: #46598a; background: #0d1729; }
.cell .arrow {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px;
  color: var(--warn); text-shadow: 0 0 12px rgba(255, 180, 84, .7); animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .cell .arrow { animation: none; } }

.dpad { display: grid; gap: 6px; justify-items: center; max-width: 230px; margin: 18px auto 0; }
.dpad button {
  font: inherit; font-size: 20px; width: 54px; height: 42px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
.dpad button:hover { border-color: var(--acc); color: var(--acc); }
.dpad .mid { display: flex; align-items: center; gap: 10px; }
.dpad .mid span { font-size: 13px; color: var(--dim); min-width: 58px; text-align: center; }

.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }
.cta, .ghost {
  font: inherit; font-weight: 700; cursor: pointer; border-radius: 11px; padding: 12px 22px; border: 1px solid transparent;
  transition: .18s;
}
.cta { background: var(--acc); color: #04121b; }
.cta:hover { filter: brightness(1.12); transform: translateY(-1px); }
.cta:disabled { opacity: .45; cursor: progress; transform: none; }
.ghost { background: transparent; color: var(--dim); border-color: var(--line); }
.ghost:hover { color: var(--ink); border-color: var(--acc2); }
.hint { font-size: 13px; color: #6f82a8; margin-top: 14px !important; }

.log-side { background: rgba(8, 14, 26, .7); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.log-side h3 { margin: 0 0 10px; font-size: 15px; color: var(--acc2); }
.log { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow: auto; font-size: 13px; }
.log li { padding: 6px 0; border-bottom: 1px dashed rgba(30, 47, 82, .8); color: var(--dim); }
.log li b { color: var(--ink); }
.log li.good b { color: var(--acc); }
.log li.bad b { color: var(--bad); }

.privacy-note { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; font-size: 12.5px; color: var(--dim); }
.privacy-note b { color: var(--ink); }
.privacy-note p { margin: 4px 0 0; }

.versus { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 16px; }
.versus b { display: block; font-size: 30px; color: var(--acc); text-align: center; }
.versus span { font-size: 12px; color: var(--dim); display: block; }
.versus .vs { color: #46598a; font-size: 13px; }
.confidence { position: relative; height: 10px; border-radius: 99px; background: #0a1120; border: 1px solid var(--line); margin: 16px auto 0; max-width: 340px; overflow: hidden; }
.confidence i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--acc2), var(--warn)); transition: width .25s; }
.confidence em { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-size: 10px; color: #04121b; }

.mindgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 460px; margin-top: 10px; }
.mind {
  border: 1px solid var(--line); border-radius: 12px; background: #0a1120; padding: 12px 6px; text-align: center;
}
.mind .a { font-size: 26px; display: block; }
.mind .c { font-size: 12px; color: var(--dim); }
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 16px; font-size: 13px; color: var(--dim); }
.legend b { color: var(--ink); }

canvas { width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--r); background: #0a1120; margin-top: 8px; }
.versions { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-top: 18px; }
.vrow { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 13px; background: rgba(17, 28, 51, .6); }
.vrow b { color: var(--acc); }
.vrow span { color: var(--dim); display: block; }

footer {
  padding: 22px clamp(16px, 4vw, 48px) 40px; color: #6f82a8; font-size: 13px;
  border-top: 1px solid var(--line); margin-top: 26px;
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between;
}
footer p { margin: 0; max-width: 72ch; }
footer a, .panel a, .log-side a { color: var(--acc2); }

.toast {
  position: fixed; inset-inline: 0; bottom: 22px; margin: auto; width: fit-content; max-width: 90vw;
  background: #0b1526; border: 1px solid var(--acc); color: var(--ink); padding: 12px 20px; border-radius: 99px;
  font-size: 14px; opacity: 0; transform: translateY(16px); transition: .25s; pointer-events: none; z-index: 20;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { border-color: var(--bad); }

article.doc { max-width: 78ch; margin: 0 auto; padding: 34px 20px 60px; }
article.doc h1 { font-size: 30px; -webkit-text-fill-color: initial; color: var(--ink); background: none; }
article.doc h2 { color: var(--acc); margin-top: 34px; font-size: 20px; }
article.doc p, article.doc li { color: #c4d2ee; }
article.doc code { background: #0a1120; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 13px; color: var(--acc); }
article.doc pre { background: #0a1120; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; overflow: auto; font-size: 13px; }
article.doc table { width: 100%; border-collapse: collapse; font-size: 14px; }
article.doc th, article.doc td { border: 1px solid var(--line); padding: 8px 10px; text-align: start; }
article.doc th { color: var(--acc2); }
.back { display: inline-block; margin-bottom: 18px; color: var(--acc2); }

.disclose {
  margin: 0 clamp(16px, 4vw, 48px) 14px; padding: 10px 16px; font-size: 13.5px; color: #cfe0ff;
  background: rgba(88, 166, 255, .09); border: 1px solid rgba(88, 166, 255, .35); border-radius: 12px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.disclose b { color: var(--acc2); }
.disclose button {
  font: inherit; font-size: 12px; margin-inline-start: auto; background: transparent; color: var(--dim);
  border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; cursor: pointer;
}
.disclose.gone { display: none; }

.voices-panel { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(280px, 360px); gap: 26px; align-items: start; }
@media (max-width: 880px) { .voices-panel { grid-template-columns: 1fr; } }

.consent {
  display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: #d6e3ff;
  background: rgba(76, 224, 179, .07); border: 1px solid rgba(76, 224, 179, .35);
  border-radius: 12px; padding: 12px 14px; cursor: pointer; margin-bottom: 14px;
}
.consent input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--acc); flex: none; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--acc2); margin-bottom: 6px; }
.field textarea, .field input, .field select {
  font: inherit; width: 100%; color: var(--ink); background: #0a1120;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.field textarea:focus, .field input:focus, .field select:focus { outline: none; border-color: var(--acc2); }
.field textarea:disabled, .field input:disabled, .field select:disabled { opacity: .45; }
.field-foot { display: flex; gap: 14px; justify-content: space-between; font-size: 12px; color: #6f82a8; margin-top: 4px; }
.pred { color: var(--warn); }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

.note { font-size: 13px; min-height: 20px; margin-top: 12px; color: var(--dim); }
.note.good { color: var(--acc); }
.note.warn { color: var(--warn); }

.brain-side { background: rgba(8, 14, 26, .7); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.brain-side h3 { margin: 18px 0 8px; font-size: 14px; color: var(--acc2); }
.brain-side h3:first-child { margin-top: 0; }
.kv { margin: 0; display: grid; gap: 4px; }
.kv div { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; border-bottom: 1px dashed rgba(30, 47, 82, .8); padding: 4px 0; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; color: var(--ink); font-variant-numeric: tabular-nums; }
.row2 { display: flex; gap: 8px; margin-top: 12px; }
.row2 button { flex: 1; font-size: 13px; padding: 9px 10px; }
.mini { font-size: 12px; color: var(--dim); margin-top: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.chip { border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; color: var(--dim); background: #0a1120; }

.poll-card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: linear-gradient(180deg, rgba(30, 47, 82, .5), rgba(10, 17, 32, .8)); }
.poll-text { font-size: 17px; color: var(--ink); margin: 0 0 10px; line-height: 1.7; }
.poll-meta { font-size: 12px; color: #6f82a8; margin-bottom: 12px; }
.poll-actions { display: flex; gap: 10px; }
.poll-actions button { font: inherit; font-weight: 700; cursor: pointer; border-radius: 10px; padding: 10px 16px; border: 1px solid transparent; flex: 1; }
.poll-actions .agree { background: var(--acc); color: #04121b; }
.poll-actions .disagree { background: transparent; color: var(--bad); border-color: rgba(255, 107, 129, .5); }
.poll-actions button:disabled { opacity: .5; cursor: progress; }
.empty { color: #6f82a8; font-size: 13px; margin: 0; }
