@font-face {
  font-family: "CampaignRoundedHeavy";
  src: url("./emfont-subset.woff2") format("woff2");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --color-blue-primary: #007aff;
  --color-pink-primary: #ff6b9d;
  --color-yellow-primary: #ffd54f;
  --color-mint-secondary: #5ed9b5;
  --color-orange-secondary: #ff8a3d;
  --color-bg-pink-soft: #fff4f8;
  --color-bg-yellow-soft: #fff8d9;
  --color-bg-blue-soft: #eef7ff;
  --color-bg-mint-soft: #effff6;
  --color-ink-strong: #1f1f1f;
  --color-ink-body: #2c2c2c;
  --color-surface-white: #ffffff;
  --border-width-strong: 4px;
  --border-width-small: 3px;
  --radius-sm: 16px;
  --radius-md: 24px;
  --radius-pill: 999px;
  --font-display: "CampaignRoundedHeavy", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  --font-body: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--color-ink-strong);
  background: var(--color-bg-pink-soft);
  font-family: var(--font-body);
}

button,
input,
a {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.desktop-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.desktop-gate-card {
  width: min(460px, 100%);
  padding: 34px;
  border: var(--border-width-strong) solid var(--color-ink-strong);
  border-radius: 32px;
  background: var(--color-surface-white);
  text-align: center;
}

.desktop-gate-card h1 {
  margin: 18px 0 12px;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.05;
}

.desktop-gate-card img {
  width: min(260px, 80vw);
  margin-top: 18px;
  background: var(--color-surface-white);
}

.app-shell {
  width: min(560px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 10px 14px 14px;
}

.app-header {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  text-align: center;
}

.logo-bar {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 34px;
  padding: 5px 0;
  border-radius: 0;
  background: var(--color-pink-primary);
}

.brand-logo {
  width: min(112px, 36vw);
  max-height: 34px;
  height: auto;
  display: block;
  object-fit: contain;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.title-card {
  position: relative;
  display: grid;
  justify-items: center;
  padding: 14px 36px 17px;
  border: 0;
  border-radius: 20px;
  background: var(--color-surface-white);
}

.app-shell[data-screen="guide"] .title-card,
.app-shell[data-screen="game"] .title-card,
.app-shell[data-screen="result"] .title-card {
  display: none;
}

.app-shell[data-screen="result"] .sound-toggle {
  display: none;
}

.sound-toggle {
  position: fixed;
  top: 11px;
  right: 14px;
  z-index: 100;
  width: 32px;
  height: 32px;
  border: var(--border-width-small) solid var(--color-ink-strong);
  border-radius: 50%;
  background: var(--color-blue-primary);
  color: var(--color-ink-strong);
}

.sound-toggle-icon {
  position: absolute;
  display: block;
  inset: 4px;
  background: url("./mute.png") center / contain no-repeat;
}

.sound-toggle[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 4px;
  width: 4px;
  height: 24px;
  border-radius: 999px;
  background: var(--color-surface-white);
  transform: translateX(-50%) rotate(42deg);
}

.sound-toggle[aria-pressed="true"] {
  background: var(--color-orange-secondary);
}

.eyebrow,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  margin: 0;
  padding: 0 12px;
  border: var(--border-width-small) solid var(--color-ink-strong);
  border-radius: var(--radius-pill);
  background: var(--color-yellow-primary);
  font-family: var(--font-display);
  font-weight: 800;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0;
}

.app-header h1 {
  max-width: 100%;
  white-space: nowrap;
  font-size: clamp(1.8rem, 8vw, 3rem);
  line-height: 1;
}

.hero-subtitle {
  margin: 9px 0 0;
  color: #da2570;
  font-family: var(--font-display);
  font-size: clamp(1rem, 4.5vw, 1.6rem);
  font-weight: 900;
  line-height: 1.05;
}

.hero-note {
  margin: 5px 0 0;
  color: var(--color-ink-body);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.35;
}

.hero-mascot {
  width: min(153px, 36vw);
  height: auto;
  margin-top: 4px;
  display: block;
}

.primary-button,
.secondary-button,
.ghost-button,
.back-button {
  min-height: 52px;
  border: var(--border-width-strong) solid var(--color-ink-strong);
  border-radius: var(--radius-pill);
  color: var(--color-ink-strong);
  font-family: var(--font-display);
  font-weight: 800;
  text-decoration: none;
  touch-action: manipulation;
}

.primary-button,
.secondary-button,
.ghost-button,
.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0 20px;
}

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

.start-form .primary-button,
.start-form .secondary-button {
  min-height: 60px;
}

.start-form .primary-button,
.share-game-button {
  animation: startButtonPulse 1180ms ease-in-out infinite;
  box-shadow: 0 8px 0 var(--color-ink-strong);
  transform-origin: center;
}

.secondary-button {
  background: var(--color-pink-primary);
  color: var(--color-surface-white);
}

.ghost-button,
.back-button {
  background: var(--color-surface-white);
}

.screen-frame {
  position: relative;
  min-height: calc(100dvh - 98px);
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

.screen {
  display: none;
  min-height: calc(100dvh - 106px);
  padding: 18px;
}

.app-shell[data-screen="guide"] .screen-frame,
.app-shell[data-screen="game"] .screen-frame,
.app-shell[data-screen="result"] .screen-frame {
  min-height: calc(100dvh - 52px);
}

.app-shell[data-screen="guide"] .screen,
.app-shell[data-screen="game"] .screen,
.app-shell[data-screen="result"] .screen {
  min-height: calc(100dvh - 60px);
}

.screen.is-active {
  display: block;
}

.start-layout {
  display: grid;
  gap: 18px;
}

.intro-block {
  padding: 20px;
  border: var(--border-width-strong) solid var(--color-ink-strong);
  border-radius: 28px;
  background: var(--color-bg-blue-soft);
}

.intro-block h2,
.result-card h2 {
  margin-top: 12px;
  font-size: clamp(2rem, 10vw, 3rem);
  line-height: 1;
}

.intro-block p,
.guide-copy p,
.result-card p,
.desktop-gate-card p {
  color: var(--color-ink-body);
  font-weight: 700;
  line-height: 1.55;
}

.asset-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
  padding: 12px;
  border: var(--border-width-small) solid var(--color-ink-strong);
  border-radius: 22px;
  background: var(--color-surface-white);
}

.asset-row img {
  width: 17%;
  max-height: 58px;
  object-fit: contain;
}

.start-form {
  display: grid;
  gap: 12px;
  padding: 20px;
  border: var(--border-width-strong) solid var(--color-ink-strong);
  border-radius: 28px;
  background: var(--color-bg-yellow-soft);
}

.start-form label {
  font-weight: 900;
}

.start-form input[type="text"] {
  width: 100%;
  height: 54px;
  padding: 0 16px;
  border: var(--border-width-strong) solid var(--color-ink-strong);
  border-radius: 18px;
  background: var(--color-surface-white);
  font-weight: 800;
}

.field-hint {
  min-height: 0;
  margin: -4px 0 2px;
  color: var(--color-ink-body);
  font-weight: 800;
}

.field-hint.is-error {
  color: #c1121f;
}

.guide-screen {
  overflow-y: auto;
  background: var(--color-bg-mint-soft);
  flex-direction: column;
}

.guide-screen.is-active {
  display: flex;
}

.back-button {
  width: 100%;
  padding: 0 18px;
  margin-top: auto;
  margin-bottom: 0;
}

.guide-copy {
  padding: 20px;
  border: var(--border-width-strong) solid var(--color-ink-strong);
  border-radius: 28px;
  background: var(--color-surface-white);
}

.guide-copy h2 {
  font-size: 2.1rem;
  line-height: 1;
}

.guide-copy h3 {
  margin-top: 16px;
  font-size: 1.35rem;
}

.guide-copy h3:first-child {
  margin-top: 0;
}

.guide-copy ol {
  padding-left: 24px;
  font-weight: 800;
  line-height: 1.8;
}

.guide-items {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0;
  padding: 10px;
  border: var(--border-width-small) solid var(--color-ink-strong);
  border-radius: 20px;
  background: var(--color-bg-blue-soft);
}

.guide-items-stones {
  grid-template-columns: repeat(3, 1fr);
  background: var(--color-bg-yellow-soft);
}

.guide-items img {
  width: 100%;
  max-height: 62px;
  object-fit: contain;
}

.game-screen {
  position: relative;
  min-height: calc(100dvh - 60px);
  padding: 0;
  overflow: hidden;
  background: var(--color-bg-blue-soft);
  touch-action: none;
}

.camera-video,
.game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.camera-video {
  object-fit: cover;
  transform: scaleX(-1);
  opacity: 0.78;
}

.game-canvas {
  z-index: 2;
}

.game-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}

.hud-chip {
  min-width: 96px;
  padding: 8px 12px 10px;
  border: var(--border-width-strong) solid var(--color-ink-strong);
  border-radius: 22px;
  background: var(--color-yellow-primary);
}

.hud-chip span,
.hud-chip strong {
  display: block;
  font-family: var(--font-body);
  line-height: 1;
}

.hud-chip span {
  font-size: 0.76rem;
  font-weight: 800;
}

.hud-chip strong {
  font-family: var(--font-display);
  margin-top: 2px;
  font-size: 2rem;
}

.score-chip {
  background: var(--color-pink-primary);
  color: var(--color-surface-white);
}

.status-banner {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 6;
  width: min(92%, 360px);
  transform: translateX(-50%);
  padding: 10px 14px;
  border: var(--border-width-small) solid var(--color-ink-strong);
  border-radius: var(--radius-pill);
  background: var(--color-surface-white);
  text-align: center;
  font-weight: 900;
}

.countdown-overlay,
.last-countdown {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--color-pink-primary);
  font-family: var(--font-display);
  font-size: clamp(6rem, 34vw, 14rem);
  font-weight: 900;
  text-shadow:
    4px 0 var(--color-ink-strong),
    -4px 0 var(--color-ink-strong),
    0 4px var(--color-ink-strong),
    0 -4px var(--color-ink-strong);
  pointer-events: none;
}

.last-countdown {
  inset: auto 18px 80px auto;
  font-size: clamp(3.5rem, 20vw, 7rem);
}

.mascot-pop {
  position: absolute;
  bottom: 8px;
  z-index: 7;
  width: 112px;
  animation: mascotPop 520ms ease both;
  pointer-events: none;
}

@keyframes mascotPop {
  from {
    transform: translateY(24px) scale(0.8);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes startButtonPulse {
  0%,
  100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 8px 0 var(--color-ink-strong);
  }
  50% {
    transform: translateY(4px) scale(1.035);
    box-shadow: 0 4px 0 var(--color-ink-strong);
  }
}

.result-screen {
  overflow: hidden;
  background: var(--color-bg-pink-soft);
}

.result-screen > * {
  width: min(95vw, 100%);
  margin-left: auto;
  margin-right: auto;
}

.result-card,
.leaderboard-panel {
  padding: 20px;
  border: var(--border-width-strong) solid var(--color-ink-strong);
  border-radius: 28px;
  background: var(--color-surface-white);
}

.result-card {
  display: grid;
  place-items: center;
  min-height: 164px;
  padding: 24px;
  text-align: center;
}

.score-group {
  display: grid;
  justify-items: center;
}

.final-score {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: clamp(4.6rem, 24vw, 8rem);
  font-weight: 900;
  line-height: 0.9;
  color: var(--color-blue-primary);
}

.leaderboard-panel {
  margin-top: 10px;
  background: var(--color-bg-yellow-soft);
}

.leaderboard-panel h3 {
  font-size: 1.45rem;
  text-align: center;
}

.leaderboard-list {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding-left: 0;
  list-style: none;
  font-weight: 900;
  margin: 10px 0 0;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  width: 80%;
  padding: 6px 9px;
  border: 0;
  border-radius: 12px;
  background: var(--color-surface-white);
}

.leaderboard-rank {
  display: grid;
  place-items: center;
  min-width: 0;
}

.leaderboard-rank img {
  width: 28px;
  height: auto;
  display: block;
}

.leaderboard-name,
.leaderboard-score {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  text-align: right;
}

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

@media (min-width: 760px) {
  .app-shell {
    padding: 14px 20px 20px;
  }

  .screen-frame {
    min-height: 700px;
  }

  .screen {
    min-height: 692px;
  }

  .app-shell[data-screen="guide"] .screen-frame,
  .app-shell[data-screen="game"] .screen-frame,
  .app-shell[data-screen="result"] .screen-frame {
    min-height: 760px;
  }

  .app-shell[data-screen="guide"] .screen,
  .app-shell[data-screen="game"] .screen,
  .app-shell[data-screen="result"] .screen {
    min-height: 752px;
  }
}

@media (max-width: 520px) {
  body {
    min-height: 100dvh;
  }

  .app-shell {
    width: 100%;
    min-height: 100dvh;
    padding: 8px 10px 10px;
  }

  .app-header {
    gap: 5px;
    margin-bottom: 6px;
  }

  .app-header h1 {
    max-width: 100%;
    font-size: clamp(1.55rem, 7.4vw, 2.55rem);
  }

  .logo-bar {
    min-height: 32px;
    padding: 5px 0;
    border-radius: 0;
  }

  .brand-logo {
    width: min(104px, 34vw);
    max-height: 31px;
  }

  .title-card {
    padding: 12px 29px 14px;
    border-width: var(--border-width-small);
    border-radius: 18px;
  }

  .hero-mascot {
    width: min(135px, 35vw);
  }

  .hero-subtitle {
    font-size: clamp(0.98rem, 4.3vw, 1.4rem);
  }

  .hero-note {
    font-size: 0.72rem;
  }

  .screen-frame {
    min-height: calc(100dvh - 84px);
  }

  .screen {
    min-height: calc(100dvh - 90px);
    padding: 0 0 10px;
  }

  .app-shell[data-screen="guide"] .screen-frame,
  .app-shell[data-screen="game"] .screen-frame,
  .app-shell[data-screen="result"] .screen-frame {
    min-height: calc(100dvh - 42px);
  }

  .app-shell[data-screen="guide"] .screen,
  .app-shell[data-screen="game"] .screen,
  .app-shell[data-screen="result"] .screen {
    min-height: calc(100dvh - 48px);
  }

  .start-layout {
    gap: 10px;
  }

  .intro-block,
  .start-form,
  .guide-copy,
  .result-card,
  .leaderboard-panel {
    padding: 12px;
    border-width: var(--border-width-small);
    border-radius: 18px;
  }

  .intro-block h2,
  .result-card h2 {
    margin-top: 10px;
    font-size: clamp(2rem, 11vw, 3.25rem);
  }

  .asset-row {
    gap: 6px;
    margin-top: 10px;
    padding: 8px;
    border-radius: 18px;
  }

  .asset-row img {
    max-height: 48px;
  }

  .start-form {
    gap: 10px;
  }

  .start-form input[type="text"] {
    height: 50px;
    border-width: var(--border-width-small);
    border-radius: 16px;
  }

  .primary-button,
  .secondary-button,
  .ghost-button,
  .back-button {
    min-height: 54px;
    padding: 0 12px;
    font-size: 0.92rem;
  }

  .start-form .primary-button,
  .start-form .secondary-button {
    min-height: 58px;
  }

  .game-screen {
    min-height: calc(100dvh - 48px);
    border-radius: 18px;
    overflow: hidden;
  }

  .hud-chip {
    min-width: 82px;
    padding: 7px 10px 9px;
    border-width: var(--border-width-small);
    border-radius: 18px;
  }

  .hud-chip strong {
    font-size: 1.7rem;
  }

  .status-banner {
    bottom: 12px;
    width: min(94%, 340px);
    font-size: 0.9rem;
  }

  .final-score {
    font-size: clamp(4rem, 22vw, 7rem);
  }

  .leaderboard-panel {
    margin-top: 8px;
  }

  .leaderboard-panel h3 {
    font-size: 1.25rem;
  }

  .leaderboard-list {
    gap: 5px;
    margin-top: 8px;
  }

  .leaderboard-list li {
    padding: 5px 8px;
    font-size: 0.9rem;
  }

  .result-actions {
    gap: 7px;
    margin-top: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .start-form .primary-button,
  .share-game-button {
    animation: none;
  }
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}

.screen-frame,
.app-shell[data-screen="guide"] .screen-frame,
.app-shell[data-screen="game"] .screen-frame,
.app-shell[data-screen="result"] .screen-frame {
  height: 100%;
  min-height: 0;
}

.screen,
.app-shell[data-screen="guide"] .screen,
.app-shell[data-screen="game"] .screen,
.app-shell[data-screen="result"] .screen {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
}

.game-screen,
.result-screen {
  min-height: 0;
  overflow: hidden;
}
