:root {
  --ink: #10283d;
  --navy: #17324d;
  --sky: #75c9e8;
  --sea: #277da1;
  --teal: #2a9d8f;
  --green: #6a994e;
  --grass: #8abf57;
  --coral: #e85d5d;
  --rose: #f45b69;
  --gold: #f4c542;
  --cream: #fff5d6;
  --paper: #fffaf0;
  --white: #ffffff;
  --shadow: rgba(16, 40, 61, 0.35);
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
  color: var(--ink);
  background: var(--navy);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: var(--navy);
}

body {
  min-height: 100svh;
}

button {
  font: inherit;
}

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

.is-hidden {
  display: none !important;
}

.app-shell,
.screen {
  width: 100%;
  min-height: 100svh;
}

.title-screen {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(#75c9e8 0 65%, #65a84a 65% 100%);
}

.title-screen::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 16%;
  background: repeating-linear-gradient(90deg, #568d3f 0 48px, #619c47 48px 96px);
  box-shadow: inset 0 8px #3f7438;
}

.title-sky,
.title-town {
  position: absolute;
  inset: 0;
}

.pixel-sun {
  position: absolute;
  top: 9%;
  right: 11%;
  width: 72px;
  aspect-ratio: 1;
  background: var(--gold);
  box-shadow: 12px 0 #f4c542, -12px 0 #f4c542, 0 12px #f4c542, 0 -12px #f4c542;
}

.pixel-cloud {
  position: absolute;
  width: 122px;
  height: 28px;
  background: var(--white);
  box-shadow: 22px -18px var(--white), 56px -10px var(--white), 86px 4px var(--white);
  opacity: 0.92;
}

.cloud-a { top: 16%; left: 8%; }
.cloud-b { top: 30%; right: 23%; transform: scale(0.7); }

.town-house,
.town-tree {
  position: absolute;
  bottom: 13%;
  image-rendering: pixelated;
}

.town-house {
  width: 150px;
  height: 108px;
  background: #ffe6a7;
  border: 8px solid var(--ink);
  box-shadow: inset 0 -18px #edc66f;
}

.town-house::before {
  content: "";
  position: absolute;
  left: -20px;
  top: -66px;
  width: 174px;
  height: 64px;
  background: var(--coral);
  border: 8px solid var(--ink);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.town-house::after {
  content: "";
  position: absolute;
  left: 54px;
  bottom: 0;
  width: 36px;
  height: 58px;
  background: #2a9d8f;
  border: 6px solid var(--ink);
}

.house-a { left: 5%; transform: scale(0.8); }
.house-b { right: 5%; transform: scale(0.9); }
.house-c { left: 24%; transform: scale(0.58); bottom: 18%; }

.town-tree {
  width: 72px;
  height: 94px;
  background: #795548;
  border: 7px solid var(--ink);
}

.town-tree::before {
  content: "";
  position: absolute;
  width: 100px;
  height: 90px;
  left: -21px;
  top: -64px;
  background: var(--green);
  border: 7px solid var(--ink);
  border-radius: 4px;
  box-shadow: 28px -18px #6a994e, -22px -8px #7eb356;
}

.tree-a { left: 40%; transform: scale(0.72); }
.tree-b { right: 31%; transform: scale(0.62); }

.title-content {
  position: relative;
  z-index: 3;
  width: min(92vw, 660px);
  padding: 38px 26px 32px;
  text-align: center;
  background: rgba(255, 250, 240, 0.94);
  border: 6px solid var(--ink);
  border-radius: 6px;
  box-shadow: 12px 12px 0 rgba(16, 40, 61, 0.32);
}

.anniversary-mark {
  margin: 0 0 12px;
  color: #b22d48;
  font-weight: 900;
  font-size: 0.9rem;
  letter-spacing: 0;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(2.2rem, 7vw, 4.4rem);
  line-height: 1.16;
  text-shadow: 4px 4px 0 #f4c542;
}

.title-date {
  margin: 18px 0 26px;
  font-size: 1.08rem;
  font-weight: 700;
}

.pixel-button,
.icon-button,
.control-button,
.action-button {
  border: 4px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 100ms ease, box-shadow 100ms ease;
}

.pixel-button:active,
.icon-button:active,
.control-button:active,
.action-button:active,
.is-pressed {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--ink);
}

.pixel-button {
  min-height: 50px;
  padding: 10px 22px;
  font-weight: 900;
  font-size: 1rem;
}

.primary-button {
  color: var(--white);
  background: var(--rose);
}

.secondary-button {
  margin-left: 8px;
  background: var(--gold);
}

.compact-button {
  min-height: 42px;
  padding: 7px 16px;
}

.game-screen {
  display: grid;
  grid-template-rows: auto 1fr;
  background: #10283d;
}

.game-hud {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto minmax(92px, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 70px;
  padding: 10px max(14px, env(safe-area-inset-left));
  color: var(--white);
  background: var(--navy);
  border-bottom: 5px solid #0a1c2b;
}

.hud-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.hud-title strong { font-size: 1.05rem; }
.hud-title span { color: #9adce8; font-size: 0.84rem; }

.stage-badges {
  display: flex;
  gap: 8px;
}

.stage-badge {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 3px solid #8cb7c7;
  border-radius: 4px;
  color: #8cb7c7;
  font-size: 0.82rem;
  font-weight: 900;
}

.stage-badge.complete {
  color: var(--ink);
  border-color: var(--gold);
  background: var(--gold);
}

.hud-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 1.35rem;
  font-weight: 900;
}

.game-viewport {
  position: relative;
  width: min(100%, 1120px);
  margin: auto;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #79b64d;
  border-inline: 5px solid #0a1c2b;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
}

.interaction-prompt {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 8px 14px;
  color: var(--white);
  background: rgba(16, 40, 61, 0.94);
  border: 3px solid var(--white);
  border-radius: 4px;
  font-weight: 800;
}

.dialog-box {
  position: absolute;
  z-index: 8;
  left: 4%;
  right: 4%;
  bottom: 4%;
  min-height: 126px;
  padding: 18px 20px 16px;
  background: var(--paper);
  border: 5px solid var(--ink);
  border-radius: 5px;
  box-shadow: 8px 8px 0 var(--shadow);
}

.dialog-box p { margin: 0 0 12px; line-height: 1.6; }
.dialog-speaker { color: #b22d48; font-weight: 900; }

.toast {
  position: absolute;
  z-index: 12;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 90%;
  padding: 10px 16px;
  color: var(--white);
  background: var(--navy);
  border: 3px solid var(--gold);
  border-radius: 4px;
  font-weight: 800;
}

.mobile-controls {
  display: none;
}

.stage-overlay {
  position: fixed;
  z-index: 30;
  inset: 0;
  padding: 14px;
  overflow: auto;
  background: rgba(8, 24, 38, 0.88);
}

.stage-frame {
  width: min(1120px, 100%);
  min-height: calc(100svh - 28px);
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  border: 5px solid var(--ink);
  border-radius: 6px;
  box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.3);
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  color: var(--white);
  background: var(--navy);
  border-bottom: 5px solid var(--ink);
}

.stage-header h2 { margin: 2px 0 0; font-size: clamp(1.25rem, 4vw, 2rem); }
.stage-kicker { color: #9adce8; font-size: 0.8rem; font-weight: 800; }
.stage-content { padding: clamp(16px, 4vw, 34px); }

.preview-stage {
  display: grid;
  place-items: center;
  min-height: 55vh;
  text-align: center;
}

.preview-stage strong { display: block; margin-bottom: 10px; font-size: 1.5rem; }

.ending-screen {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--navy);
}

.ending-screen > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ending-shade {
  position: absolute;
  inset: 0;
  background: rgba(8, 24, 38, 0.38);
}

.ending-content {
  position: relative;
  z-index: 2;
  width: min(760px, 92vw);
  max-height: 88svh;
  overflow: auto;
  padding: 26px;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.95);
  border: 5px solid var(--ink);
  border-radius: 6px;
}

.ending-content h2 { margin: 0 0 18px; font-size: clamp(2rem, 7vw, 4rem); }
.ending-message { font-size: 1.06rem; line-height: 1.8; }

@media (max-width: 760px), (pointer: coarse) {
  .game-screen {
    grid-template-rows: auto auto 1fr;
  }

  .game-hud {
    grid-template-columns: 1fr auto;
    min-height: 64px;
  }

  .stage-badges {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: center;
  }

  .game-viewport {
    width: 100%;
    margin: 0;
    border-inline: 0;
  }

  .mobile-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    min-height: 170px;
    padding: 12px max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
    background: #10283d;
  }

  .d-pad {
    display: grid;
    grid-template: repeat(3, 48px) / repeat(3, 48px);
    gap: 4px;
  }

  .control-button,
  .action-button {
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
  }

  .control-button { padding: 0; font-size: 1rem; }
  .control-button.up { grid-column: 2; grid-row: 1; }
  .control-button.left { grid-column: 1; grid-row: 2; }
  .control-button.down { grid-column: 2; grid-row: 3; }
  .control-button.right { grid-column: 3; grid-row: 2; }

  .action-button {
    width: 78px;
    aspect-ratio: 1;
    color: var(--white);
    background: var(--rose);
    border-radius: 50%;
    font-weight: 900;
  }

  .title-content { padding: 30px 18px 24px; }
  .title-town { transform: scale(0.9); transform-origin: bottom center; }
  .secondary-button { margin: 10px 0 0; }
}

@media (max-width: 430px) {
  .town-house { transform: scale(0.55); }
  .house-a { left: -4%; }
  .house-b { right: -6%; }
  .house-c { display: none; }
  .title-date { font-size: 1rem; }
  .game-hud { padding-inline: 10px; }
  .stage-badge { width: 29px; height: 29px; }
  .mobile-controls { min-height: 154px; }
  .d-pad { grid-template: repeat(3, 44px) / repeat(3, 44px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

.title-character {
  position: absolute;
  z-index: 2;
  bottom: -6%;
  width: min(28vw, 360px);
  height: min(72vh, 720px);
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(10px 12px 0 rgba(16, 40, 61, 0.24));
  pointer-events: none;
}

.title-anita {
  left: 1%;
}

.title-ray {
  right: 1%;
}

.stage-notice {
  position: fixed;
  z-index: 70;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 24, 38, 0.72);
}

.stage-notice-box {
  width: min(520px, 94vw);
  padding: 28px;
  text-align: center;
  background: var(--paper);
  border: 5px solid var(--ink);
  border-radius: 6px;
  box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.3);
}

.stage-notice-box h3 {
  margin: 0 0 12px;
  color: #b22d48;
  font-size: clamp(1.55rem, 5vw, 2.35rem);
}

.stage-notice-box p {
  margin: 0 0 22px;
  font-size: 1.02rem;
  line-height: 1.7;
}

.stage-feedback {
  min-height: 48px;
  margin: 14px 0;
  padding: 10px 12px;
  line-height: 1.55;
  background: #e5f4ef;
  border-left: 6px solid var(--teal);
}

.stage-feedback.error {
  background: #fde7e4;
  border-color: var(--coral);
}

.gallery-stage-content {
  padding: 14px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0 4px, transparent 4px 32px),
    #825f48;
}

.gallery-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
  padding: 10px 14px;
  color: #f8f0df;
  background: #273f4f;
  border: 4px solid var(--ink);
  border-radius: 4px;
  box-shadow: inset 0 0 0 3px #b88b4f;
}

.gallery-toolbar div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.gallery-toolbar span {
  color: #ffd96b;
  font-size: 0.88rem;
  font-weight: 700;
}

.gallery-toolbar p {
  max-width: 520px;
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

.gallery-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 960 / 520;
  overflow: hidden;
  border: 5px solid var(--ink);
  background: #d9d4c6;
  box-shadow: 0 8px 0 #5b4335;
}

#galleryCanvas,
#fishingCanvas,
#potteryCanvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.gallery-prompt {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  width: max-content;
  max-width: 90%;
  padding: 7px 12px;
  color: var(--white);
  background: rgba(16, 40, 61, 0.9);
  border: 3px solid var(--white);
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
}

.stage-mobile-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin-top: 12px;
}

.mini-dpad {
  display: none;
  grid-template: repeat(3, 42px) / repeat(3, 42px);
  gap: 3px;
}

.mini-dpad button,
.reel-buttons button {
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 4px;
  box-shadow: 0 4px 0 var(--ink);
  font-weight: 900;
  touch-action: none;
}

.mini-dpad button[data-stage-direction="up"] { grid-column: 2; grid-row: 1; }
.mini-dpad button[data-stage-direction="left"] { grid-column: 1; grid-row: 2; }
.mini-dpad button[data-stage-direction="down"] { grid-column: 2; grid-row: 3; }
.mini-dpad button[data-stage-direction="right"] { grid-column: 3; grid-row: 2; }

.tag-chooser {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 24, 38, 0.75);
}

.tag-chooser-box {
  width: min(860px, 96vw);
  max-height: 88svh;
  overflow: auto;
  padding: 20px;
  background: #f1dfb8;
  border: 5px solid var(--ink);
  border-radius: 5px;
}

.tag-chooser-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.tag-chooser-heading h3 {
  margin: 0;
  font-size: 1.45rem;
}

.tag-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.name-tag {
  min-height: 54px;
  padding: 9px 12px;
  color: var(--ink);
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 3px;
  box-shadow: 0 4px 0 #8d704a;
  font-weight: 800;
  cursor: pointer;
}

.name-tag:hover:not(:disabled),
.name-tag:focus-visible {
  background: #fff0ae;
}

.name-tag.is-solved {
  color: #647078;
  background: #d7d8d2;
  border-color: #7c868d;
  box-shadow: none;
}

.pottery-stage {
  background:
    linear-gradient(rgba(255,255,255,0.08), rgba(255,255,255,0)),
    repeating-linear-gradient(90deg, #bb7c55 0 42px, #ad704c 42px 45px);
}

.shop-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 10px 16px;
  color: var(--paper);
  background: #17324d;
  border: 4px solid var(--ink);
  box-shadow: 0 6px 0 rgba(16, 40, 61, 0.32);
}

.shop-banner > div {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.shop-banner span,
.workbench-heading span {
  color: #f4c542;
  font-size: 0.7rem;
  font-weight: 900;
}

.shop-banner strong {
  font-size: 1.25rem;
}

.shop-banner p {
  margin: 0;
  font-weight: 900;
}

.tea-banner {
  color: #f6f0dc;
  background: #24514a;
  box-shadow: inset 0 -6px rgba(0, 0, 0, 0.14), 0 6px 0 rgba(16, 40, 61, 0.28);
}

.pottery-layout {
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.customer-order {
  position: sticky;
  top: 14px;
  min-width: 0;
}

.customer-scene {
  position: relative;
  min-height: 300px;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, transparent 0 38px, rgba(83, 50, 35, 0.18) 38px 41px),
    #c58c60;
  border: 5px solid var(--ink);
  box-shadow: inset 0 -46px #77513a, 7px 7px 0 rgba(16, 40, 61, 0.28);
}

.studio-window {
  position: absolute;
  top: 22px;
  left: 18px;
  width: 94px;
  height: 76px;
  background: #75c9e8;
  border: 5px solid var(--ink);
  box-shadow: inset 0 -21px #73a85a;
}

.studio-window::before,
.studio-window::after {
  content: "";
  position: absolute;
  background: var(--ink);
}

.studio-window::before { inset: 0 41px; width: 5px; }
.studio-window::after { inset: 33px 0; height: 5px; }

.studio-window span {
  position: absolute;
  right: -120px;
  bottom: -170px;
  width: 80px;
  height: 185px;
  background: #8f6847;
  border: 5px solid var(--ink);
}

.studio-window span + span {
  right: -182px;
  bottom: -170px;
  width: 46px;
  height: 144px;
}

.friend-portrait {
  position: relative;
  z-index: 2;
  width: min(210px, 72%);
  aspect-ratio: 1;
  margin: 34px auto 0;
  overflow: hidden;
  background: #d8ad73;
  border: 0;
  border-radius: 0;
  filter: drop-shadow(6px 6px 0 rgba(16, 40, 61, 0.35));
}

.friend-portrait img {
  position: absolute;
  width: 200%;
  height: 200%;
  max-width: none;
  object-fit: contain;
  image-rendering: pixelated;
}

.friend-portrait.nelson img { left: 0; top: 0; }
.friend-portrait.kenji img { left: -100%; top: 0; }
.friend-portrait.ruby img { left: 0; top: -100%; }
.friend-portrait.jen img { left: -100%; top: -100%; }

.customer-nameplate {
  position: absolute;
  z-index: 4;
  right: 12px;
  bottom: 13px;
  min-width: 132px;
  padding: 7px 10px;
  color: var(--paper);
  background: #17324d;
  border: 3px solid #f4c542;
  text-align: center;
}

.customer-nameplate span {
  display: block;
  color: #f4c542;
  font-size: 0.66rem;
  font-weight: 900;
}

.customer-nameplate strong {
  font-size: 1.25rem;
}

.order-scroll {
  position: relative;
  margin: 16px 9px 0;
  padding: 13px 16px 16px;
  background: #fff3d3;
  border: 4px solid var(--ink);
  box-shadow: 7px 7px 0 rgba(16, 40, 61, 0.24);
}

.order-scroll::before,
.order-scroll::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  height: 4px;
  background: #c48a55;
}

.order-scroll::before { top: -7px; }
.order-scroll::after { bottom: -7px; }

.order-count {
  margin: 14px 0 4px;
  color: #8e3548;
  font-size: 0.86rem;
  font-weight: 900;
}

.customer-order blockquote {
  margin: 7px 0 12px;
  padding: 10px 12px;
  line-height: 1.65;
  background: rgba(255,255,255,0.48);
  border-left: 6px solid var(--coral);
}

.order-spec {
  display: grid;
  gap: 7px;
  margin: 0;
}

.order-spec div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 6px;
  border-bottom: 2px solid rgba(16, 40, 61, 0.18);
}

.order-spec dt {
  font-weight: 900;
}

.order-spec dd {
  margin: 0;
  text-align: right;
}

.pottery-workbench {
  min-width: 0;
  padding: 12px;
  background: #e9c28f;
  border: 5px solid var(--ink);
  box-shadow: 8px 8px 0 rgba(16, 40, 61, 0.3);
}

.workbench-heading,
.tea-counter-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: -12px -12px 12px;
  padding: 9px 12px;
  color: var(--paper);
  background: #704a32;
  border-bottom: 4px solid var(--ink);
}

.workbench-heading > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.workbench-heading p,
.tea-counter-heading strong {
  margin: 0;
  font-size: 0.78rem;
}

.workbench-heading strong {
  font-size: 1.05rem;
}

#potteryCanvas {
  aspect-ratio: 520 / 330;
  border: 5px solid var(--ink);
  box-shadow: 0 6px 0 #704a32;
}

.pottery-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.pottery-controls .craft-step {
  margin: 0;
  padding: 10px;
  background: #fff3d3;
  border: 3px solid var(--ink);
}

.pottery-controls .stage-feedback,
.pottery-controls .wide-button {
  grid-column: 1 / -1;
}

fieldset {
  min-width: 0;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 8px;
  font-weight: 900;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.segmented-control button,
.tea-tin {
  min-height: 46px;
  padding: 7px 8px;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 3px;
  font-weight: 800;
  cursor: pointer;
}

.segmented-control button.is-selected,
.tea-tin.is-selected {
  color: var(--white);
  background: var(--teal);
  box-shadow: inset 0 -5px rgba(0, 0, 0, 0.12);
}

.range-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 16px;
}

.range-row label {
  display: grid;
  gap: 6px;
  font-weight: 900;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--coral);
}

.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-swatch {
  width: 46px;
  height: 46px;
  padding: 0;
  background: var(--swatch);
  border: 4px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
}

.color-swatch.is-selected {
  outline: 5px solid var(--gold);
  outline-offset: 2px;
}

.wide-button {
  width: 100%;
}

.tea-stage {
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.05) 0 5px, transparent 5px 42px),
    #54785f;
}

.tea-layout {
  display: grid;
  grid-template-columns: minmax(250px, 330px) minmax(0, 1fr);
  gap: 20px;
}

.tea-orders {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 12px;
  background: #d7c59f;
  border: 5px solid var(--ink);
  box-shadow: 8px 8px 0 rgba(16, 40, 61, 0.28);
}

.tea-room-scene {
  position: relative;
  min-height: 155px;
  overflow: hidden;
  background:
    linear-gradient(90deg, transparent 48%, #2f564a 48% 52%, transparent 52%),
    linear-gradient(transparent 47%, #2f564a 47% 53%, transparent 53%),
    #b7d6c3;
  border: 4px solid var(--ink);
  box-shadow: inset 0 -38px #92704d;
}

.tea-window {
  position: absolute;
  top: 18px;
  left: 50%;
  width: 118px;
  height: 72px;
  transform: translateX(-50%);
  background: #dcebd1;
  border: 5px solid #315449;
  box-shadow: inset 0 -19px #84a86f;
}

.tea-lantern {
  position: absolute;
  top: 18px;
  width: 24px;
  height: 42px;
  background: #e75b4b;
  border: 4px solid var(--ink);
  box-shadow: inset 0 7px #f4c542, inset 0 -7px #b53a3a;
}

.tea-lantern::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 8px;
  width: 3px;
  height: 12px;
  background: var(--ink);
}

.lantern-left { left: 20px; }
.lantern-right { right: 20px; }

.tea-table {
  position: absolute;
  left: 50%;
  bottom: 13px;
  width: 122px;
  height: 18px;
  transform: translateX(-50%);
  background: #6e4b32;
  border: 4px solid var(--ink);
  box-shadow: -42px 19px 0 -35px var(--ink), 42px 19px 0 -35px var(--ink);
}

.tea-ticket {
  padding: 12px;
  background: #fff3d3;
  border: 4px solid #78917a;
  border-radius: 4px;
  opacity: 0.68;
}

.tea-ticket.active {
  border-color: var(--ink);
  box-shadow: 7px 7px 0 rgba(16, 40, 61, 0.18);
  opacity: 1;
}

.tea-ticket.done {
  background: #cfe8cf;
  opacity: 1;
}

.tea-ticket p {
  margin: 5px 0 0;
  line-height: 1.6;
}

.tea-customer-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.tea-customer-sprite {
  position: relative;
  width: 48px;
  height: 56px;
  background: #537b68;
  border: 3px solid var(--ink);
  box-shadow: inset 0 -16px #36594d;
}

.tea-customer-sprite::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 13px;
  width: 17px;
  height: 17px;
  background: #dca57f;
  border: 3px solid var(--ink);
  box-shadow: 0 -6px 0 #3b2d2a;
}

.tea-customer-sprite i {
  position: absolute;
  bottom: 7px;
  left: 10px;
  width: 24px;
  height: 19px;
  background: #e4b84d;
  border: 3px solid var(--ink);
}

.tea-customer {
  color: #8e3548;
  font-weight: 900;
}

.tea-counter {
  min-width: 0;
  padding: 12px;
  background: #bd8a58;
  border: 5px solid var(--ink);
  box-shadow: 8px 8px 0 rgba(16, 40, 61, 0.28);
}

.tea-counter-heading {
  margin-bottom: 0;
  background: #315449;
}

.tea-counter-heading span {
  color: #f4c542;
  font-weight: 900;
}

.tea-shelf-decor {
  display: flex;
  align-items: end;
  justify-content: space-around;
  min-height: 64px;
  margin: 0 0 12px;
  padding: 10px 18px 8px;
  background: #8d613f;
  border: 3px solid var(--ink);
  border-top: 0;
}

.tea-shelf-decor span {
  width: 36px;
  height: 38px;
  background: var(--tea-color);
  border: 3px solid var(--ink);
  box-shadow: inset 0 6px rgba(255,255,255,0.3), 0 -6px 0 -2px var(--ink);
}

.tea-step {
  padding: 10px;
  background: #f6efd9;
  border: 3px solid var(--ink);
}

.tea-tins {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tea-tin {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  background: #fff3d3;
  box-shadow: inset 0 -5px rgba(16,40,61,0.1);
}

.tea-tin > span {
  width: 24px;
  height: 28px;
  flex: 0 0 auto;
  background: var(--tea-color);
  border: 2px solid var(--ink);
  border-radius: 1px;
  box-shadow: inset 0 5px rgba(255,255,255,0.35);
}

.brew-station {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  margin: 22px 0 12px;
  padding: 18px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.08) 0 12px, transparent 12px 24px),
    #9fc6b5;
  border: 4px solid var(--ink);
}

.teapot-visual {
  position: relative;
  width: 140px;
  height: 110px;
}

.pot-body {
  position: absolute;
  left: 28px;
  bottom: 4px;
  width: 84px;
  height: 62px;
  background: #b4483c;
  border: 5px solid var(--ink);
  border-radius: 4px 4px 34px 34px;
}

.pot-body::before {
  content: "";
  position: absolute;
  right: -37px;
  top: 5px;
  width: 34px;
  height: 24px;
  border: 6px solid var(--ink);
  border-left: 0;
  transform: skewY(-18deg);
}

.pot-body::after {
  content: "";
  position: absolute;
  left: -35px;
  top: 9px;
  width: 32px;
  height: 39px;
  border: 6px solid var(--ink);
  border-right: 0;
  border-radius: 22px 0 0 22px;
}

.pot-lid {
  position: absolute;
  z-index: 2;
  left: 47px;
  top: 30px;
  width: 48px;
  height: 15px;
  background: #d46655;
  border: 5px solid var(--ink);
}

.steam {
  position: absolute;
  top: 0;
  width: 6px;
  height: 25px;
  background: rgba(255, 255, 255, 0.78);
}

.steam-one { left: 54px; }
.steam-two { left: 82px; top: 6px; }

.brew-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-weight: 800;
}

.brew-meter {
  position: relative;
  height: 30px;
  overflow: hidden;
  background: var(--paper);
  border: 4px solid var(--ink);
}

.target-zone {
  position: absolute;
  inset-block: 0;
  background: rgba(244, 197, 66, 0.65);
}

.brew-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: rgba(42, 157, 143, 0.48);
}

.brew-needle {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 6px;
  background: var(--coral);
  transform: translateX(-3px);
}

.brew-meter-wrap p {
  margin: 8px 0 0;
  font-size: 0.86rem;
}

.tea-actions {
  display: flex;
  gap: 10px;
}

.tea-actions .pixel-button {
  flex: 1;
  margin: 0;
}

.tea-actions button:disabled,
.fishing-controls button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.fishing-stage {
  padding: 16px;
  background: #1e536f;
}

.fishing-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
  padding: 12px 14px;
  background: var(--paper);
  border: 4px solid var(--ink);
}

.fishing-hud p {
  margin: 0;
  text-align: right;
}

.caught-fish {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.caught-fish span {
  padding: 3px 7px;
  color: var(--white);
  background: var(--sea);
  border: 2px solid var(--ink);
  border-radius: 3px;
  font-size: 0.8rem;
  font-weight: 800;
}

.caught-fish .empty-catch {
  color: #5d6870;
  background: #e3e5df;
}

#fishingCanvas {
  aspect-ratio: 960 / 500;
  border: 5px solid var(--ink);
}

.fishing-controls {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 12px;
}

.reel-buttons {
  display: flex;
  gap: 8px;
}

.reel-buttons button {
  min-width: 108px;
  padding: 8px 12px;
  font-size: 1rem;
}

.ending-sprites {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  min-height: 160px;
}

.ending-sprites img {
  width: 115px;
  height: 170px;
  object-fit: contain;
  image-rendering: pixelated;
}

.ending-sprites span {
  align-self: center;
  color: var(--rose);
  font-size: 2rem;
}

.ending-love {
  color: #b22d48;
  font-size: 1.35rem;
  font-weight: 900;
}

.ending-final-line {
  margin-top: 22px;
  padding-top: 16px;
  color: var(--navy);
  border-top: 3px solid var(--gold);
  font-weight: 900;
}

@media (max-width: 900px) {
  .title-character {
    bottom: 8%;
    width: 38vw;
    height: 48vh;
    opacity: 0.58;
  }

  .title-anita { left: -4%; }
  .title-ray { right: -4%; }

  .pottery-layout,
  .tea-layout {
    grid-template-columns: 1fr;
  }

  .customer-order {
    position: static;
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    gap: 4px 16px;
    align-items: start;
  }

  .customer-scene {
    min-height: 280px;
  }

  .customer-order blockquote {
    margin-top: 6px;
  }

  .tea-orders {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tea-orders .order-count {
    grid-column: 1 / -1;
  }

  .tea-room-scene {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px), (pointer: coarse) {
  .gallery-toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .gallery-toolbar p {
    font-size: 0.82rem;
  }

  .mini-dpad {
    display: grid;
  }

  .tag-grid,
  .range-row,
  .tea-orders {
    grid-template-columns: 1fr;
  }

  .customer-order {
    grid-template-columns: 1fr;
  }

  .customer-scene {
    min-height: 260px;
  }

  .friend-portrait {
    width: 176px;
  }

  .pottery-controls {
    grid-template-columns: 1fr;
  }

  .pottery-controls .craft-step,
  .pottery-controls .stage-feedback,
  .pottery-controls .wide-button {
    grid-column: 1;
  }

  .shop-banner,
  .workbench-heading,
  .tea-counter-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .workbench-heading > div,
  .shop-banner > div {
    flex-wrap: wrap;
  }

  .segmented-control,
  .tea-tins {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .brew-station {
    grid-template-columns: 1fr;
  }

  .teapot-visual {
    margin: auto;
  }

  .fishing-hud {
    align-items: flex-start;
    flex-direction: column;
  }

  .fishing-hud p {
    text-align: left;
  }

  .fishing-controls {
    align-items: center;
    flex-direction: column;
  }

  .reel-buttons {
    width: 100%;
  }

  .reel-buttons button {
    flex: 1;
    min-height: 48px;
  }
}

@media (max-width: 450px) {
  .stage-overlay {
    padding: 0;
  }

  .stage-frame {
    min-height: 100svh;
    border: 0;
    border-radius: 0;
  }

  .stage-header {
    position: sticky;
    z-index: 20;
    top: 0;
  }

  .gallery-stage-content,
  .fishing-stage {
    padding: 8px;
  }

  .gallery-prompt {
    bottom: 5px;
    padding: 5px 8px;
    font-size: 0.76rem;
  }

  .customer-order {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .customer-order blockquote {
    padding: 10px;
    font-size: 0.9rem;
  }

  .pottery-stage,
  .tea-stage {
    padding: 14px;
  }

  .tea-actions {
    flex-direction: column;
  }

  .ending-content {
    padding: 20px 16px;
  }
}
