:root {
  color-scheme: light;
  --ink: #172133;
  --muted: #667085;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --line: rgba(23, 33, 51, 0.12);
  --accent: #29a67a;
  --accent-strong: #15805f;
  --gold: #f3b63f;
  --rose: #e96b7f;
  --blue: #3a85d8;
  --shadow: 0 18px 48px rgba(23, 33, 51, 0.22);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #dfeadf;
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

#gameCanvas {
  display: block;
  width: 100vw;
  height: 100vh;
  background: #b9d9c6;
}

.hidden {
  display: none !important;
}

.start-screen {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 520px);
  background: #e6efea;
  z-index: 20;
}

.start-visual {
  min-height: 100%;
  background-image: linear-gradient(90deg, rgba(17, 26, 40, 0.08), rgba(17, 26, 40, 0.32)), url("/assets/webp/obito-key-art.webp");
  background-position: center;
  background-size: cover;
}

.start-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: clamp(24px, 4vw, 44px);
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  border-left: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(38px, 6vw, 64px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 24px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 6px;
  font-size: 16px;
  letter-spacing: 0;
}

.start-copy {
  max-width: 28em;
  color: #3f4b5d;
  line-height: 1.6;
}

.setup-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.field input,
.code-answer {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.field input:focus,
.code-answer:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(41, 166, 122, 0.18);
}

.choice-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.choice-title,
.section-title {
  color: #374151;
  font-size: 13px;
  font-weight: 800;
}

.section-title {
  margin-top: 4px;
}

.choice,
.world-card,
.pet-card,
.ghost-button,
.primary-button,
.icon-button,
.close-button,
.answer-button,
.interact-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
}

.choice {
  padding: 9px 12px;
  font-weight: 800;
}

.choice.selected,
.world-card.selected,
.pet-card.selected {
  border-color: rgba(41, 166, 122, 0.72);
  background: rgba(41, 166, 122, 0.12);
}

.world-choice-grid,
.pet-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.world-card,
.pet-card {
  min-height: 116px;
  padding: 12px;
  text-align: left;
}

.world-card strong,
.pet-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
}

.world-card span,
.pet-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.pet-card {
  background-image: url("/assets/webp/obito-heroes-pets.webp");
  background-size: 280%;
  background-blend-mode: screen;
}

.pet-card:nth-child(1) {
  background-position: 10% 62%;
}

.pet-card:nth-child(2) {
  background-position: 48% 58%;
}

.pet-card:nth-child(3) {
  background-position: 86% 58%;
}

.start-actions,
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.primary-button,
.ghost-button {
  min-height: 42px;
  padding: 0 18px;
  font-weight: 900;
}

.primary-button {
  border-color: transparent;
  background: #1d8f6a;
  color: #fff;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.72);
}

.hud {
  position: fixed;
  z-index: 10;
  left: 16px;
  right: 16px;
  top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  pointer-events: auto;
}

.brand-pill,
.hud-chip,
.score-badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
  box-shadow: 0 8px 26px rgba(17, 26, 40, 0.12);
  font-weight: 900;
  white-space: nowrap;
}

.brand-dot {
  width: 9px;
  height: 9px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--gold);
}

.hud-chip {
  color: #344054;
  font-weight: 800;
}

.quest-chip {
  max-width: 270px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-badge {
  color: #80520c;
  background: rgba(255, 246, 220, 0.94);
}

.icon-button {
  min-width: 42px;
  min-height: 36px;
  padding: 0 10px;
  box-shadow: 0 8px 26px rgba(17, 26, 40, 0.12);
  font-weight: 900;
  white-space: nowrap;
}

.icon-button.wide {
  min-width: 58px;
}

.interact-button {
  position: fixed;
  z-index: 12;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  min-width: 96px;
  min-height: 44px;
  background: #1d8f6a;
  color: #fff;
  font-weight: 900;
  box-shadow: var(--shadow);
}

.world-map {
  position: fixed;
  z-index: 11;
  right: 16px;
  top: 66px;
  width: 172px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 30px rgba(17, 26, 40, 0.14);
}

.map-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 900;
}

.map-region {
  color: #147457;
}

.mini-map-svg {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  overflow: visible;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.map-legend span {
  border-radius: 999px;
  padding: 3px 6px;
  background: rgba(58, 133, 216, 0.09);
  color: #344054;
  font-size: 11px;
  font-weight: 800;
}

.quest-tracker {
  position: fixed;
  z-index: 11;
  left: 16px;
  bottom: 18px;
  width: min(360px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 30px rgba(17, 26, 40, 0.14);
}

.quest-tracker h3 {
  margin-bottom: 4px;
}

.quest-tracker p {
  margin-bottom: 8px;
  color: #4b5563;
  line-height: 1.45;
}

.progress-bar {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(23, 33, 51, 0.1);
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.mobile-controls {
  position: fixed;
  z-index: 13;
  inset: auto 16px 18px 16px;
  display: none;
  align-items: end;
  justify-content: space-between;
  pointer-events: none;
}

.joystick-base {
  position: relative;
  width: 116px;
  height: 116px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: rgba(23, 33, 51, 0.2);
  box-shadow: 0 12px 34px rgba(17, 26, 40, 0.22);
  pointer-events: auto;
  touch-action: none;
}

.joystick-nub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 0 0 2px rgba(23, 33, 51, 0.08), 0 8px 20px rgba(17, 26, 40, 0.18);
}

.mobile-action-stack {
  display: grid;
  grid-template-columns: 54px 62px;
  grid-template-rows: 54px 54px;
  gap: 10px;
  pointer-events: auto;
}

.mobile-action {
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  box-shadow: 0 10px 26px rgba(17, 26, 40, 0.18);
  font-weight: 900;
}

.mobile-action.primary {
  grid-row: span 2;
  width: 62px;
  height: 118px;
  border-radius: 999px;
  background: #1d8f6a;
  color: #fff;
}

.toast {
  position: fixed;
  z-index: 25;
  left: 50%;
  top: 84px;
  max-width: min(92vw, 560px);
  transform: translateX(-50%);
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  background: rgba(23, 33, 51, 0.92);
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.modal {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 26, 40, 0.42);
}

.modal-panel {
  width: min(92vw, 680px);
  max-height: min(86vh, 720px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.challenge-panel {
  padding: 22px;
  background-image: linear-gradient(rgba(255, 255, 255, 0.93), rgba(255, 255, 255, 0.96)), url("/assets/webp/obito-ui-terrain.webp");
  background-position: center;
  background-size: cover;
}

.side-panel {
  padding: 20px;
}

.challenge-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.close-button {
  width: 36px;
  height: 36px;
  font-size: 24px;
  line-height: 1;
}

.question-text {
  margin: 12px 0 14px;
  color: #253044;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.55;
}

.answer-grid {
  display: grid;
  gap: 10px;
}

.answer-button {
  padding: 12px 14px;
  text-align: left;
  font-weight: 800;
}

.answer-button.selected {
  border-color: var(--blue);
  background: rgba(58, 133, 216, 0.12);
}

.code-answer {
  min-height: 150px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  resize: vertical;
}

.feedback {
  min-height: 26px;
  margin: 12px 0;
  color: #475467;
  font-weight: 800;
}

.panel-body {
  display: grid;
  gap: 12px;
}

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

.info-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.info-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.route-list {
  display: grid;
  gap: 10px;
}

.route-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.route-row strong,
.route-row span {
  display: block;
}

.route-row span {
  color: var(--muted);
  line-height: 1.45;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(58, 133, 216, 0.1);
  color: #275d9b;
  font-size: 12px;
  font-weight: 800;
}

.tag.done {
  background: rgba(41, 166, 122, 0.12);
  color: #147457;
}

.shop-row,
.record-row,
.rank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.shop-row button,
.mini-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #f6fbf8;
  font-weight: 900;
}

@media (max-width: 880px) {
  .start-screen {
    grid-template-columns: 1fr;
  }

  .start-visual {
    min-height: 180px;
  }

  .start-panel {
    border-left: 0;
  }

  .world-choice-grid,
  .pet-choice-grid,
  .panel-grid {
    grid-template-columns: 1fr;
  }

  .hud {
    left: 8px;
    right: 8px;
    flex-direction: column;
    align-items: stretch;
  }

  .hud-left,
  .hud-right {
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .hud-left::-webkit-scrollbar,
  .hud-right::-webkit-scrollbar {
    display: none;
  }

  .hud-left > *,
  .hud-right > * {
    flex: 0 0 auto;
  }

  .brand-pill,
  .hud-chip,
  .score-badge,
  .icon-button {
    min-height: 34px;
  }

  .quest-tracker {
    left: 8px;
    bottom: 150px;
    width: min(340px, calc(100vw - 16px));
  }

  .world-map {
    right: 8px;
    top: 108px;
    width: 132px;
    padding: 8px;
  }

  .map-head {
    font-size: 11px;
  }
}

@media (pointer: coarse), (max-width: 780px) {
  .mobile-controls {
    display: flex;
  }

  .mobile-controls.hidden {
    display: none !important;
  }

  .interact-button {
    bottom: 156px;
  }
}
