:root {
  --paper: #f3ecdf;
  --paper-deep: #e6d9c4;
  --sheet: #f7f1e6;
  --ink: #241c16;
  --muted: #6e5b4c;
  --line: #ddcfba;
  --card: rgba(255, 250, 243, 0.86);
  --orange: #e36a2e;
  --orange-deep: #b44816;
  --blue: #2c6e90;
  --shadow: 0 14px 34px rgba(62, 38, 16, 0.08);
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", "Songti SC", "Noto Serif SC", "Source Han Serif SC", serif;
  --sans: "Avenir Next", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.02rem;
  line-height: 1.5;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(70, 46, 24, 0.045) 0.7px, transparent 0.75px);
  background-size: 7px 7px;
}

body.mode-play {
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

img {
  max-width: 100%;
  height: auto;
}

button, input { font: inherit; color: inherit; }

a { color: var(--blue); }

:focus { outline: none; }

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

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 40;
  background: #fffaf3;
  color: var(--ink);
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
}

.skip:focus { top: 0.6rem; }

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.75rem 1rem;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(80, 52, 30, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: inherit;
  text-decoration: none;
  margin-right: auto;
}

.brand-mark {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 0.8rem;
  background: var(--sheet);
  box-shadow: inset 0 0 0 1px rgba(80, 52, 30, 0.08);
}

.brand-name {
  display: block;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1;
}

.brand-domain {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.nav { display: flex; gap: 0.35rem; }

.nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 0.95rem;
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
}

.nav a[aria-current="page"] {
  background: var(--ink);
  color: var(--paper);
}

.mute {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0 0.8rem;
  border: 1px solid rgba(80, 52, 30, 0.16);
  border-radius: 999px;
  background: var(--card);
  cursor: pointer;
}

.mute .icon-off { display: none; }
.mute[aria-pressed="true"] .icon-on { display: none; }
.mute[aria-pressed="true"] .icon-off { display: inline; }

.wrap {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.4rem 0 2.5rem;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
}

h1, h2 { font-family: var(--serif); font-weight: 650; letter-spacing: -0.03em; }

h1 { font-size: clamp(2.4rem, 6vw, 4.4rem); line-height: 0.95; margin: 0.15rem 0; }

.eyebrow {
  margin: 0;
  color: var(--orange-deep);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lede { margin: 0.35rem 0 0; max-width: 38rem; color: var(--muted); }
.target-line { display: flex; align-items: center; gap: 0.6rem; }
.target-ref { width: 3rem; height: 3rem; object-fit: contain; }

.stamp {
  flex: none;
  width: 5.4rem;
  height: 5.4rem;
  margin: 0;
  display: grid;
  place-items: center;
  align-content: center;
  border: 2px solid var(--orange);
  color: var(--orange-deep);
  border-radius: 50%;
  transform: rotate(8deg);
  font-family: var(--serif);
  line-height: 1;
  text-align: center;
}

.stamp span { font-size: 1.6rem; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin: 1rem 0;
}

.search { flex: 1 1 14rem; }

.search input {
  width: 100%;
  min-height: 44px;
  padding: 0 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(80, 52, 30, 0.16);
  background: var(--card);
}

.filters { display: flex; gap: 0.35rem; }

.filters button, .primary {
  min-height: 44px;
  padding: 0 0.95rem;
  border-radius: 999px;
  border: 1px solid rgba(80, 52, 30, 0.16);
  background: transparent;
  cursor: pointer;
}

.filters button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.count {
  margin: 0 0 0 auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.status { color: var(--muted); }

.grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 0.85rem;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  height: 100%;
  padding: 0.45rem 0.45rem 0.7rem;
  border-radius: 1.15rem;
  background: var(--card);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow);
  border: 1px solid rgba(80, 52, 30, 0.06);
}

.card img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  background:
    radial-gradient(circle at 50% 45%, rgb(255 250 243 / 0.9), rgb(243 236 223 / 0.2) 70%);
}

.card:hover { transform: translateY(-2px); }

.cap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.35rem;
  align-items: baseline;
  padding: 0 0.25rem;
  font-size: 0.86rem;
}

.num { font-variant-numeric: tabular-nums; color: var(--muted); }

.cap i {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 450;
}

.badge {
  margin-left: auto;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: #d9ebf4;
  color: var(--blue);
  font-size: 0.72rem;
}

.foot {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 0.5rem 0 2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.foot p { margin: 0.3rem 0; }

body.mode-play .foot { display: none; }

body.mode-play #content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#play-view {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  width: min(1280px, calc(100% - 1.2rem));
  margin: 0 auto;
  padding: 0.8rem 0 0.8rem;
  min-height: 0;
}

body.mode-play #play-view { flex: 1; }

#gallery-view[hidden],
#play-view[hidden],
.win[hidden],
.stage-status[hidden],
#gallery-empty[hidden] {
  display: none !important;
}

.play-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.7rem 1rem;
  align-items: end;
}

.play-head h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); }

.play-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.meters {
  display: flex;
  gap: 0.8rem;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.primary {
  background: var(--orange);
  color: #fffaf3;
  border-color: transparent;
  font-weight: 650;
}

.primary:hover { background: var(--orange-deep); }

.stage {
  position: relative;
  flex: 1;
  min-height: 16rem;
  border-radius: 1.4rem;
  overflow: hidden;
  background: var(--sheet);
  box-shadow: inset 0 0 0 1px rgba(80, 52, 30, 0.08), var(--shadow);
  touch-action: none;
}

.stage canvas,
.play-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.stage-status {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 1rem;
  text-align: center;
  pointer-events: none;
}

.win {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 0.9rem;
  transform: translateX(-50%);
  width: min(22rem, calc(100% - 1.4rem));
  padding: 0.95rem 1rem 1rem;
  border-radius: 1.15rem;
  background: rgba(255, 250, 243, 0.95);
  box-shadow: var(--shadow);
  text-align: center;
}

.win h2 { margin: 0.1rem 0 0.35rem; font-size: 1.7rem; }

.win p { margin: 0.2rem 0 0.8rem; }

.door {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.door-card {
  width: min(28rem, 100%);
  padding: 1.4rem 1.3rem 1.2rem;
  border-radius: 1.3rem;
  background: var(--card);
  box-shadow: var(--shadow);
}

.pswp {
  --pswp-bg: #f3ecdf;
  --pswp-placeholder-bg: #e7dcc8;
  --pswp-icon-color: #241c16;
  --pswp-icon-color-secondary: #6e5b4c;
}

.pswp__bg { background: #f3ecdf !important; }

.pswp__top-bar {
  background: linear-gradient(#f3ecdf, rgb(243 236 223 / 0)) !important;
}

.pswp__button,
.pswp__counter,
.pswp__preloader { color: #241c16; text-shadow: none; }

.pswp-caption {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  max-width: min(36rem, calc(100% - 2rem));
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: rgb(255 250 243 / 0.94);
  color: #241c16;
  text-align: center;
}

.stage button:focus-visible {
  outline: 3px solid var(--orange) !important;
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .count { margin-left: 0; }
  .stamp { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
  .top {
    flex-wrap: nowrap;
    gap: 0.35rem;
    padding: 0.55rem 0.65rem;
  }
  .brand { margin-right: 0; gap: 0.45rem; }
  .brand-mark { width: 2.2rem; height: 2.2rem; }
  .brand-name { font-size: 1.02rem; }
  .brand-domain { font-size: 0.72rem; }
  .nav { margin-left: auto; gap: 0.1rem; }
  .nav a { padding: 0 0.55rem; font-size: 0.92rem; }
  .mute { padding: 0 0.55rem; }
  .mute-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
}

@media (max-height: 620px) {
  body.mode-play { overflow: auto; }
  .stage { min-height: 18rem; }
}

/* Phones and touch screens: the play view scrolls like a normal page.
   The stage gets a fixed height instead of filling a locked 100dvh body,
   and vertical swipes on the canvas scroll the page (taps still pick). */
@media (max-width: 760px), (pointer: coarse) {
  body.mode-play {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    overflow-x: hidden;
  }
  body.mode-play #content,
  body.mode-play #play-view { flex: none; }
  body.mode-play .foot { display: block; }
  body.mode-play .stage {
    flex: none;
    height: min(72dvh, 40rem);
    min-height: 20rem;
  }
  .stage,
  .stage canvas,
  .play-canvas { touch-action: pan-y !important; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card:hover { transform: none; }
  .stamp { transform: none; }
}
