:root {
  --bg: #f4efe5;
  --paper: rgba(255, 252, 246, 0.92);
  --paper-strong: #fffdfa;
  --ink: #1f2a24;
  --muted: #617068;
  --table: #155b47;
  --table-2: #1f7a61;
  --line: rgba(31, 42, 36, 0.12);
  --accent: #c58a2e;
  --accent-deep: #8c5b11;
  --good: #1f8b5e;
  --bad: #b84e44;
  --shadow: 0 18px 48px rgba(39, 34, 24, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(197, 138, 46, 0.16), transparent 26%),
    radial-gradient(circle at top right, rgba(31, 122, 97, 0.12), transparent 28%),
    linear-gradient(180deg, #f8f3eb, #efe6d8);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Times New Roman", serif;
}

body {
  padding: 24px;
}

button,
select {
  font: inherit;
}

.app-shell {
  max-width: 1360px;
  margin: 0 auto;
  display: grid;
  gap: 20px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hero {
  display: grid;
  grid-template-columns: 1fr;
  padding: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.hero h1,
.quiz-panel h2,
.sidebar h2 {
  margin: 0 0 12px;
  line-height: 1.1;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 3.5rem);
}

.lede,
.question-text,
.hero-note,
#reasonText,
#takeawayText,
#resultLead,
#focusText {
  line-height: 1.75;
  color: var(--muted);
}

.hero-controls {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 12px;
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(21, 91, 71, 0.08), rgba(197, 138, 46, 0.08)),
    var(--paper-strong);
  border: 1px solid rgba(31, 42, 36, 0.08);
}

.hero-controls-inline {
  margin-top: 18px;
}

.field,
.explanation-block,
.focus-box,
.stat-card {
  display: grid;
  gap: 8px;
}

.field span,
.label {
  font-size: 0.86rem;
  color: var(--muted);
}

select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(31, 42, 36, 0.14);
  background: #fffdf8;
  color: var(--ink);
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  cursor: pointer;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    opacity 140ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.primary {
  color: #fffdf8;
  background: linear-gradient(135deg, var(--table), var(--table-2));
  box-shadow: 0 14px 26px rgba(21, 91, 71, 0.18);
}

.ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(31, 42, 36, 0.12);
}

.hero-controls h2 {
  margin-bottom: 4px;
  font-size: 1.15rem;
}

.hero-controls .eyebrow {
  margin-bottom: 4px;
  font-size: 0.68rem;
}

.hero-controls .field span {
  font-size: 0.8rem;
}

.hero-controls select {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.88rem;
}

.hero-controls button {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.88rem;
}

.hero-controls .hero-note {
  font-size: 0.8rem;
  line-height: 1.55;
}

.quiz-panel,
.explanation-panel,
.laws-panel,
.summary-panel,
.game-strip {
  padding: 24px;
}

.game-strip {
  display: grid;
  gap: 14px;
}

.game-strip-head,
.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.progress-copy {
  color: var(--muted);
  font-size: 0.95rem;
}

.progress-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(31, 42, 36, 0.08);
  overflow: hidden;
}

.progress-fill {
  width: 10%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--table-2));
  transition: width 180ms ease;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 18px 20px;
}

.stat-card strong {
  font-size: 1.9rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.88fr);
  gap: 20px;
  align-items: start;
}

.main-column {
  display: grid;
  gap: 20px;
}

.quiz-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.status-badge {
  flex: 0 0 auto;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid rgba(31, 42, 36, 0.12);
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.status-badge[data-tone="good"] {
  color: var(--good);
  border-color: rgba(31, 139, 94, 0.35);
  background: rgba(31, 139, 94, 0.12);
}

.status-badge[data-tone="bad"] {
  color: var(--bad);
  border-color: rgba(184, 78, 68, 0.35);
  background: rgba(184, 78, 68, 0.12);
}

.result-hero {
  margin: 2px 0 12px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 2px solid rgba(31, 42, 36, 0.12);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(248, 243, 235, 0.92));
  color: var(--ink);
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-align: center;
  line-height: 1.1;
}

.result-hero[data-tone="good"] {
  color: #ffffff;
  background: linear-gradient(135deg, #1f8b5e, #34b57a);
  border-color: rgba(31, 139, 94, 0.48);
  box-shadow: 0 12px 24px rgba(31, 139, 94, 0.18);
}

.result-hero[data-tone="bad"] {
  color: #ffffff;
  background: linear-gradient(135deg, #b84e44, #d9685d);
  border-color: rgba(184, 78, 68, 0.48);
  box-shadow: 0 12px 24px rgba(184, 78, 68, 0.18);
}

.result-hero[data-tone="neutral"] {
  color: var(--ink);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(241, 236, 228, 0.95));
}

.focus-box {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(197, 138, 46, 0.08), rgba(31, 122, 97, 0.08));
  border: 1px solid rgba(31, 42, 36, 0.08);
}

.focus-box p,
.explanation-block p {
  margin: 0;
}

.hand-area,
.choices-area {
  margin-top: 22px;
}

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

.tiny-note {
  font-size: 0.8rem;
  color: var(--muted);
}

.hand {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 8px;
}

.tile {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 92px;
  padding: 7px 4px 8px;
  border-radius: 14px;
  border: 1px solid #d8ccb4;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(249, 241, 223, 0.96) 72%, rgba(235, 223, 197, 0.98) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    inset -1px -2px 0 rgba(202, 185, 152, 0.36),
    0 2px 0 rgba(175, 155, 124, 0.65),
    0 10px 18px rgba(56, 48, 28, 0.14);
  display: grid;
  align-content: space-between;
  justify-items: center;
  color: var(--ink);
}

.tile::before {
  content: "";
  position: absolute;
  inset: 4px 5px 6px;
  border-radius: 10px;
  border: 1px solid rgba(221, 208, 182, 0.95);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 251, 242, 0.2));
  pointer-events: none;
}

.tile::after {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 5px;
  height: 8px;
  border-radius: 0 0 9px 9px;
  background: linear-gradient(180deg, rgba(206, 189, 158, 0.16), rgba(184, 164, 128, 0.38));
  pointer-events: none;
}

.tile > * {
  position: relative;
  z-index: 1;
}

.tile-top,
.tile-bottom {
  font-size: 0.68rem;
  line-height: 1.1;
}

.tile-top {
  color: var(--muted);
}

.tile-bottom {
  font-weight: 700;
}

.tile-main {
  font-size: 1.5rem;
  line-height: 1;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 46px;
}

.tile-sprite {
  min-height: 96px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  align-content: center;
}

.tile-sprite-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 96px;
  display: grid;
  place-items: center;
}

.tile-sprite-face {
  width: min(100%, 64px);
  aspect-ratio: 64 / 96;
  border-radius: 8px;
  background-image: var(--sprite-url);
  background-repeat: no-repeat;
  background-position:
    calc(var(--sprite-x) * -1px)
    calc(var(--sprite-y) * -1px);
  background-size:
    calc(var(--sheet-w) * 1px)
    calc(var(--sheet-h) * 1px);
  filter: drop-shadow(0 3px 4px rgba(61, 48, 20, 0.2));
}

.tile-sprite .tile-top,
.tile-sprite .tile-bottom {
  display: none;
}

.tile-sprite-only::before,
.tile-sprite-only::after {
  display: none;
}

.tile-sprite.is-candidate:hover {
  transform: translateY(-2px);
  box-shadow: none;
}

.tile-code {
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.face-man,
.face-pin,
.face-sou,
.face-honor {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.face-man {
  gap: 2px;
}

.face-man.red .face-number-kanji,
.face-man.red .face-suit-kanji {
  color: #c53030;
}

.face-number-kanji {
  font-size: 1.18rem;
  line-height: 1;
}

.face-suit-kanji {
  font-size: 1rem;
  line-height: 1;
}

.face-honor {
  font-size: 1.6rem;
  line-height: 1;
}

.face-pin {
  gap: 2px;
}

.pin-row,
.sou-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 3px;
  line-height: 1;
}

.pin-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  background: radial-gradient(circle at 35% 35%, #b9dcff 0%, #3c78c7 45%, #204d8f 100%);
  border: 1px solid rgba(18, 64, 126, 0.2);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.5);
}

.pin-dot.small {
  width: 8px;
  height: 8px;
}

.pin-dot.red {
  background: radial-gradient(circle at 35% 35%, #ffc3c3 0%, #d64b4b 45%, #9e2323 100%);
  border-color: rgba(123, 20, 20, 0.25);
}

.face-sou {
  color: #1f7a45;
}

.face-sou.red {
  color: #c53030;
}

.sou-row {
  font-size: 0.78rem;
  letter-spacing: 0;
}

.sou-glyph {
  display: inline-block;
  color: inherit;
}

.sou-glyph.red {
  color: #c53030;
}

.tile-man .tile-main,
.tile-man .tile-bottom {
  color: #2d6a4f;
}

.tile-red .tile-bottom {
  color: #c53030;
}

.tile-pin .tile-main,
.tile-pin .tile-bottom {
  color: #1f5ea8;
}

.tile-sou .tile-main,
.tile-sou .tile-bottom {
  color: #166534;
}

.tile-honor-wind .tile-main,
.tile-honor-wind .tile-bottom {
  color: #374151;
}

.tile-honor-dragon .tile-main,
.tile-honor-dragon .tile-bottom {
  color: #6b7280;
}

.tile-honor-dragon-green .tile-main,
.tile-honor-dragon-green .tile-bottom {
  color: #0f8a51;
}

.tile-honor-dragon-red .tile-main,
.tile-honor-dragon-red .tile-bottom {
  color: #c53030;
}

.tile.is-candidate {
  cursor: pointer;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    border-color 140ms ease;
}

.tile.is-candidate:hover {
  transform: translateY(-3px);
  border-color: rgba(197, 138, 46, 0.8);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    inset -1px -2px 0 rgba(202, 185, 152, 0.36),
    0 3px 0 rgba(175, 155, 124, 0.6),
    0 14px 22px rgba(56, 48, 28, 0.18);
}

.tile.is-disabled {
  opacity: 0.58;
}

.tile.is-correct {
  border-color: rgba(31, 139, 94, 0.92);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 0 0 4px rgba(31, 139, 94, 0.16);
}

.tile.is-wrong {
  border-color: rgba(184, 78, 68, 0.92);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 0 0 4px rgba(184, 78, 68, 0.16);
}

.tile-sprite.is-correct,
.tile-sprite.is-wrong {
  box-shadow: none;
}

.tile-sprite.is-correct .tile-sprite-face {
  box-shadow: 0 0 0 4px rgba(31, 139, 94, 0.22);
}

.tile-sprite.is-wrong .tile-sprite-face {
  box-shadow: 0 0 0 4px rgba(184, 78, 68, 0.22);
}

.choices {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.choice-btn {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(31, 42, 36, 0.12);
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
}

.choice-btn:hover {
  border-color: rgba(197, 138, 46, 0.8);
}

.choice-btn.is-answer {
  background: rgba(31, 139, 94, 0.12);
  border-color: rgba(31, 139, 94, 0.55);
}

.choice-btn.is-miss {
  background: rgba(184, 78, 68, 0.12);
  border-color: rgba(184, 78, 68, 0.55);
}

.sidebar {
  display: grid;
  gap: 20px;
  position: sticky;
  top: 24px;
  align-self: start;
}

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

.summary-box {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(31, 42, 36, 0.08);
}

.summary-box strong {
  font-size: 1.4rem;
}

.play-hint {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(21, 91, 71, 0.08), rgba(197, 138, 46, 0.08));
  border: 1px solid rgba(31, 42, 36, 0.08);
}

.play-hint p {
  margin: 0;
  color: var(--muted);
}

.play-hint-badge {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  color: #fffdf8;
  background: linear-gradient(135deg, var(--table), var(--table-2));
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.result-lead {
  margin-top: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(31, 42, 36, 0.08);
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.55;
}

.explanation-panel[data-tone="good"] .result-lead {
  color: var(--good);
  background: rgba(31, 139, 94, 0.12);
  border-color: rgba(31, 139, 94, 0.24);
}

.explanation-panel[data-tone="bad"] .result-lead {
  color: var(--bad);
  background: rgba(184, 78, 68, 0.12);
  border-color: rgba(184, 78, 68, 0.24);
}

.explanation-panel[data-tone="neutral"] .result-lead {
  color: var(--ink);
}

.law-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.law-list li {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(31, 42, 36, 0.08);
}

.law-list strong,
.explanation-block strong {
  color: var(--ink);
}

.laws-panel {
  padding: 18px 18px 16px;
}

.laws-panel h2 {
  margin-bottom: 8px;
  font-size: 1.2rem;
}

.laws-panel .eyebrow {
  margin-bottom: 6px;
  font-size: 0.7rem;
}

.law-list li strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.92rem;
}

.law-list li span {
  display: block;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .hero,
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .hand {
    grid-template-columns: repeat(14, 44px);
    overflow-x: auto;
    padding-bottom: 6px;
  }
}

@media (max-width: 640px) {
  body {
    padding: 14px;
  }

  .hero,
  .quiz-panel,
  .explanation-panel,
  .laws-panel {
    padding: 18px;
  }

  .game-strip-head,
  .progress-copy,
  .quiz-head,
  .label-row,
  .play-hint {
    flex-direction: column;
    align-items: start;
  }

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

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

  .hand {
    gap: 6px;
    grid-template-columns: repeat(14, 40px);
  }

  .tile {
    min-height: 76px;
    padding: 6px 3px;
  }

  .tile-top,
  .tile-bottom {
    font-size: 0.62rem;
  }

  .tile-main {
    font-size: 1.18rem;
    min-height: 40px;
  }

  .tile-sprite-wrap {
    min-height: 76px;
  }

  .tile-sprite-face {
    width: min(100%, 40px);
  }

  .face-honor {
    font-size: 1.35rem;
  }

  .face-number-kanji {
    font-size: 1rem;
  }

  .face-suit-kanji {
    font-size: 0.82rem;
  }

  .pin-dot {
    width: 8px;
    height: 8px;
  }

  .pin-dot.small {
    width: 6px;
    height: 6px;
  }

  .sou-row {
    font-size: 0.62rem;
  }
}
