:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #68727f;
  --line: #d9e0e8;
  --paper: #f7fafc;
  --white: #ffffff;
  --teal: #008b8f;
  --teal-dark: #006b70;
  --coral: #ef6f5a;
  --gold: #d79b23;
  --moss: #637a3f;
  --shadow: 0 18px 45px rgba(28, 41, 56, 0.14);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background:
    linear-gradient(135deg, rgba(0, 139, 143, 0.14), transparent 42%),
    linear-gradient(315deg, rgba(239, 111, 90, 0.14), transparent 38%),
    #edf3f6;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family:
    "Noto Sans TC",
    "Microsoft JhengHei",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

.phone-shell {
  width: min(100%, 440px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.94)),
    var(--paper);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0 14px;
}

.topbar > div {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal-dark);
  font-size: 1rem;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.72rem;
  line-height: 1.18;
}

h2 {
  font-size: 1.7rem;
  line-height: 1.18;
}

.icon-button {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  color: var(--teal-dark);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(31, 49, 59, 0.08);
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.progress-card {
  padding: 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(31, 49, 59, 0.08);
}

.progress-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.progress-copy span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.progress-copy strong {
  min-width: 0;
  text-align: right;
  font-size: 0.95rem;
}

.progress-track {
  overflow: hidden;
  height: 9px;
  background: #e7edf1;
  border-radius: 999px;
}

.progress-track span {
  display: block;
  width: 25%;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--coral));
  border-radius: inherit;
  transition: width 240ms ease;
}

.stage {
  padding-top: 18px;
}

.level-screen {
  display: flex;
  min-height: calc(100vh - 156px);
  flex-direction: column;
  gap: 18px;
}

.level-head {
  display: grid;
  gap: 8px;
}

.level-number {
  width: fit-content;
  padding: 5px 10px;
  color: var(--white);
  background: var(--teal-dark);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
}

.level-copy {
  display: none;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.media-stack {
  display: grid;
  gap: 12px;
}

.placeholder,
.video-box,
.coupon {
  overflow: hidden;
  position: relative;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.placeholder {
  display: grid;
  min-height: 178px;
  place-items: center;
  padding: 18px;
  text-align: center;
}

.placeholder.tall {
  min-height: 260px;
}

.placeholder.coupon-placeholder {
  min-height: 360px;
}

.placeholder.square {
  min-height: 0;
  aspect-ratio: 1 / 1;
}

.placeholder::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px dashed #aeb9c5;
  border-radius: 6px;
  pointer-events: none;
}

.placeholder img {
  display: none;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.placeholder.has-image img {
  display: block;
}

.placeholder.has-image {
  display: block;
  min-height: 0;
  padding: 0;
  background: var(--white);
}

.placeholder.has-image.tall,
.placeholder.has-image.square,
.placeholder.has-image.coupon-placeholder {
  min-height: 0;
  aspect-ratio: auto;
}

.placeholder.has-image::before,
.placeholder.has-image .placeholder-copy {
  display: none;
}

.placeholder.coupon-placeholder.has-image {
  background: var(--white);
}

.placeholder.coupon-placeholder.has-image img {
  object-fit: contain;
}

.placeholder-copy {
  display: grid;
  position: relative;
  z-index: 1;
  gap: 8px;
}

.placeholder-copy strong {
  font-size: 1.05rem;
}

.placeholder-copy span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.video-box {
  display: grid;
  min-height: 248px;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(0, 139, 143, 0.08), rgba(215, 155, 35, 0.14)),
    var(--white);
}

.video-box video {
  display: none;
  width: 100%;
  height: auto;
  min-height: 0;
  object-fit: contain;
  background: #101820;
}

.video-box.has-video video {
  display: block;
}

.video-box.has-video {
  display: block;
  min-height: 0;
  background: #101820;
  line-height: 0;
}

.video-box.has-video .placeholder-copy {
  display: none;
}

.scanner-panel {
  display: grid;
  overflow: hidden;
  position: relative;
  min-height: 360px;
  place-items: center;
  color: var(--white);
  background: #101820;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.scanner-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-frame {
  position: relative;
  z-index: 1;
  width: min(68vw, 250px);
  max-width: calc(100% - 64px);
  aspect-ratio: 1 / 1;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  box-shadow:
    0 0 0 999px rgba(16, 24, 32, 0.34),
    inset 0 0 0 1px rgba(0, 139, 143, 0.8);
}

.scanner-status {
  position: absolute;
  right: 18px;
  bottom: 16px;
  left: 18px;
  z-index: 1;
  padding: 10px 12px;
  background: rgba(16, 24, 32, 0.72);
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 800;
  text-align: center;
}

.code-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.code-panel label {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.code-input {
  width: 100%;
  padding: 14px 16px;
  color: var(--ink);
  background: #f9fbfc;
  border: 1px solid #bdc8d4;
  border-radius: 8px;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0.28em;
  text-align: center;
}

.code-input:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.icon-button:focus-visible {
  outline: 3px solid rgba(0, 139, 143, 0.28);
  outline-offset: 3px;
}

.message {
  padding: 12px 14px;
  color: #7a351e;
  background: #fff4e8;
  border: 1px solid #ffd0a5;
  border-radius: 8px;
  font-size: 0.92rem;
  line-height: 1.5;
}

.action-row {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 2px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 900;
}

.primary-button {
  color: var(--white);
  background: var(--teal-dark);
  box-shadow: 0 12px 24px rgba(0, 107, 112, 0.25);
}

.secondary-button {
  color: var(--teal-dark);
  background: transparent;
  border: 1px solid rgba(0, 107, 112, 0.32);
}

.coupon {
  display: grid;
  gap: 16px;
  padding: 20px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 250, 238, 0.92)),
    repeating-linear-gradient(45deg, rgba(215, 155, 35, 0.22) 0 8px, rgba(0, 139, 143, 0.14) 8px 16px);
}

.coupon::before,
.coupon::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 24px;
  height: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 50%;
  transform: translateY(-50%);
}

.coupon::before {
  left: -13px;
}

.coupon::after {
  right: -13px;
}

.coupon-label {
  color: var(--teal-dark);
  font-size: 0.86rem;
  font-weight: 900;
}

.coupon-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.coupon-main strong {
  font-size: 5.5rem;
  line-height: 0.82;
}

.coupon-main span {
  padding-bottom: 6px;
  color: var(--coral);
  font-size: 1.45rem;
  font-weight: 900;
  writing-mode: vertical-rl;
}

.coupon-note {
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.65;
}

.complete-mark {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  color: var(--white);
  background: var(--moss);
  border-radius: 50%;
  font-size: 2.2rem;
  font-weight: 900;
}

@media (min-width: 700px) {
  body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
  }

  .phone-shell {
    min-height: 860px;
    border: 1px solid rgba(23, 32, 42, 0.08);
    border-radius: 28px;
    box-shadow: 0 30px 80px rgba(28, 41, 56, 0.24);
  }
}

@media (max-width: 360px) {
  .eyebrow {
    font-size: 0.95rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.45rem;
  }

  .coupon-main strong {
    font-size: 4.7rem;
  }
}
