:root {
  color-scheme: dark;
  --bg: #0d1115;
  --bg-2: #121a1f;
  --panel: #182127;
  --panel-strong: #202b31;
  --panel-muted: #26343a;
  --text: #f3f7f6;
  --muted: #a8b5ba;
  --line: #34454c;
  --accent: #5ee0be;
  --accent-strong: #9affdf;
  --gold: #f2b84b;
  --danger: #e06d5a;
  --success: #5ee0be;
  --shadow: 0 20px 46px rgba(0, 0, 0, 0.32);
  --glow: 0 0 0 1px rgba(94, 224, 190, 0.32), 0 0 24px rgba(94, 224, 190, 0.13);
}

body.light {
  color-scheme: light;
  --bg: #eef2ed;
  --bg-2: #dfe9e3;
  --panel: #ffffff;
  --panel-strong: #f4f8f5;
  --panel-muted: #e6eee9;
  --text: #192125;
  --muted: #5d6a70;
  --line: #c8d4ce;
  --accent: #1f7a68;
  --accent-strong: #15584b;
  --gold: #b87922;
  --danger: #b84d40;
  --success: #248752;
  --shadow: 0 18px 42px rgba(31, 35, 40, 0.12);
  --glow: 0 0 0 1px rgba(31, 122, 104, 0.25), 0 0 22px rgba(31, 122, 104, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(rgba(94, 224, 190, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(94, 224, 190, 0.045) 1px, transparent 1px),
    radial-gradient(circle at 50% -10%, rgba(242, 184, 75, 0.12), transparent 34%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 48%, #090c10);
  background-size: 28px 28px, 28px 28px, auto, auto;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.18));
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px calc(88px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.brand-mark {
  width: 48px;
  height: 48px;
  filter: drop-shadow(0 0 14px rgba(94, 224, 190, 0.32));
}

.topbar h1,
.section-heading h2,
.lesson-panel h2,
.profile-header h2 {
  margin: 0;
}

.topbar h1 {
  overflow-wrap: anywhere;
  font-size: 24px;
  line-height: 1.12;
}

.eyebrow,
.label {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
  color: var(--accent-strong);
  box-shadow: var(--shadow);
}

.screen {
  min-height: calc(100vh - 170px);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.progress-strip,
.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 18px;
}

.progress-track {
  height: 10px;
  margin: -8px 0 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(12, 17, 21, 0.72);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  box-shadow: 0 0 18px rgba(94, 224, 190, 0.35);
  transition: width 240ms ease;
}

.progress-caption {
  margin: -12px 0 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.progress-strip > div,
.profile-stats > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(94, 224, 190, 0.08), transparent 42%),
    var(--panel);
  box-shadow: var(--shadow);
}

.progress-strip strong,
.profile-stats strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.section-heading {
  margin: 22px 0 12px;
}

.section-heading h2 {
  font-size: 19px;
}

.section-heading p {
  margin: 5px 0 0;
  color: var(--muted);
}

.map-stage {
  position: relative;
  overflow: visible;
  padding: 0 0 0 10px;
}

.map-stage::before {
  content: "";
  position: absolute;
  top: 16px;
  bottom: 16px;
  left: 33px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(var(--accent), var(--gold), var(--danger));
  opacity: 0.78;
}

.map-scanline {
  display: none;
}

.map-list {
  position: relative;
  display: grid;
  gap: 10px;
}

.map-point {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 86px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(94, 224, 190, 0.08), transparent 30%),
    color-mix(in srgb, var(--panel) 94%, transparent);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow);
}

.map-point.is-completed,
.map-point.is-current {
  box-shadow: var(--glow);
}

.point-badge {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #10161a;
  color: var(--accent-strong);
  font-weight: 900;
  box-shadow: inset 0 0 18px rgba(94, 224, 190, 0.14);
}

body.light .point-badge {
  background: var(--panel-muted);
}

.map-point.is-completed .point-badge {
  border-color: var(--success);
  background: var(--success);
  color: #07100d;
}

.map-point.is-current {
  border-color: var(--accent);
}

.map-point h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.map-point p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.point-status {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.lesson-panel {
  position: relative;
  overflow: hidden;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(94, 224, 190, 0.1), transparent 35%),
    linear-gradient(180deg, var(--panel-strong), var(--panel));
  box-shadow: var(--shadow);
}

.lesson-panel::before {
  content: "MISSION BRIEFING";
  position: absolute;
  top: 12px;
  right: 14px;
  color: color-mix(in srgb, var(--gold) 70%, transparent);
  font-size: 10px;
  font-weight: 900;
}

.lesson-kicker {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.lesson-panel h2 {
  margin-top: 4px;
  padding-right: 96px;
  font-size: 24px;
  line-height: 1.15;
}

.lesson-lore {
  color: var(--muted);
  line-height: 1.55;
}

.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.lesson-meta span,
.result-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-muted);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.lesson-block {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.lesson-block h3 {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 15px;
  text-transform: uppercase;
}

.lesson-block p,
.lesson-block li {
  color: var(--muted);
  line-height: 1.55;
}

.lesson-block ul {
  margin: 8px 0 0;
  padding-left: 19px;
}

pre {
  overflow: auto;
  margin: 10px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #070a0d;
  color: #dffcf4;
}

.file-drop {
  display: block;
  padding: 16px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
}

.file-drop span {
  display: block;
  font-weight: 900;
}

.file-drop small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.check-results {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.check-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  color: var(--muted);
}

.check-row.is-pass {
  color: var(--success);
}

.check-row.is-fail {
  color: var(--danger);
}

.actions,
.inline-edit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 8px;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  font-weight: 900;
}

.primary-button {
  border: 1px solid var(--accent);
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 72%, #000));
  color: #07100d;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.profile-header {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #10161a;
  color: var(--accent-strong);
  font-weight: 900;
  box-shadow: var(--glow);
}

.input-label {
  display: block;
  margin: 22px 0 8px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.inline-edit {
  grid-template-columns: minmax(0, 1fr) 128px;
}

.inline-edit input {
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.achievement-list {
  display: grid;
  gap: 8px;
}

.achievement {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.achievement.is-locked {
  opacity: 0.5;
}

.achievement strong {
  display: block;
}

.achievement small {
  color: var(--muted);
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px);
}

.treasure-map {
  display: block;
  width: 100%;
  min-height: 315px;
  border-radius: 8px;
  filter: drop-shadow(0 24px 28px rgba(0, 0, 0, 0.3));
}

.map-parchment {
  fill: #d8b46f;
  stroke: #8d6634;
  stroke-width: 4;
  filter: url(#mapShadow);
}

body.light .map-parchment {
  fill: #ead4a0;
  stroke: #9d7440;
}

.map-sea-line {
  fill: none;
  stroke: rgba(52, 75, 78, 0.38);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 10 12;
}

.map-route {
  fill: none;
  stroke: url(#routeGradient);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 12 16;
}

.map-island {
  cursor: pointer;
}

.island-shape {
  fill: rgba(69, 91, 70, 0.72);
  stroke: rgba(37, 55, 44, 0.62);
  stroke-width: 3;
}

.map-island.is-available .island-shape {
  fill: rgba(38, 98, 83, 0.86);
  stroke: var(--accent);
}

.map-island.is-current .island-shape {
  filter: drop-shadow(0 0 16px rgba(94, 224, 190, 0.42));
}

.map-island.is-complete .island-shape {
  fill: rgba(63, 134, 82, 0.9);
}

.island-pin {
  fill: #111820;
  stroke: var(--accent);
  stroke-width: 4;
}

.map-island:not(.is-available) .island-pin {
  stroke: rgba(28, 35, 39, 0.55);
}

.island-number,
.island-title,
.island-subtitle {
  font-family: Inter, system-ui, sans-serif;
  pointer-events: none;
}

.island-number {
  fill: var(--accent-strong);
  font-size: 19px;
  font-weight: 900;
  text-anchor: middle;
}

.island-title {
  fill: #151713;
  font-size: 17px;
  font-weight: 900;
}

.island-subtitle {
  fill: rgba(21, 23, 19, 0.72);
  font-size: 12px;
  font-weight: 800;
}

.map-legend,
.course-grid,
.mission-list {
  display: grid;
  gap: 10px;
}

.map-legend {
  margin-top: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.legend-item,
.course-card,
.mission-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(242, 184, 75, 0.08), transparent 38%),
    var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.legend-item {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 84px;
  padding: 10px;
  text-align: left;
}

.legend-item.is-open {
  border-color: var(--accent);
  box-shadow: var(--glow);
}

.legend-item strong,
.legend-item span,
.legend-item small {
  overflow-wrap: anywhere;
}

.legend-item strong {
  color: var(--gold);
}

.legend-item small {
  color: var(--muted);
  font-weight: 800;
}

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

.course-card {
  min-height: 206px;
  padding: 14px;
}

.course-card.is-open {
  border-color: var(--accent);
}

.course-card-top,
.course-metrics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.course-index,
.course-status,
.course-metrics span,
.boss-label {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--panel-muted);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.course-index {
  width: 32px;
  justify-content: center;
  background: #111820;
  color: var(--accent-strong);
}

.course-card h3 {
  margin: 12px 0 8px;
  font-size: 18px;
}

.course-card p {
  margin: 8px 0;
  color: var(--muted);
  line-height: 1.45;
}

.course-stack {
  font-size: 13px;
}

.lesson-outline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 2px;
}

.lesson-outline span {
  display: grid;
  place-items: center;
  min-height: 34px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(94, 224, 190, 0.08);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.boss-label {
  margin-top: 6px;
  color: var(--gold);
}

.mission-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
}

.mission-row p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.mission-step {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  color: var(--accent-strong);
  font-weight: 900;
}

.tab-button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.tab-button.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, var(--panel));
  color: var(--accent-strong);
  box-shadow: var(--glow);
}

@media (max-width: 430px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .brand-lockup {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .progress-strip,
  .profile-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .progress-strip > div,
  .profile-stats > div {
    padding: 9px;
  }

  .progress-strip strong,
  .profile-stats strong {
    font-size: 15px;
  }

  .map-stage {
    padding-left: 0;
  }

  .map-stage::before {
    display: none;
  }

  .treasure-map {
    min-height: 280px;
  }

  .island-title {
    display: none;
  }

  .island-subtitle {
    display: none;
  }

  .legend-item,
  .course-grid {
    grid-template-columns: 1fr;
  }

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

  .legend-item {
    min-height: 76px;
  }

  .legend-item span {
    font-size: 13px;
  }

  .legend-item small {
    display: none;
  }

  .course-card {
    min-height: auto;
  }

  .map-point {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .point-badge {
    width: 42px;
    height: 42px;
  }

  .point-status {
    grid-column: 2;
  }

  .lesson-panel h2 {
    padding-right: 0;
  }

  .lesson-panel::before {
    display: none;
  }

  .actions {
    grid-template-columns: 1fr;
  }

  .inline-edit {
    grid-template-columns: 1fr;
  }
}
