:root {
  color-scheme: light;
  --ink: #344238;
  --muted: #718071;
  --cream: #fffaf0;
  --paper: rgba(255, 253, 245, 0.92);
  --green: #6fa65a;
  --green-dark: #477c43;
  --green-soft: #dceec5;
  --blue: #5f9fbd;
  --coral: #eb8068;
  --gold: #f4be45;
  --wood: #d8a966;
  --shadow: 0 12px 28px rgba(64, 83, 55, 0.16);
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html {
  min-height: 100%;
  background: #e9f2cf;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 280px;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 15%, rgba(255, 255, 255, 0.8) 0 4%, transparent 4.2%),
    radial-gradient(circle at 92% 22%, rgba(255, 255, 255, 0.55) 0 7%, transparent 7.2%),
    linear-gradient(155deg, #e9f4c7 0%, #d4e8bd 48%, #bcd9ae 100%);
  overscroll-behavior: none;
}

button {
  font: inherit;
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 4px solid rgba(54, 119, 177, 0.42);
  outline-offset: 2px;
}

img {
  -webkit-user-drag: none;
  user-select: none;
}

[hidden] {
  display: none !important;
}

.forest {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.forest::before,
.forest::after {
  position: absolute;
  bottom: -12vmax;
  width: 44vmax;
  height: 44vmax;
  border-radius: 50%;
  background: rgba(73, 128, 70, 0.12);
  content: "";
}

.forest::before {
  left: -22vmax;
}

.forest::after {
  right: -21vmax;
}

.leaf {
  position: absolute;
  color: rgba(78, 135, 65, 0.14);
  font-size: clamp(70px, 12vw, 150px);
  transform: scaleX(0.58) rotate(34deg);
}

.leaf-a { left: -3vw; top: 11%; }
.leaf-b { right: -2vw; top: 36%; transform: scaleX(0.55) rotate(-30deg); }
.leaf-c { left: 7vw; bottom: 5%; transform: scaleX(0.48) rotate(60deg); }
.leaf-d { right: 9vw; top: -6%; transform: scaleX(0.42) rotate(16deg); }

.app {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  margin-bottom: 7px;
}

.brand,
.player-name-row,
.top-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 7px;
}

.brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.eyebrow,
.modal-kicker {
  margin: 0;
  color: var(--green-dark);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1 {
  margin: -1px 0 0;
  color: #365f3b;
  font-size: clamp(20px, 5.5vw, 28px);
  line-height: 1;
  letter-spacing: 0.02em;
  user-select: none;
  touch-action: manipulation;
}

.top-actions {
  gap: 7px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(88, 113, 77, 0.12);
  border-radius: 50%;
  color: var(--green-dark);
  background: rgba(255, 253, 245, 0.84);
  box-shadow: 0 5px 13px rgba(78, 106, 68, 0.12);
  font-size: 21px;
  font-weight: 900;
}

.icon-button[aria-pressed="false"] {
  color: #9a9f99;
  background: rgba(243, 243, 236, 0.84);
}

.game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.player-card {
  display: flex;
  width: min(100%, 430px);
  min-height: 94px;
  padding: 9px 11px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 2px solid transparent;
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 5px 18px rgba(68, 91, 58, 0.1);
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.player-card.active {
  border-color: var(--gold);
  box-shadow: 0 7px 20px rgba(131, 98, 31, 0.18);
  transform: scale(1.015);
}

.player-card.active .player-name-row strong {
  animation: activePlayerBlink 1.9s ease-in-out infinite;
  color: #c07612;
}

@keyframes activePlayerBlink {
  0%, 100% {
    opacity: 1;
  }

  50% {
    opacity: 0.38;
  }
}

.player-name-row {
  min-width: 110px;
  gap: 7px;
}

.player-name-row strong {
  display: block;
  max-width: 126px;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 1px 5px rgba(39, 52, 42, 0.2);
}

.player-dot.blue { background: var(--blue); }
.player-dot.coral { background: var(--coral); }

.hand {
  display: flex;
  min-width: 160px;
  min-height: 80px;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: wrap;
}

.hand:empty::after {
  content: "もちごま なし";
  color: #a0aa9e;
  font-size: 11px;
  font-weight: 700;
}

.hand-piece {
  position: relative;
  width: 80px;
  height: 80px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: url("assets/images/piece.webp") center / contain no-repeat;
  filter: drop-shadow(0 2px 2px rgba(77, 62, 35, 0.2));
  touch-action: none;
}

.hand-piece img {
  position: absolute;
  inset: 2%;
  width: 96%;
  height: 96%;
  object-fit: contain;
}

.hand-piece-count {
  position: absolute;
  right: -2px;
  bottom: -2px;
  z-index: 2;
  min-width: 30px;
  height: 24px;
  padding: 2px 7px;
  border: 2px solid white;
  border-radius: 999px;
  color: white;
  background: var(--green-dark);
  box-shadow: 0 3px 8px rgba(47, 64, 38, 0.22);
  font-size: 13px;
  font-weight: 900;
  line-height: 16px;
}

.hand-piece.player-1 .hand-piece-count {
  transform: rotate(180deg);
}

.hand-piece.player-1 {
  transform: rotate(180deg);
}

.hand-piece.selected {
  border: 3px solid var(--gold);
  background-color: #fff5c7;
  transform: translateY(-3px);
}

.hand-piece.player-1.selected {
  transform: rotate(180deg) translateY(3px);
}

.hand-piece.drag-source,
.cell.drag-source .piece-token {
  opacity: 0.16;
}

.drag-piece-avatar {
  --drag-piece-size: 100px;
  --drag-x: 0px;
  --drag-y: 0px;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  width: var(--drag-piece-size);
  height: var(--drag-piece-size);
  pointer-events: none;
  transform: translate3d(var(--drag-x), var(--drag-y), 0) translate(-50%, -78%) scale(1.04);
  transform-origin: center;
  filter: drop-shadow(0 12px 10px rgba(58, 45, 25, 0.3));
  will-change: transform;
}

.drag-piece-avatar .piece-token {
  width: 100%;
  height: 100%;
  filter: none;
  transition: none;
}

.turn-banner {
  display: flex;
  min-width: 178px;
  min-height: 31px;
  margin: 5px 0;
  padding: 5px 14px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  color: white;
  background: var(--green-dark);
  box-shadow: 0 4px 12px rgba(59, 102, 57, 0.2);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.turn-banner.player-1 {
  background: #be654f;
}

.turn-banner.thinking .turn-paw {
  animation: thinking 700ms ease-in-out infinite alternate;
}

.turn-banner.status-placeholder {
  visibility: hidden;
}

.turn-paw {
  color: var(--gold);
  font-size: 9px;
  box-shadow: 7px -5px 0 -2px currentColor, -7px -5px 0 -2px currentColor;
}

.thinking-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 5;
  min-width: min(78%, 220px);
  padding: 13px 18px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 18px;
  color: #365138;
  background: rgba(255, 253, 245, 0.72);
  box-shadow: 0 10px 22px rgba(48, 65, 42, 0.16);
  font-size: 15px;
  font-weight: 900;
  text-align: center;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(3px);
  pointer-events: none;
}

.board-wrap {
  position: relative;
  width: clamp(210px, min(82vw, 380px, calc((100dvh - 372px) * 0.75)), 380px);
}

.board {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 3 / 4;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  overflow: hidden;
  border: 8px solid #a6723b;
  border-radius: 24px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.16), rgba(143, 83, 27, 0.06)),
    repeating-linear-gradient(7deg, #efcc91 0 16px, #ecc486 16px 17px, #f0cc90 17px 34px);
  box-shadow:
    inset 0 0 0 3px rgba(255, 248, 215, 0.66),
    inset 0 -7px 15px rgba(112, 70, 26, 0.12),
    0 11px 0 #855a31,
    0 18px 28px rgba(68, 75, 49, 0.2);
  touch-action: none;
}

.cell {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 1px;
  place-items: center;
  border: 0;
  border-right: 2px solid rgba(132, 82, 35, 0.43);
  border-bottom: 2px solid rgba(132, 82, 35, 0.43);
  background: transparent;
}

.cell:nth-child(3n) { border-right: 0; }
.cell:nth-last-child(-n + 3) { border-bottom: 0; }

.cell::after {
  position: absolute;
  z-index: 3;
  width: 20%;
  aspect-ratio: 1;
  border: 4px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 2px 7px rgba(46, 87, 48, 0.38);
  content: "";
  opacity: 0;
  transform: scale(0.35);
  transition: opacity 120ms ease, transform 120ms ease;
}

.cell.legal::after {
  opacity: 1;
  transform: scale(1);
}

.cell.legal.capture::after {
  width: 70%;
  border: 5px solid rgba(235, 99, 76, 0.74);
  background: transparent;
}

.cell.last-move {
  background: rgba(255, 245, 121, 0.28);
}

.cell.demo-piece-hidden .piece-token,
.hand-piece.demo-piece-hidden {
  opacity: 0;
}

.cell.quiz-choice {
  cursor: pointer;
}

.cell.quiz-selected {
  background: rgba(111, 166, 90, 0.3);
  box-shadow: inset 0 0 0 6px rgba(63, 142, 73, 0.72);
}

.cell.quiz-selected::after {
  display: grid;
  width: clamp(28px, 38%, 42px);
  height: clamp(28px, 38%, 42px);
  aspect-ratio: auto;
  border: 3px solid rgba(255, 255, 255, 0.92);
  color: white;
  background: var(--green-dark);
  content: "";
  opacity: 1;
  place-items: center;
  transform: scale(1);
}

.cell.quiz-selected::before {
  position: absolute;
  z-index: 4;
  width: clamp(9px, 13%, 15px);
  height: clamp(16px, 22%, 24px);
  border-right: 4px solid white;
  border-bottom: 4px solid white;
  content: "";
  transform: translateY(-2px) rotate(42deg);
}

.piece-token {
  --piece-rotation: 0deg;
  position: relative;
  z-index: 1;
  width: 92%;
  aspect-ratio: 1;
  border-radius: 19%;
  background: url("assets/images/piece.webp") center / contain no-repeat;
  filter: drop-shadow(0 4px 3px rgba(82, 57, 28, 0.24));
  transform: rotate(var(--piece-rotation));
  transition: transform 140ms ease, filter 140ms ease;
  pointer-events: none;
}

.piece-token.owner-1 {
  --piece-rotation: 180deg;
}

.demo-moving-piece {
  position: fixed;
  z-index: 6;
  aspect-ratio: 1;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(var(--piece-rotation));
  transition: transform 1050ms cubic-bezier(0.2, 0.72, 0.16, 1);
  will-change: transform;
}

.piece-token img,
.piece-token .fallback-animal {
  position: absolute;
  inset: 1%;
  display: grid;
  width: 98%;
  height: 98%;
  place-items: center;
  object-fit: contain;
}

.piece-token .fallback-animal {
  font-size: clamp(30px, 10vw, 55px);
}

.cell.selected .piece-token {
  filter: drop-shadow(0 0 7px #fff9a7) drop-shadow(0 5px 3px rgba(82, 57, 28, 0.24));
  transform: rotate(var(--piece-rotation)) translateY(-2px) scale(1.035);
}

.cell.drag-hover {
  background: rgba(255, 250, 171, 0.48);
  box-shadow: inset 0 0 0 6px rgba(80, 147, 76, 0.82);
}

.cell.drag-hover.capture-target {
  background: rgba(255, 211, 195, 0.48);
  box-shadow: inset 0 0 0 6px rgba(217, 85, 67, 0.82);
}

.piece-owner-mark {
  position: absolute;
  right: 14%;
  bottom: 14%;
  width: 11px;
  height: 11px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 1px 3px rgba(45, 52, 41, 0.3);
}

.owner-1 .piece-owner-mark {
  background: var(--coral);
}

.you-card {
  margin-top: 16px;
}

.soft-button,
.text-button,
.wide-button,
.mode-choice {
  border: 0;
  font-weight: 900;
}

.soft-button {
  min-height: 38px;
  padding: 7px 19px;
  border-radius: 999px;
  color: #55715a;
  background: rgba(255, 253, 245, 0.78);
  box-shadow: 0 4px 12px rgba(74, 96, 67, 0.1);
  font-size: 12px;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  overflow-y: auto;
  place-items: center;
  background: rgba(48, 74, 51, 0.58);
  backdrop-filter: blur(7px);
}

.modal-card {
  position: relative;
  width: min(100%, 420px);
  padding: 28px 22px 22px;
  border: 3px solid rgba(255, 255, 255, 0.74);
  border-radius: 30px;
  background: #fffdf6;
  box-shadow: 0 24px 60px rgba(30, 52, 33, 0.27);
  text-align: center;
}

.start-card {
  padding-top: 88px;
}

.start-card h2 {
  margin-bottom: 20px;
  font-size: clamp(25px, 7vw, 34px);
}

.modal-lion {
  position: absolute;
  top: -65px;
  left: 50%;
  width: 145px;
  height: 145px;
  object-fit: contain;
  transform: translateX(-50%);
  filter: drop-shadow(0 9px 8px rgba(68, 73, 42, 0.16));
}

.modal-card h2 {
  margin: 4px 0 8px;
  color: #365f3b;
  font-size: clamp(27px, 8vw, 38px);
  line-height: 1.15;
}

.modal-copy {
  margin: 0 auto 18px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
}

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

.mode-choice {
  display: flex;
  width: 100%;
  min-height: 72px;
  padding: 10px 17px;
  align-items: center;
  gap: 14px;
  border: 2px solid #dbe6ce;
  border-radius: 19px;
  color: var(--ink);
  background: #f4f8e9;
  text-align: left;
}

.mode-choice.primary-choice {
  border-color: #7eb96c;
  color: white;
  background: linear-gradient(135deg, #78b766, #579250);
  box-shadow: 0 8px 17px rgba(71, 124, 67, 0.22);
}

.mode-choice.tutorial-choice {
  border-color: #b8cce2;
  color: #426b87;
  background: #edf5fb;
}

.mode-emoji {
  font-size: 31px;
}

.mode-choice strong,
.mode-choice small {
  display: block;
}

.mode-choice strong {
  font-size: 16px;
}

.mode-choice small {
  margin-top: 2px;
  opacity: 0.76;
  font-size: 11px;
}

.opponent-select-card {
  width: min(100%, 460px);
}

.opponent-choice-grid {
  display: grid;
  margin-top: 18px;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.opponent-choice {
  display: grid;
  min-height: 126px;
  padding: 12px 6px 10px;
  place-items: center;
  gap: 7px;
  border: 2px solid #dbe6ce;
  border-radius: 18px;
  color: var(--ink);
  background: #f4f8e9;
  font-weight: 900;
}

.opponent-choice:active {
  transform: scale(0.98);
}

.opponent-choice img {
  width: min(100%, 68px);
  height: 68px;
  object-fit: contain;
  filter: drop-shadow(0 5px 4px rgba(70, 86, 52, 0.14));
}

.opponent-choice strong {
  display: block;
  font-size: 14px;
}

.promotion-choice-card img {
  width: 108px;
  height: 108px;
  object-fit: contain;
  filter: drop-shadow(0 7px 6px rgba(70, 86, 52, 0.16));
}

.promotion-actions {
  display: grid;
  margin-top: 14px;
  gap: 10px;
}

.text-button {
  margin-top: 14px;
  padding: 7px 13px;
  color: var(--green-dark);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.modal-close {
  position: absolute;
  top: 13px;
  right: 13px;
  display: grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #667566;
  background: #edf2e6;
  font-size: 27px;
  line-height: 1;
}

.tutorial-card {
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
}

.tutorial-step-label {
  display: inline-block;
  margin: 0 0 5px;
  padding: 5px 12px;
  border-radius: 999px;
  color: white;
  background: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.tutorial-lead,
.tutorial-note {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.55;
}

.tutorial-lead {
  margin: 0 auto 14px;
  font-size: 13px;
}

.tutorial-note {
  margin: 13px auto;
  font-size: 12px;
}

.tutorial-lead strong,
.tutorial-note strong {
  color: var(--green-dark);
}

.tutorial-piece-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tutorial-entry-grid {
  display: grid;
  gap: 10px;
}

.tutorial-entry-grid .mode-choice {
  width: 100%;
}

.tutorial-review-grid {
  display: grid;
  margin-top: 14px;
  gap: 8px;
}

.tutorial-review-grid button {
  display: flex;
  min-height: 62px;
  padding: 9px 7px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 2px solid var(--green-dark);
  border-radius: 14px;
  color: white;
  background: var(--green);
}

.tutorial-review-grid button:active {
  transform: scale(0.98);
}

.tutorial-review-grid strong,
.tutorial-review-grid span {
  display: block;
}

.tutorial-review-grid strong {
  color: white;
  font-size: 13px;
}

.tutorial-review-grid span {
  font-size: 11px;
  font-weight: 800;
}

.tsume-intro {
  display: flex;
  margin: 18px 0;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.tsume-intro span {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 4px solid #d8e7cd;
  border-radius: 50%;
  color: white;
  background: var(--green);
  box-shadow: 0 5px 10px rgba(68, 121, 64, 0.18);
  font-size: 22px;
  font-weight: 900;
}

.tutorial-piece-grid.five-pieces .tutorial-piece-card:last-child {
  width: calc((100% - 8px) / 2);
  grid-column: 1 / -1;
  justify-self: center;
}

.tutorial-piece-grid.five-pieces + .wide-button {
  margin-top: 14px;
}

.quiz-howto {
  display: grid;
  margin: 14px 0;
  grid-template-columns: 34px 1fr;
  gap: 8px 10px;
  align-items: center;
  text-align: left;
}

.quiz-howto span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--green);
  font-size: 14px;
  font-weight: 900;
}

.quiz-howto p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.tutorial-piece-card {
  display: flex;
  min-height: 86px;
  padding: 8px;
  align-items: center;
  gap: 7px;
  border: 2px solid #e1e8d6;
  border-radius: 16px;
  background: #f7f9ef;
  text-align: left;
}

.tutorial-piece-image {
  position: relative;
  width: 60px;
  height: 60px;
  flex: 0 0 auto;
  border-radius: 13px;
  background: url("assets/images/piece.webp") center / contain no-repeat;
}

.tutorial-piece-image img {
  position: absolute;
  inset: 1%;
  width: 98%;
  height: 98%;
  object-fit: contain;
}

.tutorial-piece-card strong,
.tutorial-piece-card small {
  display: block;
}

.tutorial-piece-card strong {
  color: var(--ink);
  font-size: 13px;
}

.tutorial-piece-card small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
}

.tutorial-mini-board {
  position: relative;
  display: grid;
  width: min(100%, 210px);
  margin: 12px auto 8px;
  aspect-ratio: 3 / 4;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  overflow: hidden;
  border: 6px solid #a6723b;
  border-radius: 17px;
  background: #edc98e;
  box-shadow: 0 7px 0 #855a31, 0 12px 19px rgba(68, 75, 49, 0.18);
}

.tutorial-mini-board + .wide-button {
  margin-top: 16px;
}

.tutorial-mini-board > span {
  position: relative;
  min-width: 0;
  min-height: 0;
  border-right: 2px solid rgba(132, 82, 35, 0.43);
  border-bottom: 2px solid rgba(132, 82, 35, 0.43);
}

.tutorial-mini-board > span:nth-of-type(3n) {
  border-right: 0;
}

.tutorial-mini-board > span:nth-of-type(n + 10) {
  border-bottom: 0;
}

.tutorial-mini-board .tutorial-target {
  background: rgba(111, 166, 90, 0.28);
  box-shadow: inset 0 0 0 4px rgba(111, 166, 90, 0.75);
}

.tutorial-mini-board .tutorial-direction-target {
  background: rgba(111, 166, 90, 0.18);
  box-shadow: inset 0 0 0 3px rgba(111, 166, 90, 0.58);
}

.tutorial-promoted-preview img {
  position: absolute;
  inset: -10%;
  width: 120%;
  height: 120%;
  object-fit: contain;
  background: url("assets/images/piece.webp") center / contain no-repeat;
  opacity: 0.72;
  filter: drop-shadow(0 3px 2px rgba(82, 57, 28, 0.2));
}

.promotion-arrow {
  top: 11%;
  height: 25%;
}

.tutorial-board-piece img {
  position: absolute;
  inset: -8%;
  width: 116%;
  height: 116%;
  object-fit: contain;
  background: url("assets/images/piece.webp") center / contain no-repeat;
  filter: drop-shadow(0 3px 2px rgba(82, 57, 28, 0.2));
}

.tutorial-board-piece.opponent img {
  transform: rotate(180deg);
}

.tutorial-mini-piece img {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: 119%;
  height: 119%;
  object-fit: contain;
  background: url("assets/images/piece.webp") center / contain no-repeat;
  filter: drop-shadow(0 3px 2px rgba(82, 57, 28, 0.22));
  transform: translate(-50%, -50%);
}

.tutorial-arrow {
  position: absolute;
  top: 35%;
  left: 50%;
  z-index: 4;
  width: 0;
  height: 21%;
  border-left: 5px solid #3f8e49;
  filter: drop-shadow(0 2px 1px rgba(255, 255, 255, 0.9));
  transform: translateX(-50%);
}

.tutorial-arrow::before {
  position: absolute;
  top: -4px;
  left: -11px;
  border-right: 9px solid transparent;
  border-bottom: 13px solid #3f8e49;
  border-left: 9px solid transparent;
  content: "";
}

.tutorial-directions {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tutorial-directions line {
  stroke: #3f8e49;
  stroke-width: 7;
  stroke-linecap: round;
  marker-end: url("#tutorialArrowHead");
  filter: drop-shadow(0 2px 1px rgba(255, 255, 255, 0.92));
}

.lion-board .tutorial-directions line,
.chicken-board .tutorial-directions line {
  stroke-width: 5.5;
}

.tutorial-directions path {
  fill: #3f8e49;
}

.tutorial-complete-card img {
  width: 145px;
  height: 145px;
  object-fit: contain;
  filter: drop-shadow(0 8px 7px rgba(68, 73, 42, 0.16));
}

body.tutorial-active .opponent-card,
body.tutorial-active .you-card {
  display: none;
}

body.tutorial-active.tutorial-capture .you-card {
  display: flex;
}

body.tutorial-active.tutorial-demo .opponent-card,
body.tutorial-active.tutorial-demo .you-card {
  display: flex;
}

body.tutorial-active.tutorial-tsume .opponent-card {
  display: flex;
}

body.tutorial-active .turn-banner {
  margin-bottom: 10px;
  background: #b77930;
}

.settings-card {
  text-align: left;
}

.settings-card > .modal-kicker,
.settings-card > h2 {
  text-align: center;
}

.setting-group {
  margin: 18px 0;
  padding: 15px;
  border: 2px solid #e3ead8;
  border-radius: 18px;
  background: #f8faef;
}

.setting-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.setting-icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  color: #477c43;
  background: #dceec5;
  font-size: 19px;
  font-weight: 900;
}

.setting-heading h3,
.setting-heading p,
.setting-help {
  margin: 0;
}

.setting-heading h3 {
  color: var(--ink);
  font-size: 15px;
}

.setting-heading p,
.setting-help {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.45;
}

.segmented-control {
  display: grid;
  margin-top: 13px;
  padding: 4px;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  border-radius: 13px;
  background: #e5ebdc;
}

.segmented-control button {
  min-height: 42px;
  padding: 6px 4px;
  border: 0;
  border-radius: 10px;
  color: #667466;
  background: transparent;
  font-size: 12px;
  font-weight: 900;
}

.segmented-control button[aria-pressed="true"] {
  color: white;
  background: var(--green);
  box-shadow: 0 3px 8px rgba(62, 111, 59, 0.22);
}

.setting-help {
  min-height: 31px;
  margin-top: 8px;
  text-align: center;
}

.switch-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.switch-button {
  position: relative;
  width: 58px;
  height: 34px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #c8cec4;
  transition: background 140ms ease;
}

.switch-button span {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px rgba(55, 69, 55, 0.25);
  transition: transform 140ms ease;
}

.switch-button[aria-checked="true"] {
  background: var(--green);
}

.switch-button[aria-checked="true"] span {
  transform: translateX(24px);
}

.rules-card {
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
}

.rules-list {
  display: grid;
  margin: 18px 0;
  padding: 0;
  gap: 10px;
  list-style: none;
  text-align: left;
}

.rules-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.rules-list li > span {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.rules-list p {
  margin: 0;
  color: #667366;
  font-size: 12px;
  line-height: 1.5;
}

.rules-list strong {
  color: var(--ink);
  font-size: 14px;
}

.rules-actions {
  display: grid;
  margin-bottom: 10px;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.rules-actions .soft-button {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  background: #fffaf0;
}

.wide-button {
  width: 100%;
  min-height: 52px;
  padding: 10px 18px;
  border-radius: 16px;
  color: white;
  background: linear-gradient(135deg, #78b766, #579250);
  box-shadow: 0 7px 14px rgba(68, 121, 64, 0.2);
  font-size: 16px;
}

.secondary-wide-button {
  margin-top: 8px;
  color: var(--green-dark);
  background: #edf4e7;
  box-shadow: none;
}

.tutorial-complete-card .secondary-wide-button {
  margin-bottom: 12px;
}

.result-card {
  overflow: hidden;
  padding-top: 30px;
}

.result-animal {
  width: 150px;
  height: 150px;
  object-fit: contain;
  animation: result-bounce 680ms cubic-bezier(0.22, 1.5, 0.42, 1);
}

.confetti {
  position: absolute;
  top: 15px;
  left: 0;
  width: 100%;
  color: var(--gold);
  font-size: 20px;
  letter-spacing: 0.3em;
}

.debug-panel {
  position: fixed;
  right: 8px;
  bottom: 8px;
  z-index: 50;
  max-width: calc(100vw - 16px);
  padding: 8px 10px;
  border-radius: 8px;
  color: #d9ffd9;
  background: rgba(11, 28, 14, 0.88);
  font: 11px/1.4 ui-monospace, monospace;
  white-space: pre-wrap;
  pointer-events: none;
}

@keyframes thinking {
  to { transform: scale(1.42); opacity: 0.55; }
}

@keyframes result-bounce {
  0% { transform: translateY(22px) scale(0.72); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

@media (max-width: 360px) {
  .app { padding-inline: 8px; }
  .brand img { width: 36px; height: 36px; }
  .eyebrow { display: none; }
  .icon-button { width: 38px; height: 38px; }
  .player-card { min-height: 82px; padding-block: 6px; }
  .hand { min-width: 132px; min-height: 68px; }
  .hand-piece { width: 68px; height: 68px; }
  .turn-banner { margin-block: 3px; }
  .you-card { margin-top: 14px; }
}

@media (max-width: 480px) {
  .brand { gap: 5px; }
  .brand img { width: 35px; height: 35px; }
  .eyebrow { display: none; }
  h1 {
    font-size: 19px;
    white-space: nowrap;
  }
  .top-actions { gap: 5px; }
  .icon-button { width: 38px; height: 38px; }
}

@media (min-width: 760px) {
  .app {
    width: min(100%, 760px);
    padding-top: max(18px, env(safe-area-inset-top));
  }
  .board-wrap {
    width: clamp(320px, min(58vw, 470px, calc((100dvh - 348px) * 0.75)), 470px);
  }
  .player-card {
    width: min(100%, 540px);
    padding-inline: 16px;
  }
  .piece-owner-mark { width: 13px; height: 13px; }
}

@media (orientation: landscape) and (max-height: 600px) {
  .app { width: min(100%, 860px); }
  .topbar { position: absolute; top: 8px; left: 14px; width: 205px; }
  .top-actions { position: fixed; top: 9px; right: 12px; z-index: 2; }
  .game-area { display: grid; width: min(100%, 780px); margin: 0 auto; grid-template-columns: 1fr auto 1fr; grid-template-rows: auto auto auto; column-gap: 12px; }
  .opponent-card { grid-column: 3; grid-row: 1; align-self: end; }
  .turn-banner { grid-column: 2; grid-row: 1; }
  .board-wrap { grid-column: 2; grid-row: 2 / span 2; width: min(48vh, 310px); }
  .you-card { grid-column: 1; grid-row: 2; margin: 0; }
  .player-card { width: 210px; flex-direction: column; }
  .hand { min-width: 0; }
  .hand-piece { width: 64px; height: 64px; }
}

@media (min-width: 1000px) and (min-height: 650px) {
  .app {
    width: min(100%, 1120px);
    padding-inline: 24px;
  }

  .topbar {
    width: min(100%, 1050px);
    margin-inline: auto;
  }

  .game-area {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(210px, 250px) auto minmax(210px, 250px);
    grid-template-rows: auto auto auto;
    justify-content: center;
    align-items: center;
    column-gap: 22px;
  }

  .opponent-card {
    grid-column: 1;
    grid-row: 2;
  }

  .turn-banner {
    grid-column: 2;
    grid-row: 1;
  }

  .board-wrap {
    grid-column: 2;
    grid-row: 2;
    width: min(45vw, 520px, calc((100dvh - 194px) * 0.75));
  }

  .you-card {
    grid-column: 3;
    grid-row: 2;
    margin-top: 0;
  }

  .player-card {
    width: 100%;
    min-height: 140px;
    padding: 17px 14px;
    flex-direction: column;
    justify-content: center;
  }

  .player-name-row {
    width: 100%;
  }

  .hand {
    width: 100%;
    min-width: 0;
    justify-content: center;
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
