:root {
  --background: #f3ead8;
  --foreground: #2b2118;
  --card: #fffaf0;
  --primary: #b83a24;
  --primary-foreground: #fffaf0;
  --secondary: #ead7af;
  --muted: #efe5d1;
  --muted-foreground: #715f4a;
  --accent: #e9b94d;
  --destructive: #b83a24;
  --border: #aa8656;
  --ring: #b83a24;
  --font-display: Rockwell, 'Roboto Slab', Georgia, serif;
  --font-body: 'Trebuchet MS', 'Avenir Next', Arial, sans-serif;
  --radius: 0.75rem;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
html {
  background: var(--background);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--foreground);
  font-family: var(--font-body);
  background:
    radial-gradient(
      circle at 14% 18%,
      rgba(255, 255, 255, 0.55) 0 2px,
      transparent 3px
    ),
    radial-gradient(
      circle at 86% 72%,
      rgba(120, 80, 34, 0.11) 0 1px,
      transparent 2px
    ),
    linear-gradient(135deg, #f6eddb 0%, #e9d7b8 100%);
  background-size:
    31px 31px,
    23px 23px,
    auto;
}

button {
  font: inherit;
}

.game-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 54px) 14px;
}

.game-card {
  position: relative;
  width: min(100%, 620px);
  overflow: hidden;
  border: 1px solid rgba(102, 68, 34, 0.55);
  border-radius: 24px;
  background: rgba(255, 250, 240, 0.96);
  box-shadow:
    0 24px 70px rgba(71, 44, 18, 0.22),
    0 3px 0 #7e532f;
}

.game-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 7px;
  background: repeating-linear-gradient(
    90deg,
    #a8291a 0 36px,
    #e5a72f 36px 72px
  );
}

.game-nav {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 19px 22px 0;
}

.game-nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.game-nav a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border: 1px solid #a27b48;
  border-radius: 999px;
  background: #f3e4c6;
  box-shadow: 0 2px 0 #9b7244;
  color: #4c351f;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.025em;
  line-height: 1;
  text-decoration: none;
}

.game-nav a:hover,
.game-nav a:focus-visible {
  border-color: #8f291d;
  background: #fff3d8;
  color: #8f291d;
}

.game-nav a:focus-visible {
  outline: 3px solid rgba(11, 101, 105, 0.28);
  outline-offset: 2px;
}

.game-nav .game-nav-primary {
  border-color: #073f42;
  background: #0b6569;
  box-shadow: 0 2px 0 #073f42;
  color: #fffaf0;
}

.game-nav .game-nav-primary:hover,
.game-nav .game-nav-primary:focus-visible {
  background: #0e777b;
  color: #fffaf0;
}

.game-header {
  text-align: center;
  padding: 14px 28px 19px;
}

.brand-kicker {
  color: #956c32;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.2em;
}

.title-art {
  display: block;
  width: min(100%, 550px);
  height: auto;
  max-height: 158px;
  margin: 3px auto 5px;
  object-fit: contain;
}

.story-copy p {
  margin: 3px 0;
  font-size: clamp(12px, 2.8vw, 14px);
  line-height: 1.35;
}

.status-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 0 22px;
  padding: 11px 14px;
  border-block: 1px solid #c9ab7b;
  background: #f3e4c6;
}

.meter {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.meter-right {
  align-items: flex-end;
}
.meter-label {
  color: #80613d;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.13em;
}
.meter-value {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.counter-art {
  width: 25px;
  height: 25px;
  object-fit: contain;
}
.meter-value small {
  margin-left: 1px;
  font: 700 10px var(--font-body);
  color: #80613d;
}

.restart-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  gap: 7px;
  padding-inline: 14px;
  border: 1px solid #7c2117;
  border-radius: 999px;
  background: #af3422;
  box-shadow: 0 3px 0 #742116;
  color: #fffaf0;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.restart-button svg {
  width: 16px;
  height: 16px;
}
.restart-button:hover {
  background: #c43e29;
}
.restart-button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #742116;
}

.game-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.mobile-mark-button {
  display: none;
  height: 38px;
  padding: 0 10px;
  border: 1px solid #8a5e2c;
  border-radius: 999px;
  background: #f6e7c8;
  box-shadow: 0 3px 0 #9b7244;
  color: #4c351f;
  cursor: pointer;
  font-size: 9px;
  font-weight: 950;
  letter-spacing: 0.05em;
}

.mobile-mark-button--active {
  border-color: #073f42;
  background: #0b6569;
  box-shadow:
    inset 0 3px 5px rgba(0, 0, 0, 0.38),
    0 0 0 3px rgba(11, 101, 105, 0.2);
  color: #fffaf0;
  transform: translateY(2px);
}

.sound-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  padding: 0;
  border: 1px solid #8a5e2c;
  border-radius: 999px;
  background: #f6e7c8;
  box-shadow: 0 3px 0 #9b7244;
  color: #4c351f;
  cursor: pointer;
}

.sound-button:hover {
  background: #fff3d8;
}

.sound-button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #9b7244;
}

.sound-button:focus-visible {
  outline: 3px solid rgba(11, 101, 105, 0.28);
  outline-offset: 2px;
}

.sound-icon {
  width: 17px;
  height: 17px;
}

.sound-icon--off {
  display: none;
}

.sound-button[aria-pressed='true'] {
  border-color: #6e5a43;
  background: #d8cbb5;
  box-shadow: inset 0 2px 4px rgba(61, 43, 27, 0.25);
  color: #6e5a43;
}

.sound-button[aria-pressed='true'] .sound-icon--on {
  display: none;
}

.sound-button[aria-pressed='true'] .sound-icon--off {
  display: block;
}

.difficulty-selector {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 3px;
  margin: 9px auto 0;
  padding: 3px;
  border: 1px solid #b58c57;
  border-radius: 999px;
  background: #e8d2aa;
  box-shadow: inset 0 1px 2px rgba(61, 43, 27, 0.18);
  color: #8b653b;
}

.difficulty-button {
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #624426;
  cursor: pointer;
  font-size: 10px;
  font-weight: 950;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.difficulty-button:hover {
  background: rgba(255, 250, 240, 0.48);
}

.difficulty-button--active {
  background: #0b6569;
  box-shadow:
    inset 0 2px 3px rgba(0, 0, 0, 0.3),
    0 1px 0 rgba(255, 255, 255, 0.48);
  color: #fffaf0;
}

.difficulty-button--active:hover {
  background: #0b6569;
}

.difficulty-button:focus-visible {
  outline: 3px solid rgba(167, 45, 29, 0.3);
  outline-offset: 2px;
}

.board-wrap {
  padding: clamp(28px, 5vw, 38px) 22px clamp(20px, 4vw, 28px);
}

.board-stage {
  --fence-depth: clamp(9px, 2.3vw, 15px);
  position: relative;
  width: min(100%, 524px);
  margin: 0 auto;
  padding: var(--fence-depth);
  isolation: isolate;
}

.fence-frame {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.fence-rail {
  position: absolute;
  display: block;
  filter: drop-shadow(0 2px 1px rgba(51, 28, 10, 0.45));
}

.fence-rail--top,
.fence-rail--bottom {
  left: 7px;
  right: 7px;
  height: clamp(12px, 2.8vw, 18px);
  background-image: url('./fence-horizontal.png');
  background-position: center;
  background-repeat: repeat-x;
  background-size: auto 100%;
}

.fence-rail--top {
  top: 1px;
}
.fence-rail--bottom {
  bottom: 1px;
  transform: scaleY(-1);
}

.fence-rail--left,
.fence-rail--right {
  top: 7px;
  bottom: 7px;
  width: clamp(11px, 2.5vw, 16px);
  background-image: url('./fence-vertical.png');
  background-position: center;
  background-repeat: repeat-y;
  background-size: 100% auto;
}

.fence-rail--left {
  left: 1px;
}
.fence-rail--right {
  right: 1px;
  transform: scaleX(-1);
}

.fence-corner {
  position: absolute;
  z-index: 3;
  width: clamp(34px, 8vw, 48px);
  height: auto;
  filter: drop-shadow(0 2px 2px rgba(51, 28, 10, 0.45));
}

.fence-corner--tl {
  top: -3px;
  left: -4px;
  transform: scaleY(-1);
}
.fence-corner--tr {
  top: -3px;
  right: -4px;
  transform: scale(-1, -1);
}
.fence-corner--bl {
  bottom: -3px;
  left: -4px;
}
.fence-corner--br {
  right: -4px;
  bottom: -3px;
  transform: scaleX(-1);
}

.fence-crest {
  position: absolute;
  left: 50%;
  z-index: 4;
  height: auto;
  transform: translateX(-50%);
  filter: drop-shadow(0 2px 2px rgba(51, 28, 10, 0.5));
}

.fence-crest {
  top: clamp(-20px, -3vw, -12px);
  width: clamp(62px, 15vw, 88px);
}

.game-board {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: clamp(1px, 0.5vw, 3px);
  width: 100%;
  margin: 0 auto;
  padding: 2px;
  border: 0;
  border-radius: 4px;
  background: #4d3322;
  box-shadow: none;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.tile {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: clamp(2px, 0.6vw, 5px);
  background-color: transparent;
  background-image: url('./tile-covered.png');
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  box-shadow: none;
  color: #2d241a;
  cursor: pointer;
  -webkit-user-drag: none;
  font-family: var(--font-display);
  font-size: clamp(16px, 4.5vw, 23px);
  font-weight: 950;
  line-height: 1;
  text-shadow:
    0 1px 2px rgba(45, 22, 6, 0.78),
    0 0 1px rgba(255, 248, 225, 0.9);
  -webkit-text-stroke: 0.65px rgba(255, 255, 255, 0.95);
  transition:
    filter 0.12s ease,
    transform 0.1s ease,
    box-shadow 0.1s ease;
}

.board-stage[data-difficulty='medium'] {
  width: min(100%, 640px);
}

.game-board[data-difficulty='medium'] {
  grid-template-columns: repeat(12, 1fr);
  gap: clamp(1px, 0.35vw, 2px);
}

.board-stage[data-difficulty='hard'] {
  width: min(100%, 640px);
}

.game-board[data-difficulty='hard'] {
  grid-template-columns: repeat(16, 1fr);
  gap: clamp(0.5px, 0.2vw, 1.5px);
}

.game-board[data-difficulty='hard'] .tile {
  font-size: clamp(11px, 3vw, 17px);
  -webkit-text-stroke-width: 0.5px;
}

.tile:not(:disabled):hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.tile:not(:disabled):active {
  transform: translateY(2px) scale(0.97);
}
.tile:focus-visible {
  z-index: 2;
  outline: 3px solid #fffaf0;
  box-shadow: 0 0 0 5px #a72d1d;
}

.tile--revealed {
  background-image: url('./tile-revealed.png');
  cursor: default;
  animation: tile-reveal 0.14s ease-out;
}

.tile--marked {
  background-image: url('./tile-marker.png');
}
.tile--egg {
  background-image: url('./nugget.webp');
}
.tile--cracked {
  background-image: url('./smashed-nugget.webp');
}
.tile[data-number='1'] {
  color: #2d89e8;
}
.tile[data-number='2'] {
  color: #37a44a;
}
.tile[data-number='3'] {
  color: #e33b2e;
}
.tile[data-number='4'] {
  color: #ed781c;
}
.tile[data-number='5'] {
  color: #b91f32;
}
.tile[data-number='6'] {
  color: #118c8c;
}
.tile[data-number='7'] {
  color: #7952b8;
}
.tile[data-number='8'] {
  color: #292725;
}

.message-panel {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 22px;
  padding: 10px 14px;
  border: 1px solid #d3b987;
  border-radius: 11px;
  background: #f7edd9;
}
.message-panel > div {
  display: flex;
  flex-direction: column;
}
.message-panel strong {
  font-family: var(--font-display);
  font-size: 16px;
}
.message-panel span {
  color: #715f4a;
  font-size: 11px;
  margin-top: 2px;
}
.message-panel--won {
  border-color: #699267;
  background: #e6f0dd;
}
.message-panel--lost {
  border-color: #b55443;
  background: #f4ddd4;
}

.result-overlay {
  position: absolute;
  inset: var(--fence-depth);
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2vw, 13px);
  padding: clamp(8px, 2.3vw, 14px);
  border: 1px solid rgba(255, 238, 200, 0.5);
  border-radius: 6px;
  background: rgba(38, 23, 12, 0.8);
  box-shadow: inset 0 0 35px rgba(18, 10, 4, 0.55);
  backdrop-filter: blur(1.5px);
  animation: result-in 0.16s ease-out;
}

.result-art {
  display: block;
  width: min(100%, 430px);
  max-height: calc(100% - 58px);
  height: auto;
  object-fit: contain;
}

.play-again {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 20px;
  border: 1px solid #7c2117;
  border-radius: 999px;
  background: #af3422;
  box-shadow: 0 3px 0 #742116;
  color: #fffaf0;
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.play-again:hover {
  background: #c43e29;
}
.play-again:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #742116;
}

@keyframes result-in {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.controls-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 15px 22px 20px;
  color: #705c45;
  font-size: 10px;
}
.controls-hint b {
  color: #38291b;
}
.controls-hint i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #aa8656;
}

@keyframes tile-reveal {
  from {
    transform: scale(0.84);
    opacity: 0.65;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 520px) {
  .game-shell {
    padding: 0;
    place-items: start center;
  }
  .game-card {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .game-nav {
    padding: 14px 13px 0;
  }
  .game-nav a {
    min-height: 44px;
  }
  .game-header {
    padding: 12px 17px 15px;
  }
  .status-bar,
  .message-panel {
    margin-inline: 13px;
  }
  .board-wrap {
    padding: 27px 13px 20px;
  }
  .mobile-mark-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .controls-hint {
    padding: 14px 14px 19px;
    gap: 8px;
  }
}

@media (max-width: 380px) {
  .title-art {
    max-height: 96px;
  }
  .status-bar {
    gap: 7px;
    padding-inline: 9px;
  }
  .restart-button {
    width: 38px;
    padding: 0;
  }
  .restart-button span {
    display: none;
  }
  .controls-hint {
    flex-direction: column;
    gap: 3px;
  }
  .controls-hint i {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Compact onboarding inside the existing game card. */
.hunt-instructions { margin:16px 0 0; padding:clamp(16px,3vw,24px); border:1px solid var(--border); border-radius:12px; background:var(--muted); }
.hunt-instructions h2 { margin:0 0 12px; font-family:var(--font-display); font-size:24px; color:#12656a; }
.hunt-instructions ul { margin:0 0 18px; padding-left:21px; font-size:15px; line-height:1.5; }
.hunt-instructions li+li { margin-top:7px; }
.hunt-examples { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:0 0 20px; }
.hunt-examples>div { display:flex; align-items:center; gap:8px; font-size:12px; line-height:1.3; }
.hunt-examples>div:last-child { grid-column:1 / -1; }
.hunt-example-tile,.hunt-examples img { flex:0 0 40px; width:40px; height:40px; border-radius:5px; }
.hunt-example-tile { display:grid; place-items:center; background:#c09b64 url('./tile-revealed.png') center/cover; border:2px solid #7b512b; color:#11698c; font-weight:900; font-size:27px; text-shadow:0 1px #fff; }
.hunt-example-two { color:#31752e; }
.hunt-start { display:block; width:100%; min-height:52px; padding:14px; border:1px solid #742116; border-radius:999px; background:var(--primary); box-shadow:0 3px 0 #742116; color:var(--primary-foreground); font-weight:900; cursor:pointer; }
.hunt-start:hover { background:#ce452b; }
.hunt-help-row { text-align:center; margin:12px 0 0; }
#hunt-help { border:1px solid #145d62; border-radius:999px; padding:8px 16px; min-height:40px; color:#fffaf0; background:#12656a; cursor:pointer; font-weight:700; }
.hunt-start:focus-visible,#hunt-help:focus-visible { outline:3px solid #12656a; outline-offset:4px; }
@media(max-width:420px){.hunt-instructions{padding:16px 12px}.hunt-instructions ul{font-size:14px}.hunt-instructions li+li{margin-top:6px}}
