:root {
  --cream: #fff6eb;
  --jam: #d64545;
  --gold: #f4b942;
  --bread: #e8a838;
  --ink: #3b2a1a;
  --ink-soft: #5c4633;
  --white: #fffcf7;
  --cookie-dark: #8b4e1f;
  --font-display: "Fredoka", "Trebuchet MS", sans-serif;
  --font-body: "Nunito", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #1a120c;
  font-family: var(--font-body);
  color: var(--ink);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#sq-open {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #1a120c;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#sq-open.is-off {
  display: none !important;
}

.sq-studio {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  text-decoration: none;
  color: var(--cream);
  background: rgba(59, 42, 26, 0.78);
  border: 2px solid var(--bread);
  padding: 4px 10px 4px 4px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
}

.sq-studio svg {
  display: block;
  width: 22px;
  height: 22px;
}

/* The opening story: title + forage copy, then Arny, then how-to-play,
   as a swipeable wood-card carousel. Each card auto-advances after ten
   seconds (the last one waits for Play instead) and a tap or swipe
   moves early. */
.carousel-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.carousel {
  width: min(36rem, calc(100% - 2rem));
  overflow: hidden;
}

.carousel-track {
  display: flex;
  align-items: stretch;
  width: 300%;
  transition: transform 0.6s cubic-bezier(0.3, 0.1, 0.2, 1);
  touch-action: pan-y;
}

.carousel-track .slide {
  flex: 0 0 33.333%;
  width: 33.333%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.carousel-dots {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 242, 216, 0.35);
}

.dot.is-active {
  background: #fff2d8;
}

.lore-punch {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: #fff2d8;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.card {
  width: min(36rem, calc(100% - 2rem));
  /* No border/border-radius/box-shadow here on purpose - the plank art
     already draws its own jagged outline, so a CSS rectangle border and
     radius on top of it just doubled up into a "box around a box" look.
     Let the plank's own silhouette be the only edge, with a drop-shadow
     (which follows alpha, unlike box-shadow) hugging that same shape. */
  background-color: transparent;
  background-image: url(../assets/panel-wood-large.png);
  background-size: 100% 100%;
  background-position: center;
  border: none;
  padding: 2.25rem 1.75rem 2rem;
  text-align: center;
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.45));
}

.eyebrow {
  display: inline-block;
  align-self: center;
  margin: 0 0 0.75rem;
  padding: 0.3rem 0.8rem;
  background: #d4b08a;
  color: #3b2a1a;
  text-shadow: none;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.95rem;
}

h1,
h2 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: #fff2d8;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.55);
}

h1 {
  font-size: clamp(2.1rem, 8vw, 3.2rem);
}

h2 {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
}

p {
  margin: 0 0 0.75rem;
  color: #fff2d8;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.lead {
  font-size: 1.15rem;
  color: #fff2d8;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.25rem;
  min-width: 44px;
  margin-top: 0.5rem;
  padding: 0.7rem 1.75rem;
  border: none;
  /* <button> has an opaque UA background by default (shows as a stark white
     box behind the plank art, squaring it off) - kill it outright so only
     the plank's own jagged silhouette (and its drop-shadow below) shows. */
  background-color: transparent;
  background-image: url(../assets/btn-wood-light.png);
  background-size: 100% 100%;
  background-position: center;
  text-decoration: none;
  font-weight: 800;
  font-family: inherit;
  font-size: 1.1rem;
  color: #4a2c0f;
  cursor: pointer;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
}

.btn:hover,
.btn:focus-visible {
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35)) brightness(1.08);
  color: #4a2c0f;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

#game-wrap {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#game {
  display: block;
  width: min(100vw - 16px, calc((100dvh - 96px) * 1280 / 720), 1280px);
  height: auto;
  max-height: calc(100dvh - 96px);
  background: #f6dcc4;
  border: 4px solid #3b2a1a;
  border-radius: 12px;
}

#hud {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  z-index: 5;
  pointer-events: none;
  max-width: min(70vw, 640px);
}

.hud-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 4px 12px;
  background-image: url(../assets/wood-coin.png);
  background-size: cover;
  background-position: center;
  border: 3px solid #2a1c10;
  border-radius: 14px;
  font-weight: 800;
  font-size: 1rem;
  color: #fff2d8;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.hud-chip img {
  width: 22px;
  height: 22px;
}

.hud-chip.hearts {
  gap: 2px;
  padding: 4px 8px;
}

.heart {
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
  transition: filter 0.2s ease, opacity 0.2s ease;
}

.heart.lost {
  filter: grayscale(1) brightness(0.6);
  opacity: 0.55;
}

#touch {
  flex: none;
  width: min(100%, 1280px);
  display: none;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px 4px;
}

body.touch-on #touch {
  display: flex;
}

#touch button {
  min-width: 88px;
  min-height: 52px;
  border-radius: 16px;
  border: 3px solid var(--cookie-dark);
  background: var(--gold);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  cursor: pointer;
}

#end {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(26, 18, 12, 0.45);
  z-index: 8;
}

#end.is-on {
  display: flex;
}

.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;
}
