:root {
  color-scheme: dark;
  --bg: #080d19;
  --surface: #10182a;
  --surface-2: #151f35;
  --surface-3: #1a2741;
  --line: rgba(255,255,255,.1);
  --text: #f4f7ff;
  --muted: #aeb9cf;
  --gold: #efc86c;
  --purple: #9d68ff;
  --purple-soft: rgba(157,104,255,.18);
  --blue: #4aa8ff;
  --green: #52d78c;
  --orange: #ffb24d;
  --red: #ff6f70;
  --shadow: 0 18px 50px rgba(0,0,0,.32);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--bg); scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, rgba(113,61,192,.22), transparent 30rem),
    radial-gradient(circle at 100% 18%, rgba(31,104,181,.16), transparent 32rem),
    var(--bg);
  color: var(--text);
}

button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.site-shell {
  width: min(100%, 860px);
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 10px;
  align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: rgba(8,13,25,.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; justify-content: center; gap: 9px; min-width: 0; }
.brand-mark { color: var(--gold); font-size: 22px; }
.brand-kicker { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.1; }
.brand h1 { margin: 2px 0 0; font-size: 17px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}

.app { padding: 16px 14px 8px; }

.hero {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(57,35,100,.55), rgba(17,27,47,.95) 56%, rgba(13,20,35,.98));
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: .08em;
  font-size: 12px;
}

.hero h2 { margin: 0; font-size: clamp(26px, 7vw, 38px); line-height: 1.18; }
.hero p { margin: 10px 0 0; color: var(--muted); line-height: 1.7; }
.hero-note { margin-top: 14px; padding: 11px 13px; border-radius: 14px; background: rgba(255,255,255,.055); color: #d9e2f4; font-size: 13px; }

.section { margin-top: 18px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-heading h3 { margin: 0; font-size: 20px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 12px; }

.tribe-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 11px;
}

.tribe-card {
  position: relative;
  min-height: 132px;
  padding: 18px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(255,255,255,.045), rgba(255,255,255,.018));
  color: var(--text);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}

.tribe-card::after {
  content: "";
  position: absolute;
  inset: auto -25px -45px auto;
  width: 105px;
  height: 105px;
  border-radius: 50%;
  background: var(--tribe-accent, rgba(157,104,255,.12));
  filter: blur(8px);
}

.tribe-card.is-ready { border-color: rgba(157,104,255,.48); box-shadow: inset 0 0 24px rgba(157,104,255,.08); }
.tribe-icon { display: block; font-size: 38px; margin-bottom: 12px; }
.tribe-name { position: relative; z-index: 1; display: block; font-size: 18px; font-weight: 800; }
.status-badge { position: relative; z-index: 1; display: inline-flex; margin-top: 7px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; }
.status-badge.ready { color: #e6dbff; border-color: rgba(157,104,255,.4); background: var(--purple-soft); }

.guide-header {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 23px;
  background: linear-gradient(150deg, rgba(48,31,83,.68), rgba(15,24,41,.96));
  box-shadow: var(--shadow);
}
.guide-title-row { display: flex; gap: 12px; align-items: center; }
.guide-icon { font-size: 40px; }
.guide-header h2 { margin: 0; font-size: 29px; }
.guide-meta { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.guide-warning { margin-top: 12px; padding: 10px 12px; border-radius: 13px; background: rgba(239,200,108,.08); border: 1px solid rgba(239,200,108,.2); color: #eadfbf; font-size: 12px; line-height: 1.6; }

.board-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.card-tile {
  position: relative;
  min-height: 210px;
  padding: 0;
  border: 1px solid rgba(239,200,108,.24);
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(180deg, #17223a, #10182a);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.card-art {
  min-height: 124px;
  display: grid;
  place-items: center;
  padding: 14px;
  background:
    radial-gradient(circle at 50% 35%, rgba(157,104,255,.28), transparent 45%),
    linear-gradient(145deg, #17223c, #0d1424);
  color: rgba(255,255,255,.75);
  font-size: 12px;
}
.card-art-symbol { font-size: 38px; display: block; margin-bottom: 5px; text-align: center; }
.card-info { padding: 11px 12px 13px; }
.card-info strong { display: block; font-size: 14px; line-height: 1.35; }
.card-info span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.card-tier { position: absolute; top: 8px; left: 8px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px; background: #55328e; border: 1px solid #b38bff; font-weight: 800; }

.empty-panel,
.content-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.032);
}
.empty-panel { color: var(--muted); text-align: center; line-height: 1.7; }

.quick-links {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.quick-link {
  min-height: 70px;
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255,255,255,.035);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}
.quick-link span { display: block; font-size: 20px; margin-bottom: 4px; }

.phase-tabs { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 10px; }
.phase-tab {
  padding: 11px 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,255,255,.03);
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}
.phase-tab.active { color: #fff; border-color: rgba(157,104,255,.55); background: var(--purple-soft); }
.phase-panel h4 { margin: 0 0 9px; font-size: 18px; }
.phase-panel ul { margin: 0; padding-left: 1.15em; color: #dbe3f4; }
.phase-panel li + li { margin-top: 7px; }
.phase-caption { margin: 12px 0 0; color: var(--muted); font-size: 12px; }

.decision-grid { display: grid; grid-template-columns: 1fr; gap: 9px; }
.decision-card { padding: 14px; border-radius: 15px; border: 1px solid var(--line); background: rgba(255,255,255,.025); }
.decision-card h4 { margin: 0 0 5px; font-size: 15px; }
.decision-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.decision-card.continue { border-color: rgba(82,215,140,.35); }
.decision-card.pivot { border-color: rgba(255,178,77,.35); }
.decision-card.cash { border-color: rgba(255,111,112,.35); }

.placeholder-list { display: grid; gap: 9px; }
.placeholder-item { padding: 13px; border: 1px dashed rgba(255,255,255,.17); border-radius: 14px; color: var(--muted); font-size: 13px; }

.back-link {
  margin-bottom: 11px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: #d5c7ff;
  cursor: pointer;
}

.card-dialog,
.about-dialog {
  width: min(92vw, 520px);
  max-height: min(84vh, 760px);
  padding: 0;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 24px;
  background: #0e1627;
  color: var(--text);
  box-shadow: 0 28px 90px rgba(0,0,0,.6);
  overflow: auto;
}
.card-dialog::backdrop,
.about-dialog::backdrop { background: rgba(0,0,0,.78); backdrop-filter: blur(5px); }
.dialog-close { position: sticky; top: 10px; float: right; z-index: 5; margin: 10px 10px 0 0; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: rgba(8,13,25,.88); color: var(--gold); font-size: 28px; cursor: pointer; }
.dialog-card-art { min-height: 280px; display: grid; place-items: center; padding: 28px 18px; background: radial-gradient(circle at 50% 35%, rgba(82,183,255,.24), transparent 38%), linear-gradient(145deg,#17223c,#0b1220); }
.dialog-card-art .big-symbol { font-size: 76px; }
.dialog-body { padding: 18px 20px 23px; }
.dialog-body h2 { margin: 0 52px 6px 0; font-size: 25px; }
.dialog-body .effect { margin: 13px 0; padding: 13px; border-radius: 14px; background: rgba(255,255,255,.05); line-height: 1.7; }
.meta-list { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
.meta-list strong { color: var(--gold); }
.about-dialog { padding: 22px; }
.about-dialog h2 { margin-top: 20px; }
.about-dialog p { color: var(--muted); line-height: 1.75; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 100;
  transform: translate(-50%, 20px);
  width: min(88vw, 420px);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(18,27,46,.96);
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  text-align: center;
  box-shadow: var(--shadow);
  font-size: 13px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.footer { padding: 24px 18px 0; text-align: center; color: #7f8ca5; font-size: 11px; }
.footer p { margin: 4px 0; }

@media (min-width: 560px) {
  .tribe-grid { grid-template-columns: repeat(4, 1fr); }
  .board-grid { grid-template-columns: repeat(4, 1fr); }
  .board-grid .card-tile:nth-child(n+5) { grid-column: auto; }
  .quick-links { grid-template-columns: repeat(5, 1fr); }
  .decision-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
