:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #52616b;
  --paper: #f8f5ee;
  --panel: #fffaf0;
  --line: #5c3e21;
  --wood: #dca65d;
  --wood-dark: #b67830;
  --gold: #f3c54e;
  --gold-soft: rgba(243, 197, 78, 0.34);
  --silver: #9ab3c7;
  --silver-soft: rgba(154, 179, 199, 0.28);
  --green: #2d7d5a;
  --green-soft: rgba(45, 125, 90, 0.22);
  --red: #c95445;
  --blue: #2b668f;
  --blue-soft: rgba(43, 102, 143, 0.16);
  --violet: #6d5aa8;
  --shadow: 0 18px 38px rgba(28, 35, 39, 0.16);
  font-family: ui-rounded, "Hiragino Maru Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 250, 240, 0.92), rgba(235, 242, 244, 0.92)),
    repeating-linear-gradient(90deg, rgba(92, 62, 33, 0.05) 0 2px, transparent 2px 14px);
}

button {
  font: inherit;
}

.app {
  width: min(1220px, calc(100vw - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0 14px;
}

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

.brand-mark {
  flex: 0 0 auto;
  width: 68px;
  height: 68px;
  filter: drop-shadow(0 8px 14px rgba(28, 35, 39, 0.16));
}

.brand-mark rect {
  fill: #e2ad63;
  stroke: #664320;
  stroke-width: 4;
}

.brand-mark path {
  fill: none;
  stroke: #664320;
  stroke-width: 3;
  stroke-linecap: round;
}

.brand-mark .black-stone {
  fill: #12171a;
}

.brand-mark .white-stone {
  fill: #fffdf7;
  stroke: #25313a;
  stroke-width: 2;
}

.eyebrow,
.level-label {
  margin: 0;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.65rem, 4.8vw, 3.05rem);
  line-height: 1.02;
}

.score-strip {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.score-box {
  min-width: 78px;
  padding: 10px 12px;
  border: 2px solid rgba(23, 32, 38, 0.13);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.82);
  text-align: center;
}

.score-box strong {
  display: block;
  font-size: 1.34rem;
  line-height: 1;
}

.score-box span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.mode-tab {
  min-height: 44px;
  padding: 8px 10px;
  border: 2px solid rgba(23, 32, 38, 0.13);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.9);
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

.mode-tab.active {
  border-color: rgba(45, 125, 90, 0.38);
  background: #eaf6ee;
  color: #1d6042;
}

.mode-tab:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.lesson-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.lesson-step {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px;
  border: 2px solid rgba(23, 32, 38, 0.1);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
}

.lesson-step span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e6eced;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 900;
}

.lesson-step strong {
  font-size: 0.95rem;
}

.lesson-step.active {
  border-color: rgba(243, 197, 78, 0.65);
  background: #fff7dc;
}

.lesson-step.done span {
  background: var(--green);
  color: white;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 390px);
  align-items: start;
  gap: 18px;
}

.board-panel,
.play-panel {
  border: 2px solid rgba(23, 32, 38, 0.12);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.88);
  box-shadow: var(--shadow);
}

.board-panel {
  padding: clamp(10px, 2vw, 18px);
}

.board-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.board-status span {
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 999px;
  background: #fffdf8;
  color: #27333a;
  font-size: 0.88rem;
  font-weight: 900;
}

.board-frame {
  display: grid;
  place-items: center;
  width: 100%;
}

.board {
  --pad: 8.3%;
  position: relative;
  width: min(100%, 680px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 5px solid #6d4218;
  border-radius: 8px;
  background:
    radial-gradient(circle at 24% 17%, rgba(255, 255, 255, 0.28), transparent 26%),
    linear-gradient(135deg, #efc178, var(--wood) 48%, #c9893f);
  box-shadow: inset 0 0 0 2px rgba(255, 245, 210, 0.32);
  touch-action: manipulation;
}

.zone {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  opacity: 0.38;
  transition: opacity 180ms ease, box-shadow 180ms ease;
}

.zone.corner {
  width: 33.333%;
  height: 33.333%;
  background: var(--gold-soft);
}

.zone.side {
  background: var(--silver-soft);
}

.zone.nw,
.zone.n {
  top: 0;
}

.zone.ne {
  top: 0;
  right: 0;
}

.zone.w,
.zone.e {
  top: 33.333%;
  width: 33.333%;
  height: 33.333%;
}

.zone.sw {
  left: 0;
  bottom: 0;
}

.zone.s,
.zone.se {
  bottom: 0;
}

.zone.nw,
.zone.w,
.zone.sw {
  left: 0;
}

.zone.n,
.zone.s {
  left: 33.333%;
  width: 33.333%;
  height: 33.333%;
}

.zone.ne,
.zone.e,
.zone.se {
  right: 0;
}

.zone.board-focus {
  opacity: 0.92;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.68);
}

.grid-line {
  position: absolute;
  z-index: 1;
  background: rgba(64, 39, 17, 0.88);
  pointer-events: none;
}

.grid-line.vertical {
  top: var(--pad);
  bottom: var(--pad);
  width: 2px;
  transform: translateX(-1px);
}

.grid-line.horizontal {
  left: var(--pad);
  right: var(--pad);
  height: 2px;
  transform: translateY(-1px);
}

.star-point {
  position: absolute;
  z-index: 2;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(64, 39, 17, 0.86);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.point {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  width: clamp(31px, 5.2vw, 46px);
  height: clamp(31px, 5.2vw, 46px);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  transform: translate(-50%, -50%);
  cursor: pointer;
}

.point::before {
  content: "";
  width: 15px;
  height: 15px;
  border-radius: 50%;
  opacity: 0;
  background: rgba(45, 125, 90, 0.32);
  transform: scale(0.7);
  transition: opacity 120ms ease, transform 120ms ease;
}

.point:hover::before,
.point:focus-visible::before {
  opacity: 1;
  transform: scale(1);
}

.point:focus-visible {
  outline: 4px solid rgba(45, 125, 90, 0.42);
  outline-offset: 2px;
}

.stone-piece {
  position: absolute;
  inset: 5px;
  z-index: 2;
  border-radius: 50%;
  box-shadow:
    inset -5px -7px 9px rgba(0, 0, 0, 0.24),
    inset 5px 5px 7px rgba(255, 255, 255, 0.28),
    0 5px 10px rgba(18, 23, 26, 0.28);
}

.stone-piece.black {
  background:
    radial-gradient(circle at 34% 28%, #4d575f 0 8%, transparent 24%),
    linear-gradient(135deg, #232a2f, #06080a);
}

.stone-piece.white {
  background:
    radial-gradient(circle at 35% 28%, #ffffff 0 20%, transparent 40%),
    linear-gradient(135deg, #fffef8, #d8d4ca);
  box-shadow:
    inset -5px -7px 9px rgba(80, 86, 89, 0.18),
    inset 5px 5px 7px rgba(255, 255, 255, 0.86),
    0 5px 10px rgba(18, 23, 26, 0.24);
}

.hint-mark {
  position: absolute;
  inset: 8px;
  z-index: 1;
  display: grid;
  place-items: center;
  border: 3px solid rgba(23, 32, 38, 0.24);
  border-radius: 50%;
  background: rgba(255, 253, 248, 0.52);
  color: #1f2b31;
  font-size: 0.8rem;
  font-weight: 900;
  pointer-events: none;
}

.hint-mark.gold {
  border-color: #d5970e;
  background: rgba(243, 197, 78, 0.34);
}

.hint-mark.silver {
  border-color: #64869d;
  background: rgba(154, 179, 199, 0.34);
}

.hint-mark.green {
  border-color: var(--green);
  background: rgba(45, 125, 90, 0.28);
}

.hint-mark.blue {
  border-color: var(--blue);
  background: rgba(43, 102, 143, 0.23);
}

.hint-mark.red {
  border-color: var(--red);
  background: rgba(201, 84, 69, 0.22);
}

.point.wrong-ring::after,
.point.best-ring::after {
  content: "";
  position: absolute;
  inset: 2px;
  z-index: 4;
  border: 4px solid var(--red);
  border-radius: 50%;
  pointer-events: none;
}

.point.best-ring::after {
  border-color: var(--green);
}

.territory-readout {
  display: grid;
  grid-template-columns: 1fr 1fr 1.25fr;
  gap: 8px;
  margin-top: 10px;
}

.territory-readout div {
  min-height: 56px;
  padding: 9px 10px;
  border: 2px solid rgba(23, 32, 38, 0.1);
  border-radius: 8px;
  background: #fffdf8;
}

.territory-readout span,
.territory-readout strong {
  display: block;
}

.territory-readout span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.territory-readout strong {
  margin-top: 3px;
  font-size: 1rem;
}

.play-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.scenario h2 {
  margin-top: 4px;
  font-size: clamp(1.55rem, 4vw, 2.1rem);
  line-height: 1.1;
}

.prompt {
  min-height: 3.2em;
  margin: 10px 0 0;
  color: #27333a;
  font-size: 1.13rem;
  font-weight: 800;
  line-height: 1.45;
}

.concept-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.concept-badge,
.lesson-tag {
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 900;
}

.concept-badge {
  background: #fff2bf;
  color: #6a4710;
}

.lesson-tag {
  background: #e8f1f5;
  color: #244e68;
}

.difficulty-pips {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
}

.difficulty-pips i {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
}

.coach-note {
  min-height: 92px;
  padding: 12px;
  border: 2px solid rgba(43, 102, 143, 0.18);
  border-radius: 8px;
  background: #f4fafb;
}

.coach-note p {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 0.8rem;
  font-weight: 900;
}

.coach-note strong {
  display: block;
  color: #26343b;
  font-size: 1rem;
  line-height: 1.45;
}

.reason-choices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.reason-choice {
  min-height: 42px;
  padding: 8px 9px;
  border: 2px solid rgba(23, 32, 38, 0.12);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

.reason-choice.active {
  border-color: rgba(45, 125, 90, 0.38);
  background: #eaf6ee;
  color: #1d6042;
}

.priority-map {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.priority-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 8px 10px;
  border: 2px solid rgba(23, 32, 38, 0.1);
  border-radius: 8px;
  background: #fffdf8;
}

.priority-item strong {
  font-size: 1.05rem;
}

.priority-item span:last-child {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
}

.priority-medal {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #1f2b31;
  font-weight: 900;
}

.priority-item.gold .priority-medal {
  background: var(--gold);
}

.priority-item.silver .priority-medal {
  background: #cbd9e3;
}

.priority-item.green .priority-medal {
  background: #bfe2c8;
}

.priority-item.center .priority-medal {
  background: #d9d3ee;
}

.vision-meter {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 2px solid rgba(23, 32, 38, 0.1);
  border-radius: 8px;
  background: #fffdf8;
}

.meter-row {
  display: grid;
  grid-template-columns: 46px 1fr;
  align-items: center;
  gap: 8px;
}

.meter-row span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.meter-row div {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6eced;
}

.meter-row i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width 180ms ease;
}

.feedback {
  min-height: 108px;
  padding: 12px;
  border: 2px solid rgba(23, 32, 38, 0.1);
  border-radius: 8px;
  background: #fffdf8;
}

.feedback strong,
.feedback span {
  display: block;
}

.feedback strong {
  margin-bottom: 6px;
  font-size: 1.18rem;
}

.feedback span {
  color: #29353c;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.45;
}

.feedback.good {
  border-color: rgba(45, 125, 90, 0.35);
  background: #f2fbf4;
}

.feedback.ok {
  border-color: rgba(43, 102, 143, 0.34);
  background: #f3f8fb;
}

.feedback.bad {
  border-color: rgba(201, 84, 69, 0.34);
  background: #fff4f1;
}

.feedback.hint {
  border-color: rgba(243, 197, 78, 0.7);
  background: #fff8dd;
}

.feedback.think {
  border-color: rgba(109, 90, 168, 0.34);
  background: #f7f4ff;
}

.controls,
.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
}

.control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  gap: 7px;
  padding: 10px 12px;
  border: 2px solid rgba(23, 32, 38, 0.16);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.control-btn span {
  font-weight: 900;
}

.control-btn:hover:not(:disabled),
.control-btn:focus-visible:not(:disabled),
.mode-tab:hover:not(:disabled),
.mode-tab:focus-visible:not(:disabled),
.reason-choice:hover:not(:disabled),
.reason-choice:focus-visible:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(28, 35, 39, 0.12);
}

.control-btn:focus-visible,
.mode-tab:focus-visible,
.reason-choice:focus-visible {
  outline: 4px solid rgba(43, 102, 143, 0.24);
  outline-offset: 2px;
}

.control-btn:disabled,
.reason-choice:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.control-btn.primary {
  border-color: rgba(45, 125, 90, 0.3);
  background: var(--green);
  color: white;
}

.result-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 32, 38, 0.46);
}

.result-panel[hidden] {
  display: none;
}

.result-card {
  width: min(560px, 100%);
  padding: 22px;
  border: 2px solid rgba(23, 32, 38, 0.14);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: center;
}

.result-card h2 {
  margin-top: 4px;
  font-size: clamp(2rem, 9vw, 3.2rem);
}

.result-card p:not(.eyebrow) {
  margin: 12px auto;
  max-width: 39ch;
  color: #27333a;
  font-weight: 800;
  line-height: 1.5;
}

.big-stars {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  min-height: 42px;
  margin: 12px 0 14px;
  color: #d5970e;
  font-size: 1.55rem;
  line-height: 1;
}

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

.mastery-list div {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #fffdf8;
  font-size: 0.9rem;
  font-weight: 900;
}

.mastery-list span {
  color: var(--muted);
}

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

@media (max-width: 920px) {
  .app {
    width: min(100vw - 18px, 720px);
    padding-top: 10px;
  }

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

  .score-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }

  .score-box {
    min-width: 0;
  }

  .mode-tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow-x: auto;
  }

  .mode-tab {
    min-width: 82px;
  }

  .lesson-strip {
    grid-template-columns: repeat(5, minmax(80px, 1fr));
    overflow-x: auto;
  }

  .game-shell {
    grid-template-columns: 1fr;
  }

  .board-panel {
    order: 1;
  }

  .play-panel {
    order: 2;
  }

  .prompt {
    min-height: auto;
  }
}

@media (max-width: 560px) {
  .brand-mark {
    width: 54px;
    height: 54px;
  }

  .score-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .score-box {
    padding: 8px 6px;
  }

  .score-box strong {
    font-size: 1.18rem;
  }

  .territory-readout {
    grid-template-columns: 1fr;
  }

  .priority-item {
    grid-template-columns: 38px 1fr auto;
    gap: 7px;
  }

  .reason-choices,
  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .control-btn {
    min-height: 44px;
  }
}
