:root {
  color-scheme: light;
  --page: #f7f4eb;
  --ink: #22312f;
  --muted: #61716d;
  --panel: #fffdf7;
  --line: #ded7c8;
  --green: #2d7a6f;
  --green-dark: #215f56;
  --blue: #486fb8;
  --coral: #df7c59;
  --yellow: #f4c95d;
  --success: #2f7d4c;
  --danger: #bb4d45;
  --shadow: 0 16px 38px rgba(69, 58, 37, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(45, 122, 111, 0.14), transparent 38%),
    linear-gradient(315deg, rgba(223, 124, 89, 0.16), transparent 36%),
    var(--page);
  color: var(--ink);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Sans",
    "Yu Gothic",
    "Meiryo",
    sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.top-bar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green-dark);
  font-size: 0.95rem;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: 2.55rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.score-board {
  display: grid;
  grid-template-columns: repeat(2, 88px);
  gap: 8px;
}

.score-board div {
  min-height: 76px;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
  box-shadow: 0 8px 18px rgba(69, 58, 37, 0.08);
}

.score-board span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.score-board strong {
  display: block;
  color: var(--green-dark);
  font-size: 2rem;
  line-height: 1.15;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.mode-button {
  min-height: 64px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
  color: var(--ink);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 800;
}

.mode-button:focus-visible,
.mode-button:hover {
  outline: 3px solid rgba(72, 111, 184, 0.28);
  border-color: var(--blue);
}

.mode-button.is-active {
  border-color: var(--green);
  background: #e7f3ee;
  color: var(--green-dark);
  box-shadow: inset 0 -5px 0 rgba(45, 122, 111, 0.18);
}

.button-mark {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-right: 6px;
  border-radius: 6px;
  background: #ffffff;
  color: var(--coral);
}

.difficulty-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: -4px 0 16px;
}

.difficulty-button {
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 900;
}

.difficulty-button:focus-visible,
.difficulty-button:hover {
  outline: 3px solid rgba(72, 111, 184, 0.24);
  border-color: var(--blue);
}

.difficulty-button.is-active {
  border-color: var(--coral);
  background: #fff0e8;
  color: #8a3f27;
}

.practice-area {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(360px, 0.95fr);
  gap: 16px;
  align-items: stretch;
}

.visual-panel,
.question-panel {
  min-height: 520px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.visual-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 18px;
}

.round-badge {
  justify-self: start;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  min-height: 42px;
  padding: 7px 14px;
  border-radius: 8px;
  background: #f8e6b4;
  color: #735017;
  font-weight: 800;
}

.round-badge strong {
  font-size: 1.55rem;
  line-height: 1;
}

.visual-area {
  display: grid;
  place-items: center;
  min-height: 410px;
  padding: 16px;
}

.question-panel {
  display: flex;
  flex-direction: column;
  padding: 22px;
}

.mode-label {
  align-self: start;
  margin: 0 0 12px;
  padding: 7px 12px;
  border-radius: 8px;
  background: #eaf0fb;
  color: #264b89;
  font-weight: 800;
}

h2 {
  min-height: 78px;
  margin: 0 0 18px;
  font-size: 1.65rem;
  line-height: 1.45;
  letter-spacing: 0;
}

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

.choice-grid[data-count="2"],
.choice-grid[data-count="4"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-button {
  display: grid;
  place-items: center;
  min-height: 92px;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.22rem;
  font-weight: 800;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.choice-button:focus-visible,
.choice-button:hover {
  outline: 3px solid rgba(72, 111, 184, 0.25);
  transform: translateY(-2px);
  border-color: var(--blue);
}

.choice-button.is-correct {
  border-color: var(--success);
  background: #e5f4ea;
  color: #1e5d38;
}

.choice-button.is-wrong {
  border-color: var(--danger);
  background: #fdebe8;
  color: #8f332d;
}

.choice-button:disabled {
  cursor: default;
}

.feedback {
  min-height: 62px;
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f3efe4;
  color: var(--muted);
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.45;
}

.feedback.is-correct {
  background: #e4f3e9;
  color: #245b3c;
}

.feedback.is-wrong {
  background: #fdebe8;
  color: #87332d;
}

.action-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 10px;
  margin-top: auto;
  padding-top: 18px;
}

.action-button {
  min-height: 60px;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.08rem;
  font-weight: 900;
}

.action-button:focus-visible,
.action-button:hover {
  outline: 3px solid rgba(72, 111, 184, 0.28);
}

.action-button.primary {
  background: var(--green);
  color: #ffffff;
}

.action-button.primary:disabled {
  background: #aebdb8;
  cursor: default;
}

.action-button.ghost {
  border-color: var(--line);
  background: #ffffff;
  color: var(--green-dark);
}

.die-face {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 92px;
  height: 92px;
  padding: 12px;
  border: 3px solid #24312e;
  border-radius: 8px;
  background: #fffefa;
  box-shadow: inset 0 -6px 0 rgba(36, 49, 46, 0.1);
}

.visual-area > .die-face {
  width: 220px;
  height: 220px;
  padding: 26px;
  border-width: 5px;
}

.dot {
  align-self: center;
  justify-self: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #24312e;
}

.visual-area > .die-face .dot {
  width: 34px;
  height: 34px;
}

.pos-1 {
  grid-column: 1;
  grid-row: 1;
}

.pos-2 {
  grid-column: 2;
  grid-row: 1;
}

.pos-3 {
  grid-column: 3;
  grid-row: 1;
}

.pos-4 {
  grid-column: 1;
  grid-row: 2;
}

.pos-5 {
  grid-column: 2;
  grid-row: 2;
}

.pos-6 {
  grid-column: 3;
  grid-row: 2;
}

.pos-7 {
  grid-column: 1;
  grid-row: 3;
}

.pos-8 {
  grid-column: 2;
  grid-row: 3;
}

.pos-9 {
  grid-column: 3;
  grid-row: 3;
}

.cube-wrap {
  width: 286px;
  height: 250px;
  position: relative;
}

.cube-face {
  position: absolute;
  display: grid;
  place-items: center;
  border: 3px solid #263934;
  border-radius: 8px;
  background: #fffefa;
  box-shadow: inset 0 -5px 0 rgba(36, 49, 46, 0.1);
}

.cube-face.top {
  left: 80px;
  top: 0;
  width: 126px;
  height: 82px;
  transform: skewX(-24deg);
  background: #fff4cf;
}

.cube-face.front {
  left: 72px;
  top: 82px;
  width: 130px;
  height: 130px;
  background: #ffffff;
}

.cube-face.right {
  left: 202px;
  top: 59px;
  width: 78px;
  height: 132px;
  transform: skewY(-24deg);
  background: #eaf0fb;
}

.cube-face .die-face {
  width: 60px;
  height: 60px;
  padding: 8px;
  border-width: 2px;
  transform: none;
  box-shadow: none;
}

.cube-face .dot {
  width: 10px;
  height: 10px;
}

.cube-label {
  position: absolute;
  display: inline-grid;
  place-items: center;
  min-width: 56px;
  min-height: 34px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--green-dark);
  font-size: 0.92rem;
  font-weight: 900;
  box-shadow: 0 5px 12px rgba(69, 58, 37, 0.12);
}

.cube-label.top-label {
  left: 104px;
  top: -18px;
}

.cube-label.front-label {
  left: 28px;
  top: 130px;
}

.cube-label.right-label {
  right: -2px;
  top: 108px;
}

.net-svg {
  width: min(100%, 430px);
  height: auto;
}

.net-shape {
  fill: #fffefa;
  stroke: #263934;
  stroke-width: 4;
  stroke-linejoin: round;
}

.net-shape.accent {
  fill: #fff2bd;
}

.net-shape.blue {
  fill: #e7edf9;
}

.shape-choice {
  min-height: 112px;
  gap: 8px;
}

.swatch-choice {
  min-height: 112px;
  gap: 8px;
}

.block-choice,
.view-choice {
  min-height: 132px;
  gap: 8px;
}

.number-choice {
  min-height: 112px;
  color: var(--green-dark);
  font-size: 2.2rem;
}

.shape-icon {
  display: block;
  width: 76px;
  height: 54px;
}

.shape-icon svg {
  width: 100%;
  height: 100%;
}

.shape-label {
  display: block;
}

.block-visual {
  display: grid;
  gap: 8px;
  place-items: center;
  width: min(100%, 430px);
}

.block-visual-label {
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  padding: 5px 12px;
  border-radius: 8px;
  background: #fff0e8;
  color: #8a3f27;
  font-weight: 900;
}

.block-svg {
  width: min(100%, 430px);
  height: auto;
}

.block-svg.is-small {
  width: min(100%, 154px);
}

.iso-face {
  stroke: #263934;
  stroke-width: 3;
  stroke-linejoin: round;
}

.projection-svg {
  width: 110px;
  height: 92px;
}

.projection-cell {
  fill: #fff2bd;
  stroke: #263934;
  stroke-width: 3;
  rx: 6;
}

.projection-cell.is-soft {
  fill: #e7edf9;
}

.build-prompt {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: min(100%, 430px);
}

.prompt-card {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 170px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.prompt-card span {
  color: var(--green-dark);
  font-weight: 900;
}

.choice-swatch {
  display: grid;
  place-items: center;
  width: 74px;
  height: 54px;
  border: 3px solid #263934;
  border-radius: 8px;
  box-shadow: inset 0 -5px 0 rgba(36, 49, 46, 0.1);
}

.choice-swatch-mark {
  color: #263934;
  font-size: 1.45rem;
  font-weight: 900;
}

.pattern-net-face {
  stroke: #263934;
  stroke-width: 4;
  stroke-linejoin: round;
}

.pattern-net-face.is-target {
  stroke: var(--coral);
  stroke-width: 8;
}

.net-face-mark {
  fill: #263934;
  font-size: 23px;
  font-weight: 900;
  text-anchor: middle;
  dominant-baseline: middle;
}

.net-face-name {
  fill: #263934;
  font-size: 10px;
  font-weight: 900;
  text-anchor: middle;
}

@media (max-width: 860px) {
  .top-bar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .practice-area {
    grid-template-columns: 1fr;
  }

  .visual-panel,
  .question-panel {
    min-height: auto;
  }

  .visual-area {
    min-height: 330px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 18px;
  }

  h1 {
    font-size: 2rem;
  }

  .mode-tabs,
  .difficulty-tabs,
  .choice-grid,
  .action-row,
  .build-prompt {
    grid-template-columns: 1fr;
  }

  .mode-button,
  .difficulty-button,
  .choice-button,
  .action-button {
    min-height: 58px;
  }

  h2 {
    min-height: auto;
    font-size: 1.35rem;
  }

  .visual-area > .die-face {
    width: 178px;
    height: 178px;
  }

  .cube-wrap {
    width: 242px;
    height: 218px;
  }

  .cube-face.top {
    left: 64px;
    width: 108px;
    height: 72px;
  }

  .cube-face.front {
    left: 60px;
    top: 72px;
    width: 112px;
    height: 112px;
  }

  .cube-face.right {
    left: 172px;
    top: 52px;
    width: 64px;
    height: 112px;
  }

  .cube-label.front-label {
    left: 12px;
    top: 118px;
  }

  .cube-label.right-label {
    right: -6px;
    top: 96px;
  }
}

/* LiNest v3: 問題の立体・配色・正誤表示は保ち、外枠のみ統一する。 */
@media screen {
  body.linest-themed .app-shell {
    min-width: 0;
    padding-block: 28px 36px;
  }

  body.linest-themed .top-bar {
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--linest-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--linest-shadow);
  }

  body.linest-themed .score-board div,
  body.linest-themed :where(.visual-panel, .question-panel) {
    border-color: var(--linest-border);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--linest-shadow);
  }

  body.linest-themed :where(.mode-button, .difficulty-button, .action-button.ghost) {
    min-width: 0;
    border-color: var(--linest-border);
    background: #ffffff;
    color: var(--linest-heading);
  }

  body.linest-themed .mode-button.is-active {
    border-color: var(--linest-green);
    background: var(--linest-green-soft);
    color: var(--linest-green-dark);
    box-shadow: inset 0 -4px 0 rgba(47, 158, 68, 0.16);
  }

  body.linest-themed .difficulty-button.is-active {
    border-color: var(--linest-terracotta);
    background: #fbf0e9;
    color: var(--linest-terracotta-dark);
  }

  body.linest-themed .round-badge {
    background: #f6f1e8;
    color: var(--linest-heading);
  }

  body.linest-themed :where(.top-bar, .mode-tabs, .difficulty-tabs, .practice-area, .choice-grid, .action-row) > * {
    min-width: 0;
  }
}

@media screen and (max-width: 620px) {
  body.linest-themed .app-shell {
    width: min(100% - 20px, 1120px);
  }

  body.linest-themed .top-bar {
    padding: 14px;
  }

  body.linest-themed :where(.mode-button, .difficulty-button, .choice-button, .action-button) {
    padding-inline: 10px;
    white-space: normal;
  }
}
