@font-face {
  font-family: "Tide Pixel";
  src: url("../../../assets/fonts/TidePixel.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0020-007E;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  min-height: -webkit-fill-available;
  min-height: 100dvh;
  background: #7ec8ea;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: #7ec8ea;
}

html:fullscreen,
html:-webkit-full-screen,
#game:fullscreen,
#game:-webkit-full-screen {
  width: 100%;
  height: 100%;
  background: #7ec8ea;
}

#game canvas {
  display: block;
}

#insets {
  position: fixed;
  inset: 0;
  pointer-events: none;
  visibility: hidden;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

#loading {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #922333;
  color: #fff6ec;
  font-family: "Segoe UI", sans-serif;
}

#loading[hidden] {
  display: none;
}

#loading p {
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: 1.4rem;
}

#ios-hint {
  position: fixed;
  z-index: 25;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  top: calc(12px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #f4efe4;
  color: #1b140f;
  border: 3px solid #1b140f;
  box-shadow: 4px 4px 0 #1b140f;
  font-family: "Segoe UI", sans-serif;
}

#ios-hint[hidden] {
  display: none;
}

#ios-hint p {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
}

#ios-hint button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 14px;
  background: #922333;
  color: #fff6ec;
  border: 3px solid #1b140f;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

#rotate {
  display: none;
}

@media (orientation: portrait) {
  #rotate {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 30;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: #922333;
    color: #fff6ec;
    text-align: center;
    font-family: "Segoe UI", sans-serif;
  }

  #rotate .rotate-card {
    max-width: 22rem;
  }

  #rotate h1 {
    margin: 0 0 0.4rem;
    font-size: 1.7rem;
  }

  #rotate p {
    margin: 0;
    font-size: 1.15rem;
  }
}

#gear {
  position: fixed;
  z-index: 26;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  padding: 0;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  left: auto;
  bottom: auto;
  background: #fff6ec;
  color: #922333;
  border: 4px solid #1b140f;
  border-radius: 16px;
  box-shadow: 4px 4px 0 #1b140f;
  cursor: pointer;
  touch-action: manipulation;
}

#gear[hidden] {
  display: none;
}

#gear.is-down,
.settings-card button.is-down {
  filter: brightness(0.86);
}

#gear svg {
  display: block;
  width: 36px;
  height: 36px;
}

#settings {
  position: fixed;
  inset: 0;
  z-index: 28;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(27, 20, 15, 0.45);
  touch-action: manipulation;
}

#settings[hidden] {
  display: none;
}

.settings-card {
  width: min(22rem, 100%);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 18px 16px 16px;
  background: #f4efe4;
  color: #1b140f;
  border: 4px solid #1b140f;
  box-shadow: 6px 6px 0 #1b140f;
  font-family: "Segoe UI", sans-serif;
}

.settings-card h2 {
  margin: 0;
  text-align: center;
  font-family: "Tide Pixel", monospace;
  font-size: 1.15rem;
  font-weight: 400;
  color: #922333;
}

.build-label {
  margin: 4px 0 10px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #5c4636;
}

.settings-card button {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  background: #f3ddb0;
  color: #1b140f;
  border: 3px solid #1b140f;
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  cursor: pointer;
  touch-action: manipulation;
}

#settings-close {
  margin-top: 14px;
  background: #922333;
  color: #fff6ec;
}

#set-full[hidden] {
  display: none;
}

.clay-overlay {
  position: fixed;
  inset: 0;
  z-index: 27;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(27, 20, 15, 0.45);
  touch-action: manipulation;
}

.clay-overlay[hidden] {
  display: none;
}

#guide.clay-overlay {
  z-index: 29;
}

.story-card,
.guide-card {
  width: min(860px, 100%);
  max-height: 100%;
  background: #f4efe4;
  color: #1b140f;
  border: 4px solid #1b140f;
  box-shadow: 6px 6px 0 #1b140f;
  font-family: "Segoe UI", sans-serif;
}

.story-card {
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.story-art {
  flex: 0 0 38%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px 0;
  background: linear-gradient(#7ec8ea 0 58%, #6eaf45 58% 100%);
  border-right: 4px solid #1b140f;
  overflow: hidden;
}

.clay-sprite {
  display: block;
  flex: 0 0 auto;
  image-rendering: auto;
}

.story-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 14px 12px;
}

.story-copy h2,
.guide-card h2,
.guide-card h3,
.guide-bird h3 {
  margin: 0;
  font-family: "Tide Pixel", monospace;
  font-weight: 400;
  color: #922333;
}

.story-copy h2 {
  font-size: clamp(15px, 3.2vh, 22px);
}

.story-copy p,
.guide-note,
.guide-bird p {
  margin: 0;
  font-weight: 700;
  line-height: 1.3;
}

.story-copy p {
  font-size: clamp(14px, 2.5vh, 18px);
}

.card-kicker {
  color: #5c4636;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.guide-trigger {
  color: #5c4636;
}

.aim-dots {
  display: none;
  gap: 8px;
  align-items: center;
  height: 16px;
}

#story.is-howto .aim-dots {
  display: flex;
}

.aim-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f0c14a;
  border: 2px solid #1b140f;
}

.story-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}

.story-nav button,
.guide-card header button {
  min-height: 48px;
  padding: 0 14px;
  background: #f3ddb0;
  color: #1b140f;
  border: 3px solid #1b140f;
  font: inherit;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
}

#story-next,
#bird-ok {
  flex: 1;
  background: #922333;
  color: #fff6ec;
}

.story-nav button.is-down,
.guide-card header button.is-down {
  filter: brightness(0.86);
}

.story-dots {
  display: flex;
  gap: 6px;
}

.story-dots span {
  width: 10px;
  height: 10px;
  border: 2px solid #1b140f;
  background: #f4efe4;
}

.story-dots span.is-on {
  background: #922333;
}

.guide-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.guide-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 4px solid #1b140f;
}

.guide-card header h2 {
  font-size: 1.05rem;
}

.guide-card header button {
  min-width: 96px;
}

.guide-body {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 12px;
  padding: 10px 12px 12px;
  overflow: auto;
}

.guide-body h3 {
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.guide-birds {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.guide-bird {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px;
  background: #f3ddb0;
  border: 3px solid #1b140f;
}

.guide-bird h3 {
  font-size: 0.72rem;
}

.guide-bird p {
  font-size: 0.78rem;
  font-weight: 700;
}

.guide-body ul {
  margin: 0 0 8px;
  padding-left: 1.1rem;
}

.guide-body li,
.guide-note {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
}

@media (max-width: 720px), (max-height: 420px) {
  .guide-body {
    grid-template-columns: 1fr;
  }

  .story-art {
    flex-basis: 34%;
  }
}
