:root {
  --sky-a: #201D46;
  --sky-b: #141C38;
  --sky-c: #142D42;
  --paper: #FFFFFF;
  --paper-deep: #EDF3FA;
  --paper-soft: #F7FAFE;
  --paper-line: #CAD7E8;
  --ink: #23354F;
  --ink-soft: #536981;
  --ink-faint: #6C7F93;
  --stamp: #167A96;
  --stamp-deep: #155C73;
  --line-koku: #53AD85;
  --line-shoku: #D5AB4C;
  --line-kogyo: #5A9ABB;
  --line-joho: #A08AC4;
  --line-kankyo: #55A99C;
  --line-sei: #7695CF;
  --line-rek: #CA7E79;
  --line-kok: #48ACBC;
  --ok: #278561;
  --warn: #9F6430;
  --locked: #758294;
  --gold: #E3B857;
  --shadow: 0 22px 70px rgba(4, 10, 30, .35);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

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

body {
  margin: 0;
  color: var(--ink);
  font-family: "Zen Maru Gothic", "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  background: linear-gradient(150deg, var(--sky-a), var(--sky-b) 55%, var(--sky-c));
  background-attachment: fixed;
  padding: 24px 12px 48px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(184, 84, 74, .42);
  outline-offset: 2px;
}

.app-shell {
  position: relative;
  width: min(1120px, 100%);
  min-height: calc(100vh - 72px);
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid rgba(246, 238, 225, .74);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(0deg, rgba(92, 79, 66, .035) 0 1px, transparent 1px 4px);
}

.paper-grain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: .42;
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 1;
}

.app-header,
.tabbar,
.screen-frame {
  position: relative;
  z-index: 2;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 2px solid var(--paper-line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  color: var(--stamp);
  flex: 0 0 auto;
}

.brand h1,
.section-head h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.15;
}

.brand h1 {
  font-family: "Klee One", "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 28px;
}

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

.player-card {
  display: grid;
  gap: 2px;
  min-width: 170px;
  padding: 10px 12px;
  background: rgba(225, 214, 180, .8);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  text-align: right;
}

.player-card span,
.player-card small {
  color: var(--ink-soft);
  font-size: 12px;
}

.player-card strong {
  color: var(--stamp);
  font-size: 22px;
  line-height: 1;
}

.tabbar {
  display: flex;
  gap: 2px;
  padding: 0 18px;
  background: rgba(225, 214, 180, .42);
  border-bottom: 1px solid var(--paper-line);
}

.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  min-width: 104px;
  padding: 13px 14px 12px;
  font-weight: 800;
}

.tab.active {
  color: var(--ink);
  border-bottom-color: var(--stamp);
}

.screen-frame {
  padding: 20px;
}

.screen {
  display: none;
  position: relative;
}

.screen.active {
  display: block;
}

.ambient-motes {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.mote {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 250, 236, .72);
  box-shadow: 0 0 18px rgba(255, 250, 236, .78);
  opacity: .42;
  animation: moteDrift 8s ease-in-out infinite alternate;
}

.mote:nth-child(1) {
  top: 10%;
  left: 8%;
}

.mote:nth-child(2) {
  top: 28%;
  right: 14%;
  animation-delay: -2s;
}

.mote:nth-child(3) {
  right: 8%;
  bottom: 18%;
  animation-delay: -5s;
}

.mote:nth-child(4) {
  bottom: 12%;
  left: 20%;
  animation-delay: -3s;
}

.screen > :not(.ambient-motes) {
  position: relative;
  z-index: 1;
}

@keyframes moteDrift {
  from {
    transform: translate3d(0, 0, 0) scale(.84);
  }

  to {
    transform: translate3d(10px, -14px, 0) scale(1.1);
  }
}

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

.section-head h2 {
  font-size: 24px;
}

.ghost-button,
.primary-button,
.danger-button,
.choice-button,
.tier-button,
.station-button,
.branch-button {
  border-radius: var(--radius);
  border: 1px solid var(--paper-line);
  min-height: 42px;
  padding: 9px 12px;
  font-weight: 800;
}

.ghost-button {
  color: var(--ink);
  background: rgba(248, 242, 223, .75);
}

.primary-button {
  color: var(--paper);
  background: var(--stamp);
  border-color: var(--stamp-deep);
}

.danger-button {
  color: var(--paper);
  background: var(--stamp-deep);
  border-color: #7A3730;
}

.map-stack {
  display: grid;
  gap: 16px;
}

.line-panel {
  background: rgba(248, 242, 223, .7);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  padding: 14px;
}

.line-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.line-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.line-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--line-color);
  flex: 0 0 auto;
}

.line-title h3 {
  margin: 0;
  font-size: 18px;
}

.line-meta {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 800;
}

.station-list.route {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(174px, 1fr));
  gap: 10px;
}

.station-group {
  display: grid;
  gap: 10px;
}

.station-list.route .station-group {
  grid-column: 1 / -1;
  grid-template-columns: repeat(auto-fit, minmax(174px, 1fr));
}

.station-list.sugoroku {
  display: grid;
  gap: 10px;
  max-height: 560px;
  overflow: auto;
  padding-left: 18px;
  border-left: 4px solid var(--line-color);
}

.station-list.sugoroku .station-group {
  grid-template-columns: 1fr;
}

.station-list.world {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  gap: 14px;
  align-items: center;
}

.world-map {
  min-height: 164px;
  color: var(--line-color);
  display: grid;
  place-items: center;
  background: rgba(46, 122, 142, .09);
  border: 1px dashed rgba(46, 122, 142, .4);
  border-radius: var(--radius);
}

.world-map svg {
  width: min(170px, 70%);
}

.world-station-group {
  grid-template-columns: repeat(auto-fit, minmax(174px, 1fr));
}

.station-button {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 112px;
  padding: 12px;
  text-align: left;
  background: var(--paper-soft);
  color: var(--ink);
  isolation: isolate;
  overflow: hidden;
}

.station-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: .88;
  pointer-events: none;
}

.station-button.locked .station-bg,
.station-button.coming-soon .station-bg {
  opacity: .42;
}

.station-button > :not(.station-bg) {
  position: relative;
  z-index: 1;
}

.station-button.playable {
  border-color: color-mix(in srgb, var(--line-color), var(--paper-line) 35%);
}

.station-button.coming-soon,
.station-button.locked {
  background: rgba(225, 214, 180, .58);
  color: var(--locked);
}

.station-button.locked {
  opacity: .72;
}

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

.station-number {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--paper);
  background: var(--line-color);
  font-size: 12px;
  flex: 0 0 auto;
}

.station-status {
  font-size: 11px;
  color: var(--ink-soft);
}

.station-name {
  display: block;
  margin-top: 8px;
  font-size: 16px;
  line-height: 1.3;
}

.station-sub {
  margin-top: 5px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.4;
}

.stamp-row {
  display: flex;
  gap: 5px;
  align-self: end;
  margin-top: 8px;
}

.mini-stamp {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--paper-line);
  border-radius: 50%;
  color: var(--ink-faint);
  background: rgba(255, 255, 255, .22);
  font-size: 10px;
  font-weight: 900;
}

.mini-stamp.clear {
  color: var(--stamp);
  border-color: var(--stamp);
  background: rgba(184, 84, 74, .09);
}

.node-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 18px;
}

.node-panel,
.quiz-panel,
.result-panel,
.settings-panel,
.collection-summary,
.collection-section {
  background: rgba(248, 242, 223, .76);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  padding: 16px;
}

.node-panel h2,
.quiz-panel h2,
.result-panel h2,
.collection-section h3 {
  margin: 0 0 8px;
  line-height: 1.25;
}

.node-meta {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.6;
}

.reward-preview {
  display: grid;
  gap: 10px;
}

.reward-line {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: rgba(225, 214, 180, .55);
  border-radius: var(--radius);
}

.reward-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: var(--stamp);
}

.reward-icon svg {
  width: 44px;
  height: 44px;
}

.sq-icon {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.sq-icon-somber {
  filter: saturate(.78);
}

.branch-grid,
.tier-grid,
.collection-grid {
  display: grid;
  gap: 12px;
}

.branch-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.tier-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.branch-button,
.tier-button {
  width: 100%;
  text-align: left;
  background: var(--paper-soft);
  color: var(--ink);
}

.branch-button strong,
.tier-button strong {
  display: block;
  margin-bottom: 4px;
  font-size: 16px;
}

.branch-button span,
.tier-button span {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
}

.tier-button:disabled,
.branch-button:disabled,
.choice-button:disabled {
  cursor: not-allowed;
  opacity: .6;
}

.tier-button.kikitori {
  background: #E7E0D0;
  border-color: #C8BA9A;
}

.tier-button.clear {
  border-color: var(--stamp);
  box-shadow: inset 0 0 0 2px rgba(184, 84, 74, .15);
}

.back-row {
  margin-bottom: 14px;
}

.quiz-panel {
  max-width: 760px;
  margin: 0 auto;
}

.quiz-progress {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 14px;
}

.question-text {
  font-size: 22px;
  line-height: 1.55;
  margin: 0 0 18px;
}

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

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

.choice-button {
  width: 100%;
  min-height: 56px;
  background: var(--paper-soft);
  color: var(--ink);
  text-align: left;
}

.choice-button.correct {
  border-color: var(--ok);
  background: rgba(71, 122, 88, .13);
}

.choice-button.wrong {
  border-color: var(--stamp);
  background: rgba(184, 84, 74, .11);
}

.feedback {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  background: rgba(225, 214, 180, .58);
  line-height: 1.55;
}

.feedback.good {
  border-color: var(--ok);
}

.feedback.bad {
  border-color: var(--stamp);
}

.quiz-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.result-panel {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
}

.stamp-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 124px;
  height: 124px;
  margin: 6px auto 12px;
}

.impact-ring {
  position: absolute;
  width: 78px;
  height: 78px;
  border: 0;
  background:
    radial-gradient(circle, rgba(255, 250, 236, .62) 0 28%, rgba(184, 84, 74, .22) 48%, rgba(184, 84, 74, 0) 72%);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

.stamp-stage.kikitori .impact-ring {
  background:
    radial-gradient(circle, rgba(255, 250, 236, .48) 0 28%, rgba(139, 128, 112, .22) 48%, rgba(139, 128, 112, 0) 72%);
}

.hanko-stamp-anim {
  width: 92px;
  height: 92px;
  opacity: 0;
  transform-origin: center;
}

.hanko-stamp-anim.play {
  animation: softIn .62s ease-out both;
}

.impact-ring.play {
  animation: glowPulse 1.05s ease-out both;
}

@keyframes softIn {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(.88) rotate(-3deg);
  }

  70% {
    opacity: 1;
    transform: translateY(0) scale(1.04) rotate(-3deg);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(-3deg);
  }
}

@keyframes glowPulse {
  0% {
    opacity: 0;
    transform: scale(.72);
    filter: blur(0);
  }

  100% {
    opacity: 0;
    transform: scale(1.9);
    filter: blur(2px);
  }
}

.result-list {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  text-align: left;
}

.result-line {
  padding: 10px;
  border-radius: var(--radius);
  background: rgba(225, 214, 180, .55);
}

.collection-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.summary-tile {
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(225, 214, 180, .62);
}

.summary-tile strong {
  display: block;
  color: var(--stamp);
  font-size: 24px;
}

.collection-sections {
  display: grid;
  gap: 16px;
}

.collection-grid {
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}

.collection-card {
  min-height: 158px;
  padding: 12px;
  background: var(--paper-soft);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
}

.collection-card.locked {
  color: var(--locked);
  background: rgba(225, 214, 180, .55);
}

.collection-card .reward-icon {
  margin-bottom: 8px;
}

.collection-card h4 {
  margin: 0 0 5px;
  font-size: 15px;
  line-height: 1.35;
}

.collection-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.45;
}

.achievement-grid {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.achievement-card {
  min-height: 146px;
}

.achievement-card .reward-icon {
  color: var(--gold);
}

.achievement-card.locked {
  filter: grayscale(1);
  opacity: .58;
}

.achievement-lock-icon {
  color: var(--ink-faint);
}

.achievement-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(92, 79, 66, .38);
  opacity: 0;
  pointer-events: none;
  transition: opacity .24s ease;
}

.achievement-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.achievement-modal {
  width: min(360px, 100%);
  padding: 24px 22px;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--gold);
  border-radius: var(--radius);
  text-align: center;
  box-shadow: 0 22px 60px rgba(92, 79, 66, .24);
  opacity: 0;
  transform: scale(.72);
}

.achievement-overlay.show .achievement-modal {
  animation: achievementPop .52s ease-out forwards;
}

.achievement-modal-badge {
  width: 68px;
  height: 68px;
  margin-bottom: 10px;
}

.achievement-label {
  margin: 0;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
}

.achievement-modal h2 {
  margin: 4px 0 6px;
  color: var(--stamp-deep);
  font-family: "Klee One", "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 24px;
  line-height: 1.25;
}

.achievement-modal p:last-of-type {
  margin: 0 0 16px;
  color: var(--ink-soft);
  line-height: 1.55;
}

@keyframes achievementPop {
  0% {
    opacity: 0;
    transform: scale(.62);
  }

  60% {
    opacity: 1;
    transform: scale(1.04);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.common-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.common-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(225, 214, 180, .55);
  border-radius: var(--radius);
  font-size: 13px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--paper-line);
}

.switch-row strong,
.switch-row small {
  display: block;
}

.switch-row small {
  color: var(--ink-soft);
  margin-top: 2px;
}

.settings-panel > button {
  width: 100%;
  margin-top: 12px;
}

.report-panel {
  max-width: 780px;
  margin: 0 auto;
  background: rgba(248, 242, 223, .76);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  padding: 16px;
}

.report-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 12px 14px;
  color: var(--paper);
  background: var(--ink);
  border-radius: var(--radius);
}

.report-top span,
.report-footer span {
  display: block;
  font-size: 11px;
  opacity: .72;
}

.report-top strong {
  display: block;
  color: var(--gold);
  font-family: "Klee One", "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 22px;
  line-height: 1.25;
}

.overall-report {
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(225, 214, 180, .62);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
}

.overall-report > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
}

.overall-report-track,
.line-report-track {
  overflow: hidden;
  background: var(--paper-soft);
  border-radius: 999px;
}

.overall-report-track {
  height: 12px;
}

.overall-report-fill {
  height: 100%;
  background: var(--stamp);
  border-radius: 999px;
}

.report-block {
  margin-top: 16px;
}

.report-block h3 {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 13px;
}

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

.line-report-row {
  display: grid;
  grid-template-columns: minmax(110px, 170px) 1fr 48px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.line-report-name {
  color: var(--ink-soft);
  font-weight: 800;
}

.line-report-track {
  height: 9px;
}

.line-report-fill {
  height: 100%;
  border-radius: 999px;
}

.report-weak {
  padding: 12px;
  background: #F4E7DD;
  border: 1px dashed var(--stamp);
  border-radius: var(--radius);
}

.report-note {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.report-weak-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.report-weak-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-soft);
  font-size: 13px;
}

.report-weak-list strong {
  color: var(--ink);
}

.report-footer {
  margin-top: 14px;
  color: var(--ink-soft);
  font-size: 13px;
}

.report-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
}

.toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  z-index: 10;
}

.toast {
  width: min(330px, calc(100vw - 32px));
  padding: 11px 13px;
  color: var(--paper);
  background: rgba(92, 79, 66, .94);
  border-left: 5px solid var(--stamp);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(92, 79, 66, .26);
}

.is-hidden {
  display: none !important;
}

@media (max-width: 760px) {
  body {
    padding: 0;
  }

  .app-shell {
    min-height: 100vh;
    border-radius: 0;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .player-card {
    width: 100%;
    text-align: left;
  }

  .screen-frame {
    padding: 15px;
  }

  .tabbar {
    overflow-x: auto;
    padding: 0 12px;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .station-list.world,
  .node-layout {
    grid-template-columns: 1fr;
  }

  .choice-grid.ox {
    grid-template-columns: 1fr;
  }

  .line-report-row {
    grid-template-columns: 1fr 1fr 42px;
  }

  .report-actions {
    flex-direction: column;
  }
}

@media print {
  body {
    padding: 0;
    background: #fff;
  }

  .app-shell {
    width: 100%;
    min-height: auto;
    border: 0;
    box-shadow: none;
  }

  .app-shell::before,
  .paper-grain,
  .app-header,
  .tabbar,
  .no-print {
    display: none !important;
  }

  .screen {
    display: none !important;
  }

  #screen-report {
    display: block !important;
  }

  .screen-frame {
    padding: 0;
  }

  .report-panel {
    max-width: none;
    border: 0;
    background: #fff;
  }
}
