/* 莫蘭迪色系：低飽和、無純黑純白 */
:root {
  --bg-deep: #252e37;
  --bg: #34404b;
  --haze: #687682;
  --text: #e4ded3;
  --text-dim: #a9a49a;
  --text-faint: #7f8a92;
  --accent: #c4a59f;
  --sage: #9fae9c;
  --sand: #c9b99c;
  --card: rgba(58, 71, 83, 0.46);
  --card-hover: rgba(70, 85, 98, 0.58);
  --line: rgba(228, 222, 211, 0.12);
  --line-strong: rgba(228, 222, 211, 0.22);
  --badge-bg: rgba(40, 49, 58, 0.78);
  --shadow: 0 10px 30px rgba(22, 28, 34, 0.35);

  --font-serif: "Noto Serif TC", "Noto Serif JP", "Noto Serif KR", "Songti TC", serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --footer-h: 48px;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

img {
  -webkit-user-drag: none;
}

a {
  color: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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

/* ---------- 讀取畫面 ---------- */

.loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 60%, #34404b 0%, var(--bg-deep) 70%);
  transition: opacity 0.9s ease, visibility 0.9s;
}

.loader__inner {
  display: grid;
  justify-items: center;
  gap: 14px;
  transition: transform 0.9s var(--ease-out), opacity 0.6s ease;
}

.loader__ring {
  width: 64px;
  height: 64px;
  transform: rotate(-90deg);
}

.loader__track {
  fill: none;
  stroke: rgba(228, 222, 211, 0.1);
  stroke-width: 2;
}

.loader__arc {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 163.36;
  stroke-dashoffset: 163.36;
}

.loader__label {
  font-size: 11px;
  letter-spacing: 0.32em;
  color: var(--text-dim);
  text-indent: 0.32em;
}

.loader__pct {
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
  margin-left: 0.4em;
}

.is-ready .loader {
  opacity: 0;
  visibility: hidden;
}

.is-ready .loader__inner {
  transform: scale(1.15);
  opacity: 0;
}

/* ---------- 背景 ---------- */

.ocean {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  opacity: 0;
  transition: opacity 1.6s ease;
}

.is-ready .ocean {
  opacity: 1;
}

/* WebGL 不可用時的靜態背板 */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 30% at 50% 62%, rgba(150, 160, 166, 0.22), transparent 70%),
    linear-gradient(180deg, #2a343e 0%, #3d4955 58%, #4e5c68 62%, #2e3a45 63%, #232c35 100%);
}

/* ---------- 主頁 ---------- */

.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  padding: clamp(40px, 9vh, 96px) clamp(16px, 4vw, 48px) calc(var(--footer-h) + 40px);
}

.hero {
  text-align: center;
  margin: 0 auto clamp(28px, 5vh, 52px);
}

.hero__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(28px, 4.2vw, 46px);
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  margin: 0;
  color: var(--text);
  text-shadow: 0 2px 24px rgba(30, 38, 46, 0.5);
}

.hero__rule {
  width: 48px;
  height: 1px;
  margin: 22px auto 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.grid {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 1180px;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1080px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 780px;
  }
}

@media (max-width: 640px) {
  .grid {
    grid-template-columns: minmax(0, 1fr);
    max-width: 440px;
  }
}

.card {
  position: relative;
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 14px 14px 16px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px) saturate(0.9);
  -webkit-backdrop-filter: blur(10px) saturate(0.9);
  box-shadow: var(--shadow);
  transition: background 0.3s ease, border-color 0.3s ease, transform 0.4s var(--ease-out);
}

.card.is-live:hover {
  background: var(--card-hover);
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

/* 整張卡片可點進作品頁，徽章另外疊在上層 */
.card__link {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 1;
}

.card__icon {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 4px 14px rgba(22, 28, 34, 0.35);
}

.card__icon--empty {
  border: 1px dashed var(--line-strong);
  box-shadow: none;
}

.card__body {
  min-width: 0;
}

.card__name {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__desc {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card.is-soon .card__name {
  color: var(--text-faint);
  font-family: var(--font-sans);
  font-size: 13px;
  letter-spacing: 0.2em;
}

.card__badges {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 6px;
}

/* 進場動畫：讀取完成後 body 加上 .is-ready 才播放 */
.reveal {
  opacity: 0;
  transform: translateY(18px) scale(0.97);
  filter: blur(6px);
}

.is-ready .reveal {
  animation: reveal-in 1s var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 85ms + 350ms);
}

@keyframes reveal-in {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

/* ---------- 商店徽章 ---------- */

.badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 128px;
  height: 36px;
  padding: 0 12px 0 10px;
  border-radius: 8px;
  background: var(--badge-bg);
  border: 1px solid var(--line-strong);
  color: var(--text);
  text-decoration: none;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s var(--ease-out);
}

a.badge:hover {
  background: rgba(58, 70, 82, 0.92);
  border-color: rgba(196, 165, 159, 0.6);
  transform: translateY(-1px);
}

.badge__icon {
  display: grid;
  flex: none;
  width: 18px;
  height: 18px;
}

.badge__icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.badge--googlePlay .badge__icon {
  color: var(--sage);
}

.badge--appStore .badge__icon {
  color: var(--accent);
}

/* 徽章依文字撐開寬度，任何語言、字型都不裁切 */
.badge__text {
  display: grid;
  line-height: 1.05;
}

.badge__small {
  font-size: 8.5px;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  white-space: nowrap;
}

.badge__name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.badge.is-disabled {
  opacity: 0.32;
  cursor: not-allowed;
  filter: grayscale(1);
}

.badge--lg {
  min-width: 160px;
  height: 50px;
  padding: 0 14px;
  gap: 11px;
  border-radius: 11px;
}

.badge--lg .badge__icon {
  width: 24px;
  height: 24px;
}

.badge--lg .badge__small {
  font-size: 10px;
}

.badge--lg .badge__name {
  font-size: 16px;
}

@media (max-width: 380px) {
  .card {
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 12px;
  }
  .card__icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
  }
  .card .badge {
    min-width: 0;
  }
}

/* ---------- 作品頁 ---------- */

.product {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 72px 16px calc(var(--footer-h) + 32px);
}

.product__inner {
  display: grid;
  justify-items: center;
  text-align: center;
}

.product__logo {
  width: clamp(140px, 30vw, 200px);
  height: auto;
  aspect-ratio: 1;
  border-radius: 22.5%;
  box-shadow: 0 18px 50px rgba(20, 26, 32, 0.5), 0 0 0 1px var(--line);
}

.product__name {
  margin: 28px 0 0;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(26px, 4vw, 34px);
  letter-spacing: 0.3em;
  text-indent: 0.3em;
}

.product__desc {
  margin: 10px 0 0;
  font-size: 13px;
  letter-spacing: 0.16em;
  color: var(--text-dim);
}

.product__badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 36px;
}

.product .reveal {
  animation: reveal-in 1s var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 120ms + 100ms);
}

.back-link {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  text-decoration: none;
  border: 1px solid transparent;
  transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.back-link:hover {
  color: var(--text);
  border-color: var(--line);
  background: rgba(58, 71, 83, 0.4);
}

/* ---------- 聯繫頁 ---------- */

.contact {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 76px 16px calc(var(--footer-h) + 32px + env(safe-area-inset-bottom));
}

.contact__card {
  width: min(100%, 580px);
  padding: clamp(24px, 5vw, 44px);
  border-radius: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px) saturate(0.9);
  -webkit-backdrop-filter: blur(12px) saturate(0.9);
  box-shadow: var(--shadow);
}

.contact .reveal {
  animation: reveal-in 1s var(--ease-out) forwards;
  animation-delay: 100ms;
}

.contact__title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(24px, 4vw, 30px);
  letter-spacing: 0.24em;
}

.contact__intro {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.8;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.contact__form {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

.contact__form[hidden],
.contact__sent[hidden] {
  display: none;
}

.contact__row {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 600px) {
  .contact__row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field label {
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--text-dim);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  /* 16px 以上，iOS 點進欄位才不會自動放大 */
  font: 16px/1.5 var(--font-sans);
  color: var(--text);
  background: rgba(37, 46, 55, 0.55);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 11px 14px;
  -webkit-user-select: text;
  user-select: text;
  transition: border-color 0.25s ease, background 0.25s ease;
}

.field textarea {
  min-height: 150px;
  resize: vertical;
}

.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 20px) 52%, calc(100% - 15px) 52%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.field select option {
  background: var(--bg);
  color: var(--text);
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: rgba(228, 222, 211, 0.32);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(37, 46, 55, 0.72);
}

.field [aria-invalid="true"] {
  border-color: #c98f86;
}

.field__error {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: #d9a59c;
}

.field__error:empty {
  display: none;
}

.contact__actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.contact__sent .contact__actions {
  justify-content: flex-start;
  margin-top: 28px;
}

.button {
  min-width: 132px;
  min-height: 46px;
  padding: 0 24px;
  font: 500 14px/1 var(--font-sans);
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  color: var(--text);
  background: rgba(196, 165, 159, 0.2);
  border: 1px solid rgba(196, 165, 159, 0.55);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s var(--ease-out), opacity 0.25s ease;
}

.button:hover:not(:disabled) {
  background: rgba(196, 165, 159, 0.32);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.55;
  cursor: progress;
}

.contact__status {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  color: #d9a59c;
}

.contact__status:empty {
  display: none;
}

.contact__status a {
  color: var(--text);
  text-underline-offset: 3px;
}

/* 手機：按鈕撐滿，好按 */
@media (max-width: 480px) {
  .contact {
    padding-top: 68px;
  }
  .contact__card {
    border-radius: 18px;
  }
  .contact__actions .button {
    width: 100%;
  }
}

/* ---------- 常駐頁尾 ---------- */

.footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 clamp(16px, 3vw, 32px);
  padding-bottom: env(safe-area-inset-bottom);
  font-size: 12px;
  color: var(--text-dim);
  background: linear-gradient(180deg, rgba(37, 46, 55, 0.35), rgba(32, 40, 48, 0.72));
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.footer__copy {
  min-width: 0;
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.footer__end {
  flex: none;
  display: flex;
  align-items: center;
  gap: clamp(10px, 2.4vw, 18px);
}

.footer__link {
  padding: 5px 2px;
  letter-spacing: 0.14em;
  white-space: nowrap;
  text-decoration: none;
  color: var(--text-dim);
  border-bottom: 1px solid transparent;
  transition: color 0.25s ease, border-color 0.25s ease;
}

.footer__link:hover,
.footer__link[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* 窄螢幕一排放不下（日文最寬約 400px）：改兩排，聯繫與語言在上、版權在下 */
@media (max-width: 430px) {
  :root {
    --footer-h: 72px;
  }
  .footer {
    height: auto;
    min-height: var(--footer-h);
    flex-direction: column-reverse;
    justify-content: center;
    gap: 4px;
    padding-top: 6px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
  }
  .footer__copy {
    font-size: 11px;
    color: var(--text-faint);
  }
}

.lang {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lang svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}

.lang select {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 26px 5px 12px;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 14px) 52%, calc(100% - 10px) 52%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  transition: border-color 0.25s ease;
}

.lang select:hover {
  border-color: var(--line-strong);
}

.lang select option {
  background: var(--bg);
  color: var(--text);
}

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .is-ready .reveal,
  .product .reveal,
  .contact .reveal {
    animation: none;
    opacity: 1;
    transform: none;
    filter: none;
  }
}
