:root {
  --bg: #080b16;
  --surface: #111827;
  --surface-2: #172033;
  --ink: #f8fafc;
  --muted: #a7b4c8;
  --line: #29364d;
  --blue: #38bdf8;
  --blue-soft: rgba(56, 189, 248, 0.14);
  --green: #84cc16;
  --green-soft: rgba(132, 204, 22, 0.14);
  --red: #f43f5e;
  --red-soft: rgba(244, 63, 94, 0.14);
  --amber: #facc15;
  --amber-soft: rgba(250, 204, 21, 0.14);
  --purple: #a855f7;
  --purple-soft: rgba(168, 85, 247, 0.16);
  --teal: #22d3ee;
  --shadow: 0 22px 48px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 0%, rgba(56, 189, 248, 0.18), transparent 34%),
    radial-gradient(circle at 86% 12%, rgba(168, 85, 247, 0.16), transparent 30%),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 16px 28px;
  background: rgba(8, 11, 22, 0.92);
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(56, 189, 248, 0.22);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.34);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  flex: 0 0 auto;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--amber), #f97316);
  color: #080b16;
  font-weight: 800;
  box-shadow: 0 0 24px rgba(250, 204, 21, 0.28);
}

.brand h1,
.brand p,
h2,
h3,
p {
  margin: 0;
}

.brand h1 {
  font-size: 1.05rem;
  white-space: nowrap;
}

.brand p {
  margin-top: 3px;
  color: #aeb8c4;
  font-size: 0.78rem;
  line-height: 1.35;
}

.tabs {
  display: flex;
  gap: 6px;
  flex: 1 1 auto;
  justify-content: center;
  min-width: 0;
}

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: #d6dee8;
  text-align: center;
  padding: 10px 12px;
  border-radius: 8px;
  white-space: nowrap;
}

.tab:hover,
.tab.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(168, 85, 247, 0.14));
  border-color: rgba(56, 189, 248, 0.42);
  color: #ffffff;
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.12);
}

.session-panel {
  margin-left: auto;
  padding: 10px 12px;
  border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.8);
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}

.label,
.eyebrow {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.session-panel .label {
  color: var(--blue);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 0;
  color: #c9d3df;
  white-space: nowrap;
}

main {
  min-width: 0;
  padding: 30px;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
}

h2 {
  margin-top: 4px;
  font-size: clamp(1.45rem, 2.4vw, 2.1rem);
  line-height: 1.15;
}

h3 {
  font-size: 1.08rem;
}

.round-chip,
.chart-meta span,
.scenario-card .badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--surface-2);
  color: var(--blue);
  font-size: 0.85rem;
  white-space: nowrap;
}

.assessment-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.55fr);
  gap: 18px;
}

.chart-panel,
.decision-panel,
.profile-card,
.coach-card,
.scenario-card,
.class-card,
.metrics-strip,
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.lobby-hero {
  min-height: 420px;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 20px;
  align-items: stretch;
}

.lobby-copy,
.player-card,
.mission-card {
  background: linear-gradient(145deg, rgba(17, 24, 39, 0.96), rgba(23, 32, 51, 0.92));
  border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.lobby-copy {
  padding: clamp(24px, 5vw, 56px);
  display: grid;
  align-content: center;
  gap: 18px;
}

.lobby-copy h2 {
  max-width: 850px;
  font-size: clamp(2.2rem, 6vw, 4.7rem);
  line-height: 0.98;
}

.lobby-copy p {
  max-width: 660px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
}

.lobby-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.player-card {
  padding: 24px;
  display: grid;
  align-content: center;
  gap: 14px;
}

.player-card > strong {
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1;
}

.player-card > span {
  color: var(--amber);
  font-weight: 800;
}

.xp-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #0b1020;
  border: 1px solid var(--line);
}

.xp-track div {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--blue), var(--purple), var(--amber));
}

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

.player-stats div {
  padding: 12px;
  border-radius: 8px;
  background: rgba(8, 11, 22, 0.58);
  border: 1px solid var(--line);
}

.player-stats span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 5px;
}

.mission-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.mission-card {
  padding: 18px;
}

.mission-card.active-mission {
  border-color: rgba(250, 204, 21, 0.52);
}

.mission-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 900;
}

.chart-panel {
  padding: 18px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.chart-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
}

#candle-chart {
  min-height: 330px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1020;
}

.chart-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.87rem;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.chart-legend i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.legend-up {
  background: var(--green);
}

.legend-down {
  background: var(--red);
}

.legend-reveal {
  background: var(--blue-soft);
  border: 1px solid var(--blue);
}

.decision-panel {
  padding: 18px;
  display: grid;
  gap: 16px;
  align-content: start;
}

.scenario-copy p {
  margin-top: 8px;
  line-height: 1.55;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

legend {
  padding: 0;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.83rem;
}

.decision-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.decision-buttons button,
.primary-button,
.secondary-button,
.ghost-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 9px 12px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 750;
}

.decision-buttons button.selected {
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: #ffffff;
  border-color: var(--blue);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.22);
}

.primary-button {
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: #ffffff;
  border-color: var(--blue);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.2);
}

.primary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ghost-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.secondary-button {
  background: linear-gradient(135deg, var(--green), var(--blue));
  color: #081016;
  border-color: var(--green);
}

.ghost-button {
  background: transparent;
}

.sidebar .ghost-button {
  color: #ffffff;
  border-color: rgba(56, 189, 248, 0.34);
  width: auto;
  min-height: 34px;
  margin-top: 0;
  padding: 7px 10px;
}

.range-control,
.journal-control {
  display: grid;
  gap: 8px;
}

.range-control {
  grid-template-columns: 1fr auto;
}

.range-control input {
  grid-column: 1 / -1;
  accent-color: var(--blue);
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--ink);
  background: #0b1020;
}

.feedback {
  border-radius: 8px;
  padding: 14px;
  background: var(--amber-soft);
  border: 1px solid rgba(250, 204, 21, 0.44);
  line-height: 1.5;
}

.tutorial-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 11, 22, 0.78);
  backdrop-filter: blur(12px);
}

.tutorial-card {
  width: min(640px, 100%);
  padding: 24px;
  border: 1px solid rgba(56, 189, 248, 0.34);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(17, 24, 39, 0.98), rgba(23, 32, 51, 0.98));
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.46);
}

.tutorial-topline {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.tutorial-visual {
  min-height: 150px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(56, 189, 248, 0.09) 1px, transparent 1px),
    linear-gradient(rgba(56, 189, 248, 0.09) 1px, transparent 1px),
    #0b1020;
  background-size: 34px 34px;
  color: var(--amber);
  font-size: clamp(2.2rem, 8vw, 4rem);
  font-weight: 900;
  letter-spacing: 0.08em;
}

.tutorial-card h3 {
  font-size: 1.45rem;
}

.tutorial-card p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.55;
}

.tutorial-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-top: 22px;
}

.tutorial-actions div {
  display: flex;
  gap: 10px;
}

.result-modal {
  position: fixed;
  inset: 0;
  z-index: 32;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 12px;
  background: rgba(8, 11, 22, 0.86);
  backdrop-filter: blur(14px);
}

.result-shell {
  position: relative;
  width: clamp(360px, 30vw, 520px);
  max-width: calc(100vw - 24px);
  padding: 14px;
  border: 1px solid rgba(56, 189, 248, 0.34);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(17, 24, 39, 0.99), rgba(23, 32, 51, 0.99));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.52);
}

.result-close {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #0b1020;
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1;
}

.result-close:hover {
  border-color: var(--red);
  color: var(--red);
}

.result-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  min-height: 36px;
  margin-bottom: 10px;
  padding-left: 40px;
}

.result-header h2 {
  font-size: 1.1rem;
}

.result-header .eyebrow {
  font-size: 0.65rem;
}

.result-header .round-chip {
  padding: 5px 8px;
  font-size: 0.72rem;
}

#result-card {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #080b16;
}

.share-status {
  min-height: 18px;
  margin-top: 7px;
  color: var(--green);
  font-size: 0.75rem;
  text-align: center;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.result-actions button {
  min-height: 38px;
  padding: 7px 9px;
  font-size: 0.82rem;
}

.hidden {
  display: none !important;
}

.profile-grid,
.coaching-grid,
.classroom-grid,
.scenario-bank {
  display: grid;
  gap: 14px;
}

.profile-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

.profile-card,
.coach-card,
.scenario-card,
.class-card {
  padding: 16px;
}

.bias-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.severity {
  min-width: 68px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--red-soft);
  color: var(--red);
  font-weight: 800;
}

.profile-card p,
.coach-card p,
.scenario-card p,
.class-card p {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.48;
}

.meter {
  margin-top: 12px;
  height: 9px;
  border-radius: 999px;
  background: #0b1020;
  overflow: hidden;
  border: 1px solid var(--line);
}

.meter div {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--purple));
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 18px;
}

.metrics-strip div {
  padding: 16px;
}

.metrics-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.metrics-strip strong {
  font-size: 1.25rem;
}

#progress-chart,
#progress-pie-chart {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

#progress-pie-chart {
  margin-top: 18px;
}

.coaching-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.scenario-bank {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.scenario-card {
  display: grid;
  gap: 10px;
}

.scenario-card .badge {
  width: fit-content;
  background: var(--blue-soft);
  color: var(--blue);
  border-color: rgba(56, 189, 248, 0.34);
}

select {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

input[type="range"] {
  accent-color: var(--blue);
}

::placeholder {
  color: #64748b;
}

@media (max-width: 1080px) {
  .sidebar {
    position: static;
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .tabs {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .session-panel {
    margin-left: 0;
    justify-content: space-between;
  }

  .assessment-grid,
  .lobby-hero,
  .profile-grid,
  .coaching-grid,
  .scenario-bank {
    grid-template-columns: 1fr;
  }

  .mission-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  main,
  .sidebar {
    padding: 16px;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
  }

  .tab {
    white-space: normal;
  }

  .session-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .result-modal {
    padding: 12px;
  }

  .result-shell {
    padding: 14px;
  }

  .topbar,
  .chart-header {
    align-items: stretch;
    flex-direction: column;
  }

  .chart-meta {
    justify-content: flex-start;
  }

  .decision-buttons,
  .metrics-strip,
  .mission-grid,
  .player-stats {
    grid-template-columns: 1fr;
  }

  .lobby-copy h2 {
    font-size: 2.35rem;
  }
}
