:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --font-body: "Palatino Linotype", "Book Antiqua", "Iowan Old Style", "Times New Roman", serif;
  --font-display: "Baskerville", "Garamond", "Palatino Linotype", "Times New Roman", serif;
  --font-ui: "Trebuchet MS", "Gill Sans", "Segoe UI", sans-serif;

  /* Palette: carta, pietra, legno, verde */
  --paper: #efe3cf;
  --paper-2: #e5d5bb;
  --parchment-light: #f6ecd7;
  --parchment-mid: #e6d2ad;
  --parchment-dark: #c8ae80;
  --parchment-edge: #8c6a42;
  --ink: #2d241b;
  --ink-soft: #56483b;
  --stone: #b8a792;
  --wood: #7d5a3b;
  --moss: #6c7d49;
  --rose: #ba6f6f;
  --accent: #a76e2f;
  --bear: #9b4f3f;
  --hunter: #3d6070;
  --line: #44372c;
  --edge-glow: rgba(167, 110, 47, 0.18);
  --surface-radius: 15px 8px 13px 10px / 11px 16px 9px 15px;
  --surface-inner-radius: 12px 6px 10px 7px / 9px 13px 7px 12px;
  --surface-inner-inset: 3px;
  --surface-border: 2px solid rgba(68, 54, 38, 0.35);
  --surface-inner-border: 1px solid rgba(140, 106, 66, 0.32);
  --surface-background:
    radial-gradient(circle at 20% 18%, rgba(255, 247, 229, 0.55), transparent 42%),
    radial-gradient(circle at 80% 82%, rgba(190, 151, 92, 0.13), transparent 40%),
    linear-gradient(178deg, rgba(248, 237, 213, 0.95), rgba(231, 213, 180, 0.93)),
    repeating-linear-gradient(
      85deg,
      rgba(61, 46, 31, 0.02) 0,
      rgba(61, 46, 31, 0.02) 2px,
      transparent 2px,
      transparent 12px
    ),
    repeating-radial-gradient(circle at 35% 45%, rgba(83, 63, 41, 0.02) 0 1px, transparent 1px 16px);
  --surface-shadow:
    inset 0 0 0 1px rgba(98, 73, 46, 0.16),
    inset 0 16px 18px rgba(255, 249, 236, 0.28),
    inset 0 -22px 22px rgba(94, 67, 36, 0.12),
    0 5px 0 rgba(70, 52, 33, 0.2),
    0 12px 28px rgba(43, 30, 18, 0.14);
  --surface-inner-background:
    radial-gradient(circle at 14% 12%, rgba(255, 248, 233, 0.24), transparent 36%),
    radial-gradient(circle at 88% 82%, rgba(126, 92, 52, 0.09), transparent 30%);
  --surface-overlay-shadow:
    inset 0 0 0 1px rgba(97, 72, 44, 0.22),
    inset 0 14px 16px rgba(255, 249, 237, 0.2),
    inset 0 -16px 20px rgba(85, 60, 34, 0.18);
  --ui-btn-radius: 10px 6px 10px 7px / 8px 12px 7px 11px;
  --ui-btn-border: 2px solid rgba(77, 58, 38, 0.36);
  --ui-btn-background:
    linear-gradient(180deg, rgba(246, 236, 214, 0.98), rgba(225, 206, 172, 0.95)),
    repeating-linear-gradient(
      0deg,
      rgba(78, 59, 38, 0.03) 0,
      rgba(78, 59, 38, 0.03) 1px,
      transparent 1px,
      transparent 10px
    );
  --ui-btn-shadow: 0 3px 0 rgba(70, 52, 33, 0.22);
  --ui-btn-hover-border: rgba(134, 86, 39, 0.9);
  --ui-btn-hover-shadow: 0 4px 0 rgba(70, 52, 33, 0.24);
  --ui-btn-active-shadow: 0 1px 0 rgba(70, 52, 33, 0.22);
  --app-pad: 1rem;
  --screen-gap: 1rem;
  --hero-padding: 1.25rem;
  --hero-radius: 16px 10px 15px 9px / 10px 18px 9px 16px;
  --subtitle-size: 1rem;
  --eyebrow-size: 0.72rem;
  --panel-padding: 0.9rem;
  --game-header-gap: 0.8rem;
  --game-header-title-margin-top: 0.2rem;
  --game-header-title-size: 1.1rem;
  --actions-cols: repeat(auto-fit, minmax(140px, 1fr));
  --actions-gap: 0.6rem;
  --actions-btn-pad-y: 0.62rem;
  --actions-btn-pad-x: 0.7rem;
  --status-copy-size: 1rem;
  --status-copy-line-height: normal;
  --status-p-margin: 0.26rem;
  --status-message-min-lines: 2;
  --result-copy-margin: 0.2rem;
  --result-banner-pad-y: 0.42rem;
  --result-banner-pad-x: 0.6rem;
  --result-banner-margin-bottom: 0.55rem;
  --board-width-limit: clamp(260px, 76vw, 520px);
  --rough-cut: polygon(
    2.5% 0.8%,
    10% 0%,
    22% 1.4%,
    36% 0.2%,
    48% 1.8%,
    64% 0.4%,
    80% 1.6%,
    92% 0%,
    99.4% 3.4%,
    100% 15%,
    98.6% 30%,
    100% 44%,
    98.8% 58%,
    100% 72%,
    98.9% 86%,
    99.6% 96.5%,
    92% 100%,
    80% 98.6%,
    66% 100%,
    52% 98.8%,
    39% 100%,
    24% 98.8%,
    12% 100%,
    2% 98.4%,
    0% 90%,
    1.2% 75%,
    0% 60%,
    1.4% 46%,
    0% 31%,
    1.4% 16%
  );

  /* Optional variant: set to url('./background-sketch.png') */
  --village-artwork: url('./background-sketch.png');
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
  background:
    radial-gradient(140vmax 90vmax at 8% 10%, rgba(140, 107, 67, 0.2) 0%, transparent 58%),
    radial-gradient(130vmax 90vmax at 92% 90%, rgba(108, 125, 73, 0.12) 0%, transparent 52%),
    radial-gradient(100vmax 65vmax at 50% 110%, rgba(90, 62, 32, 0.14) 0%, transparent 65%),
    linear-gradient(160deg, var(--parchment-light), var(--paper-2));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 22% 28%, rgba(111, 82, 46, 0.08), transparent 34%),
    radial-gradient(circle at 76% 74%, rgba(111, 82, 46, 0.09), transparent 30%),
    linear-gradient(6deg, rgba(41, 30, 21, 0.05), rgba(41, 30, 21, 0.01) 35%, rgba(41, 30, 21, 0.06)),
    repeating-linear-gradient(
      12deg,
      rgba(72, 58, 43, 0.03) 0,
      rgba(72, 58, 43, 0.03) 1px,
      transparent 1px,
      transparent 13px
    ),
    repeating-radial-gradient(circle at 30% 40%, rgba(76, 58, 38, 0.028) 0 1px, transparent 1px 14px),
    var(--village-artwork);
  background-size: auto, auto, auto, auto, auto, cover;
  background-position: center;
  mix-blend-mode: multiply;
  opacity: 0.78;
  z-index: 0;
}

.app {
  max-width: 1060px;
  margin: 0 auto;
  padding:
    calc(var(--app-pad) + var(--safe-top))
    calc(var(--app-pad) + var(--safe-right))
    calc(var(--app-pad) + var(--safe-bottom))
    calc(var(--app-pad) + var(--safe-left));
  position: relative;
  z-index: 1;
}

.legal-footer {
  display: block;
  padding: 0.1rem 1rem 0.85rem;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: rgba(86, 72, 59, 0.9);
  opacity: 0.92;
}

.legal-footer a {
  color: #5a4634;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.screen {
  display: grid;
  gap: var(--screen-gap);
  min-width: 0;
}

.left-stack {
  display: grid;
  gap: 0.8rem;
  min-width: 0;
}

.is-hidden {
  display: none;
}

.hero {
  padding: var(--hero-padding);
  border: 2px solid rgba(66, 50, 34, 0.32);
  border-radius: var(--hero-radius);
  clip-path: var(--rough-cut);
  background:
    linear-gradient(175deg, rgba(255, 252, 242, 0.78), rgba(227, 211, 182, 0.74)),
    repeating-linear-gradient(
      90deg,
      rgba(74, 56, 38, 0.03) 0,
      rgba(74, 56, 38, 0.03) 2px,
      transparent 2px,
      transparent 10px
    );
  box-shadow: 0 8px 24px rgba(51, 36, 22, 0.18);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: var(--eyebrow-size);
  color: var(--accent);
  font-weight: 700;
  font-family: var(--font-ui);
}

h1 {
  margin: 0.35rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5.7vw, 3.3rem);
  line-height: 1.03;
  color: var(--ink);
  letter-spacing: 0.01em;
  text-align: center;
}

.subtitle {
  margin: 0.45rem 0 0;
  color: var(--ink-soft);
  font-size: var(--subtitle-size);
  text-align: center;
}

:is(.start-card, .status-panel, .results-panel, .board-panel, .legend, .game-header) {
  position: relative;
  isolation: isolate;
  background: var(--surface-background);
  border: var(--surface-border);
  border-radius: var(--surface-radius);
  clip-path: var(--rough-cut);
  box-shadow: var(--surface-shadow);
}

:is(.start-card, .status-panel, .results-panel, .board-panel, .legend, .game-header)::before {
  content: "";
  position: absolute;
  inset: var(--surface-inner-inset);
  border-radius: var(--surface-inner-radius);
  clip-path: var(--rough-cut);
  border: var(--surface-inner-border);
  background: var(--surface-inner-background);
  pointer-events: none;
  z-index: 0;
}

:is(.start-card, .status-panel, .results-panel, .board-panel, .legend, .game-header)::after {
  content: "";
  position: absolute;
  inset: -1px;
  clip-path: var(--rough-cut);
  pointer-events: none;
  z-index: 0;
  box-shadow: var(--surface-overlay-shadow);
}

:is(.start-card, .status-panel, .results-panel, .board-panel, .legend, .game-header) > * {
  position: relative;
  z-index: 1;
}

.start-card {
  padding: 1.1rem;
}

h2 {
  margin: 0 0 0.8rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: #34281f;
  letter-spacing: 0.01em;
}

.mode-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

:is(.mode-btn, .side-btn, .cta-btn, :where(.actions button)) {
  position: relative;
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
  border: var(--ui-btn-border);
  background: var(--ui-btn-background);
  border-radius: var(--ui-btn-radius);
  clip-path: var(--rough-cut);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  box-shadow: var(--ui-btn-shadow);
}

:is(.mode-btn, .side-btn) {
  min-height: 3rem;
}

.mode-btn,
.side-btn,
.cta-btn {
  isolation: isolate;
}

:is(.mode-btn, .side-btn, .cta-btn, :where(.actions button)):hover {
  transform: translateY(-1px);
  border-color: var(--ui-btn-hover-border);
  box-shadow: var(--ui-btn-hover-shadow);
}

:is(.mode-btn, .side-btn, .cta-btn, :where(.actions button)):active {
  transform: translateY(1px);
  box-shadow: var(--ui-btn-active-shadow);
}

.mode-btn {
  display: grid;
  gap: 0.25rem;
  text-align: left;
  padding: 0.85rem;
}

.mode-title {
  font-size: 1.05rem;
  font-weight: 700;
  font-family: var(--font-body);
  letter-spacing: 0.01em;
}

.mode-copy {
  color: rgba(72, 59, 46, 0.94);
  font-size: 0.9rem;
}

.mode-btn.is-active,
.side-btn.is-active {
  color: #2b1e14;
  border-color: rgba(134, 86, 39, 0.98);
  background:
    linear-gradient(180deg, rgba(248, 231, 187, 0.99), rgba(230, 193, 121, 0.96)),
    repeating-linear-gradient(
      -10deg,
      rgba(94, 66, 31, 0.04) 0,
      rgba(94, 66, 31, 0.04) 2px,
      transparent 2px,
      transparent 12px
    );
  box-shadow:
    inset 0 0 0 2px rgba(255, 246, 221, 0.5),
    0 0 0 3px rgba(167, 110, 47, 0.22),
    0 5px 0 rgba(70, 52, 33, 0.22);
}

.mode-btn.is-active::after,
.side-btn.is-active::after {
  content: "";
  position: absolute;
  inset: 0.5rem auto 0.5rem 0.42rem;
  width: 0.14rem;
  border-radius: 999px;
  background: rgba(134, 86, 39, 0.48);
  pointer-events: none;
}

.mode-btn.is-active .mode-copy {
  color: rgba(58, 41, 23, 0.92);
}

.mode-btn:not(.is-active),
.side-btn:not(.is-active) {
  color: rgba(45, 36, 27, 0.88);
  border-color: rgba(89, 67, 42, 0.42);
  background:
    linear-gradient(180deg, rgba(244, 233, 210, 0.95), rgba(226, 209, 177, 0.93)),
    repeating-linear-gradient(
      0deg,
      rgba(78, 59, 38, 0.028) 0,
      rgba(78, 59, 38, 0.028) 1px,
      transparent 1px,
      transparent 10px
    );
  box-shadow:
    inset 0 1px 0 rgba(255, 248, 229, 0.4),
    0 2px 0 rgba(70, 52, 33, 0.16);
}

.cta-btn {
  color: #2a1d13;
  border-color: rgba(132, 85, 34, 0.95);
  background:
    linear-gradient(180deg, rgba(248, 231, 188, 0.995), rgba(231, 194, 114, 0.98)),
    repeating-linear-gradient(
      -10deg,
      rgba(94, 66, 31, 0.04) 0,
      rgba(94, 66, 31, 0.04) 2px,
      transparent 2px,
      transparent 12px
    );
  box-shadow:
    inset 0 0 0 2px rgba(255, 246, 220, 0.56),
    0 0 0 3px rgba(167, 110, 47, 0.18),
    0 5px 0 rgba(70, 52, 33, 0.22);
}

.cta-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 248, 228, 0.18), transparent 45%);
  pointer-events: none;
  z-index: -1;
}

.side-panel {
  margin-top: 0.95rem;
  padding: 0.8rem;
  border-radius: 12px 7px 12px 8px / 8px 13px 7px 11px;
  clip-path: var(--rough-cut);
  background:
    linear-gradient(180deg, rgba(248, 236, 211, 0.86), rgba(233, 215, 183, 0.84)),
    repeating-radial-gradient(circle at 30% 35%, rgba(81, 60, 36, 0.03) 0 1px, transparent 1px 15px);
  border: 1px solid rgba(74, 56, 38, 0.26);
}

.side-title {
  margin: 0;
  color: var(--ink-soft);
  font-family: var(--font-ui);
  font-weight: 600;
}

.side-toggle {
  margin-top: 0.65rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(100px, 1fr));
  gap: 0.6rem;
}

.side-toggle--triple {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.side-btn {
  padding: 0.62rem 0.7rem;
}

.cta-btn {
  width: 100%;
  margin-top: 0.95rem;
  padding: 0.78rem;
  font-size: 1rem;
}

.game-header {
  display: grid;
  gap: var(--game-header-gap);
}

.game-header > :first-child {
  justify-self: start;
  margin-left: -0.45rem;
  padding: 0.3rem 0.68rem 0.38rem;
  border: 1px solid rgba(112, 84, 53, 0.42);
  border-radius: 11px 7px 10px 8px / 8px 12px 7px 10px;
  clip-path: var(--rough-cut);
  background:
    linear-gradient(180deg, rgba(249, 239, 217, 0.94), rgba(233, 213, 178, 0.92)),
    repeating-linear-gradient(
      0deg,
      rgba(79, 57, 34, 0.024) 0,
      rgba(79, 57, 34, 0.024) 1px,
      transparent 1px,
      transparent 12px
    );
  box-shadow:
    inset 0 0 0 1px rgba(255, 248, 232, 0.28),
    0 2px 0 rgba(92, 68, 40, 0.2);
}

.game-header > div {
  min-width: 0;
}

.game-header h2 {
  margin: var(--game-header-title-margin-top) 0 0;
  font-size: var(--game-header-title-size);
}

.actions {
  display: grid;
  grid-template-columns: var(--actions-cols);
  gap: var(--actions-gap);
  min-width: 0;
}

.actions button {
  padding: var(--actions-btn-pad-y) var(--actions-btn-pad-x);
}

:is(.game-header, .status-panel, .results-panel, .board-panel, .legend) {
  padding: var(--panel-padding);
  min-width: 0;
}

#startScreen .start-card {
  border-radius: 18px 10px 16px 12px / 12px 20px 10px 17px;
}

#startScreen .start-card h2 {
  margin-left: 0.9rem;
}

#startScreen .side-panel {
  border-radius: 13px 8px 12px 9px / 9px 14px 8px 12px;
}

#startScreen :is(.side-btn, .cta-btn) {
  border-radius: 12px 7px 11px 8px / 8px 13px 7px 11px;
}

.board-panel {
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: visible;
  clip-path: none;
  border-radius: 16px;
}

.board-panel::before,
.board-panel::after {
  clip-path: none;
  border-radius: inherit;
}

.status-panel p {
  margin: var(--status-p-margin) 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: var(--status-copy-size);
  line-height: var(--status-copy-line-height);
}

.status-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem 0.5rem;
  align-items: start;
}

.status-item {
  margin: 0;
  text-align: center;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.15;
  padding: 0.22rem 0.35rem 0.26rem;
  border: 1px solid rgba(112, 84, 53, 0.32);
  border-radius: 8px;
  background: rgba(248, 238, 214, 0.55);
}

.status-message {
  grid-column: 1 / -1;
  margin: 0;
  font-weight: 700;
  line-height: 1.24;
  min-height: 2.7em;
  max-height: 2.7em;
  color: #463728;
  font-family: var(--font-ui);
  font-size: 0.96rem;
  padding-bottom: 0.08em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.review-tutorial-btn {
  margin-top: 0.35rem;
  padding: 0.24rem 0.5rem;
  border: 1px solid rgba(106, 81, 54, 0.55);
  border-radius: 8px;
  background: rgba(246, 235, 210, 0.75);
  box-shadow: none;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  line-height: 1.1;
  color: #4b392a;
  cursor: pointer;
}

.review-tutorial-btn:hover {
  border-color: rgba(106, 81, 54, 0.8);
  background: rgba(246, 235, 210, 0.95);
}

#gameModeLabel,
.result-line,
.result-final {
  overflow-wrap: anywhere;
  font-family: var(--font-ui);
}

.result-banner {
  margin: 0 0 var(--result-banner-margin-bottom);
  padding: var(--result-banner-pad-y) var(--result-banner-pad-x);
  border-radius: 9px 5px 8px 6px / 6px 9px 5px 8px;
  clip-path: var(--rough-cut);
  font-weight: 700;
  letter-spacing: 0.01em;
  font-family: var(--font-ui);
  background: rgba(164, 129, 82, 0.22);
  border: 1px solid rgba(120, 89, 56, 0.35);
}

.result-banner.hunters-win {
  background: rgba(68, 110, 129, 0.2);
  border: 1px solid rgba(61, 96, 112, 0.5);
}

.result-banner.draw {
  background: rgba(191, 152, 92, 0.2);
  border: 1px solid rgba(167, 110, 47, 0.5);
}

.result-banner.match-over {
  background: rgba(155, 79, 63, 0.2);
  border: 1px solid rgba(137, 66, 51, 0.52);
}

.result-banner.tie {
  background: rgba(140, 132, 117, 0.22);
  border: 1px solid rgba(115, 107, 95, 0.5);
}

.result-line,
.result-final {
  margin: var(--result-copy-margin) 0;
  font-size: var(--status-copy-size);
  line-height: var(--status-copy-line-height);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-final {
  margin-top: 0.55rem;
  font-weight: 700;
}

#board {
  display: block;
  max-width: 100%;
  width: min(100%, var(--board-width-limit));
  height: auto;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  overflow: visible;
  border-radius: 14px 9px 12px 8px / 10px 16px 8px 13px;
  background:
    radial-gradient(circle at 28% 18%, rgba(255, 246, 228, 0.52), transparent 38%),
    radial-gradient(circle at 76% 74%, rgba(137, 98, 54, 0.12), transparent 38%),
    repeating-linear-gradient(
      22deg,
      rgba(74, 55, 38, 0.05) 0,
      rgba(74, 55, 38, 0.05) 1px,
      transparent 1px,
      transparent 11px
    ),
    repeating-radial-gradient(circle at 40% 40%, rgba(80, 60, 39, 0.03) 0 1px, transparent 1px 15px),
    linear-gradient(155deg, #ecd9b9, #ddc49c 45%, #c9ab7f);
  box-shadow:
    inset 0 0 0 2px rgba(83, 62, 39, 0.35),
    inset 0 0 18px rgba(124, 94, 56, 0.22),
    inset 0 -20px 22px rgba(83, 58, 31, 0.12),
    0 14px 26px rgba(54, 37, 22, 0.22);
}

.edge {
  stroke: var(--line);
  stroke-width: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  fill: none;
  filter: drop-shadow(0 0 2px var(--edge-glow));
}

.edge-lunette-guide {
  stroke: rgba(68, 55, 44, 0.92);
  stroke-width: 1.25;
  filter: drop-shadow(0 0 2px rgba(68, 55, 44, 0.2));
}

#board[data-setup="hunters"] .edge-lunette-guide {
  stroke: rgba(68, 55, 44, 0.95);
  stroke-width: 1.45;
  filter: drop-shadow(0 0 2px rgba(68, 55, 44, 0.16));
}

.edge-outer-lunette-guide {
  stroke: #6e8a5f;
  stroke-width: 1.35;
  filter: drop-shadow(0 0 3px rgba(108, 125, 73, 0.32));
}

#board[data-setup="hunters"] .edge-outer-lunette-guide {
  stroke: #6b8458;
  stroke-width: 1.5;
  filter: drop-shadow(0 0 3px rgba(108, 125, 73, 0.38));
}

.lunette-guide-node {
  fill: rgba(108, 125, 73, 0.14);
  stroke: rgba(98, 116, 68, 0.72);
  stroke-width: 0.45;
  pointer-events: none;
}

.node {
  cursor: pointer;
  stroke: #261a11;
  stroke-width: 0.65;
  pointer-events: none;
}

.node.empty {
  fill: #f7efdd;
}

.piece-group {
  pointer-events: none;
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.3));
}

.piece {
  stroke: #27180f;
  stroke-width: 0.65;
}

.piece-bear {
  fill: var(--bear);
}

.piece-hunter {
  fill: var(--hunter);
}

.piece-mark-bear {
  fill: #f0d7ce;
}

.piece-mark-hunter {
  stroke: #ecf3f6;
  stroke-width: 0.5;
  stroke-linecap: round;
}

.piece-mark-hunter-dot {
  fill: #ecf3f6;
}

.piece-selected {
  fill: none;
  stroke: #d5a254;
  stroke-width: 0.7;
}

.piece-thinking {
  fill: none;
  stroke-width: 1.05;
  vector-effect: non-scaling-stroke;
  transform-box: fill-box;
  transform-origin: center;
  animation: piece-thinking-pulse 1s ease-in-out infinite;
}

.piece-thinking-halo {
  fill: none;
  stroke-width: 1.7;
  opacity: 0.28;
  vector-effect: non-scaling-stroke;
  animation: piece-thinking-halo-pulse 1s ease-in-out infinite;
}

.piece-thinking-bear {
  stroke: rgba(155, 79, 63, 0.95);
}

.piece-thinking-hunter {
  stroke: rgba(61, 96, 112, 0.96);
}

.piece-thinking-halo-bear {
  stroke: rgba(155, 79, 63, 0.36);
}

.piece-thinking-halo-hunter {
  stroke: rgba(61, 96, 112, 0.38);
}

.node-hit {
  fill: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

#board[data-busy="true"] .node-hit {
  pointer-events: none;
  cursor: wait;
}

#board[data-busy="true"] {
  filter: saturate(0.97);
}

@keyframes piece-thinking-pulse {
  0%,
  100% {
    opacity: 0.55;
    stroke-width: 0.96;
  }
  50% {
    opacity: 1;
    stroke-width: 1.22;
  }
}

@keyframes piece-thinking-halo-pulse {
  0%,
  100% {
    opacity: 0.2;
    stroke-width: 1.45;
  }
  50% {
    opacity: 0.42;
    stroke-width: 1.95;
  }
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.legend p {
  margin: 0;
}

.dot {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 999px;
  border: 1px solid #5a4734;
  box-shadow: 0 0 0 1px rgba(47, 33, 20, 0.12);
  vertical-align: middle;
}

.dot.bear {
  background:
    radial-gradient(circle at 50% 60%, #f0d7ce 0 22%, transparent 23%),
    radial-gradient(circle at 36% 36%, #f0d7ce 0 9%, transparent 10%),
    radial-gradient(circle at 50% 31%, #f0d7ce 0 9%, transparent 10%),
    radial-gradient(circle at 64% 36%, #f0d7ce 0 9%, transparent 10%),
    var(--bear);
}

.dot.hunter {
  background:
    linear-gradient(#ecf3f6, #ecf3f6) center / 10% 58% no-repeat,
    linear-gradient(#ecf3f6, #ecf3f6) center / 58% 10% no-repeat,
    radial-gradient(circle at center, #ecf3f6 0 14%, transparent 15%),
    var(--hunter);
}

.dot.empty {
  background: #f7efdd;
}

.tutorial-popup {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(24, 17, 12, 0.58);
}

.tutorial-popup-card {
  width: min(460px, 100%);
  background: var(--surface-background);
  border: var(--surface-border);
  border-radius: var(--surface-radius);
  clip-path: var(--rough-cut);
  box-shadow: var(--surface-shadow);
  padding: 1rem;
}

.tutorial-popup-card h3 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  color: #34281f;
}

.tutorial-popup-text {
  margin: 0;
  font-family: var(--font-ui);
  line-height: 1.35;
  color: #463728;
}

.tutorial-popup-actions {
  margin-top: 0.85rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.tutorial-popup-btn {
  position: relative;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--ink);
  border: var(--ui-btn-border);
  background: var(--ui-btn-background);
  border-radius: var(--ui-btn-radius);
  clip-path: var(--rough-cut);
  cursor: pointer;
  padding: 0.55rem 0.8rem;
}

.tutorial-popup-btn--primary {
  border-color: rgba(134, 86, 39, 0.95);
  background:
    linear-gradient(180deg, rgba(244, 226, 187, 0.95), rgba(228, 202, 149, 0.9)),
    repeating-linear-gradient(
      -10deg,
      rgba(94, 66, 31, 0.04) 0,
      rgba(94, 66, 31, 0.04) 2px,
      transparent 2px,
      transparent 12px
    );
}

html.is-native-app :is(.mode-btn, .side-btn, .cta-btn, :where(.actions button), .tutorial-popup-btn) {
  clip-path: none;
  border-radius: 12px;
  border: 2px solid rgba(92, 67, 40, 0.9);
  color: #2f2218;
  background:
    linear-gradient(180deg, rgba(246, 237, 214, 0.995), rgba(228, 208, 171, 0.99));
  box-shadow:
    inset 0 1px 0 rgba(255, 248, 230, 0.86),
    inset 0 -1px 0 rgba(126, 92, 53, 0.12),
    0 2px 6px rgba(83, 61, 36, 0.18);
}

html.is-native-app :is(.mode-btn, .side-btn).is-active,
html.is-native-app .tutorial-popup-btn--primary {
  border-color: rgba(138, 86, 28, 1);
  color: #24170f;
  background:
    linear-gradient(180deg, rgba(251, 233, 183, 1), rgba(232, 192, 110, 0.995));
  box-shadow:
    inset 0 0 0 2px rgba(255, 245, 217, 0.74),
    0 0 0 3px rgba(167, 110, 47, 0.28),
    0 3px 8px rgba(111, 82, 50, 0.24);
}

html.is-native-app :is(.mode-btn, .side-btn, .cta-btn, :where(.actions button), .tutorial-popup-btn):hover,
html.is-native-app :is(.mode-btn, .side-btn, .cta-btn, :where(.actions button), .tutorial-popup-btn):active {
  transform: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 248, 230, 0.82),
    inset 0 -1px 0 rgba(126, 92, 53, 0.12),
    0 2px 6px rgba(83, 61, 36, 0.18);
}

html.is-native-app .mode-btn,
html.is-native-app #computerSidePanel .side-btn,
html.is-native-app #difficultyPanel .side-btn {
  border-color: rgba(97, 71, 42, 0.92);
  color: #33251a;
  background:
    linear-gradient(180deg, rgba(244, 233, 206, 0.998), rgba(226, 205, 164, 0.992));
  box-shadow:
    inset 0 0 0 1px rgba(255, 248, 229, 0.84),
    0 2px 7px rgba(79, 57, 33, 0.18);
}

html.is-native-app .mode-btn.is-active,
html.is-native-app #computerSidePanel .side-btn.is-active,
html.is-native-app #difficultyPanel .side-btn.is-active {
  border-color: rgba(138, 86, 28, 1);
  background:
    linear-gradient(180deg, rgba(251, 233, 183, 1), rgba(232, 192, 110, 0.995));
  box-shadow:
    inset 0 0 0 2px rgba(255, 245, 214, 0.78),
    0 0 0 3px rgba(167, 110, 47, 0.28),
    0 3px 8px rgba(111, 82, 50, 0.24);
}

html.is-native-app .mode-btn::before,
html.is-native-app #computerSidePanel .side-btn::before,
html.is-native-app #difficultyPanel .side-btn::before,
html.is-native-app .cta-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 250, 236, 0.26), transparent 48%);
  pointer-events: none;
  z-index: -1;
}

html.is-native-app .cta-btn {
  border-width: 2px;
  border-color: rgba(138, 86, 28, 1);
  color: #24170f;
  background:
    linear-gradient(180deg, rgba(252, 234, 185, 1), rgba(233, 191, 101, 0.998));
  box-shadow:
    inset 0 0 0 2px rgba(255, 246, 215, 0.84),
    0 0 0 3px rgba(167, 110, 47, 0.3),
    0 4px 10px rgba(98, 67, 35, 0.26);
}

html.is-native-app .actions button {
  border-color: rgba(110, 79, 44, 0.9);
  background:
    linear-gradient(180deg, rgba(243, 229, 198, 0.996), rgba(227, 206, 166, 0.986));
  box-shadow:
    inset 0 0 0 1px rgba(255, 247, 224, 0.74),
    0 2px 7px rgba(88, 62, 35, 0.18);
}

html.is-native-app .board-panel {
  border-radius: 18px;
  border-color: rgba(110, 84, 54, 0.3);
  box-shadow: 0 8px 18px rgba(54, 37, 22, 0.12);
}

html.is-native-app .board-panel::before,
html.is-native-app .board-panel::after {
  display: none;
}

html.is-native-app #board {
  border-radius: 14px;
  box-shadow:
    inset 0 0 0 2px rgba(101, 76, 48, 0.28),
    0 8px 18px rgba(54, 37, 22, 0.12);
}

html.is-native-app .edge,
html.is-native-app .edge-lunette-guide,
html.is-native-app .piece-group,
html.is-native-app #board[data-busy="true"] {
  filter: none;
}

html.is-native-app .edge,
html.is-native-app .edge-lunette-guide {
  shape-rendering: geometricPrecision;
}

@media (min-width: 760px) {
  :root {
    --app-pad: 1.5rem;
    --screen-gap: 1.2rem;
  }

  .game-header {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .status-panel {
    gap: 0.5rem 0.6rem;
    align-items: start;
  }
}

@media (min-width: 1100px) {
  #gameScreen {
    grid-template-columns: minmax(360px, 1fr) minmax(420px, 0.95fr);
    grid-template-areas:
      "header header"
      "left board";
    align-items: start;
    column-gap: 1rem;
    row-gap: 0.8rem;
  }

  #gameScreen .game-header {
    grid-area: header;
  }

  #gameScreen .left-stack {
    grid-area: left;
    align-self: start;
  }

  #gameScreen .board-panel {
    grid-area: board;
    align-self: start;
  }
}

@media (max-width: 480px) {
  :root {
    --app-pad: 0.6rem;
    --screen-gap: 0.7rem;
    --hero-padding: 0.85rem;
    --hero-radius: 12px 8px 11px 7px / 8px 12px 7px 10px;
    --subtitle-size: 0.92rem;
    --surface-radius: 11px 7px 10px 7px / 8px 11px 7px 10px;
    --surface-inner-inset: 2px;
    --panel-padding: 0.7rem;
    --actions-cols: 1fr 1fr;
    --actions-gap: 0.45rem;
    --actions-btn-pad-y: 0.5rem;
    --actions-btn-pad-x: 0.55rem;
    --status-copy-size: 0.95rem;
    --status-p-margin: 0.14rem;
    --result-copy-margin: 0.14rem;
    --result-banner-pad-y: 0.34rem;
    --result-banner-pad-x: 0.5rem;
    --result-banner-margin-bottom: 0.4rem;
  }

  .actions button {
    font-size: 0.94rem;
  }

  .legal-footer {
    padding-bottom: 0.7rem;
    font-size: 0.8rem;
  }

  .legend {
    display: none;
  }
}

@media (max-width: 480px) and (max-height: 860px) {
  :root {
    --board-width-limit: clamp(250px, 74vw, 500px);
  }
}

@media (max-width: 480px) and (max-height: 800px) {
  :root {
    --app-pad: 0.45rem;
    --screen-gap: 0.5rem;
    --panel-padding: 0.55rem;
    --game-header-gap: 0.45rem;
    --game-header-title-margin-top: 0.12rem;
    --game-header-title-size: 1rem;
    --eyebrow-size: 0.66rem;
    --status-copy-size: 0.88rem;
    --status-copy-line-height: 1.2;
    --status-p-margin: 0.1rem;
    --result-copy-margin: 0.1rem;
    --result-banner-pad-y: 0.28rem;
    --result-banner-pad-x: 0.45rem;
    --result-banner-margin-bottom: 0.3rem;
    --board-width-limit: clamp(240px, 70vw, 460px);
  }

  .result-banner {
    font-size: 0.92rem;
  }

  .legal-footer {
    padding-bottom: 0.55rem;
  }
}
