/* 小豬遊戲島：黃昏的故事書地圖（刻意單一主題） */
:root {
  color-scheme: light;
  --sea: #86bcd6;
  --ink: #3b2f3a;
  --ink-soft: #6a5a68;
  --paper: #fffaf0;
  --paper-2: #f6ecd9;
  --coral: #ff8f6b;
  --gold: #ffd166;
  --font: "Huninn", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  --font-num: "Baloo 2", "Huninn", "Avenir Next", "Segoe UI", sans-serif;
  --map-s: 1;
}

[hidden] { display: none !important; }

html { height: 100%; box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; }

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--sea);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
}

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

button:focus-visible,
a:focus-visible {
  outline: 3px dashed var(--ink);
  outline-offset: 4px;
}

/* ---------- 標題緞帶 ---------- */
.banner {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  left: 50%;
  z-index: 2;
  width: max-content;
  max-width: calc(100% - 120px);
  padding: 8px 22px 10px;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 4px 0 var(--ink);
  text-align: center;
  transform: translateX(-50%) rotate(-1.2deg);
  pointer-events: none;
  animation: banner-in 0.8s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.banner-title {
  margin: 0;
  font-size: clamp(24px, 7vw, 34px);
  font-weight: 400;
  letter-spacing: 0.1em;
  line-height: 1.2;
}

.banner-title::after {
  content: "";
  display: block;
  height: 5px;
  margin: 3px auto 0;
  width: 70%;
  border-radius: 3px;
  background: repeating-linear-gradient(90deg, var(--coral) 0 10px, transparent 10px 16px);
}

.banner-sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-soft);
  text-wrap: balance;
}

body[data-layout="landscape"] .banner {
  left: 24px;
  max-width: 360px;
  transform: rotate(-1.5deg);
  text-align: left;
}

body[data-layout="landscape"] .banner-title::after { margin-left: 0; }

/* ---------- 聲音按鈕 ---------- */
.icon-btn {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: 16px;
  z-index: 3;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.icon-btn svg { width: 22px; height: 22px; fill: var(--ink); }
.icon-btn svg .stroke { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
#btnSound[aria-pressed="true"] .icon-off,
#btnSound[aria-pressed="false"] .icon-on { display: none; }

/* ---------- 地標 ---------- */
.marks {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.mark {
  position: absolute;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
}

.plate {
  position: absolute;
  top: calc(100% - 2px);
  left: 50%;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px 3px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 2.5px 0 var(--ink);
  font-size: clamp(11.5px, calc(14px * var(--map-s)), 17px);
  line-height: 1.3;
  white-space: nowrap;
  transform: translateX(-50%);
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.plate-soon {
  background: #ffe9a8;
  border-style: dashed;
}

.mark:hover .plate,
.mark:focus-visible .plate {
  background: #fff3c4;
  transform: translateX(-50%) translateY(-2px);
}

.played {
  font-style: normal;
  color: #e8a412;
  text-shadow: 0 1px 0 var(--ink);
}

/* ---------- 署名 ---------- */
.credit {
  position: fixed;
  left: calc(env(safe-area-inset-left, 0px) + 12px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 2;
  padding: 2px 12px 3px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 2.5px 0 var(--ink);
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--ink-soft);
  transform: rotate(-1.5deg);
  pointer-events: none;
}

.credit-name {
  font-family: var(--font-num);
  font-weight: 600;
  color: var(--ink);
}

/* ---------- 遊戲卡片 ---------- */
.card {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 4;
  max-width: 460px;
  margin-inline: auto;
  padding: 16px 16px 16px;
  border: 3px solid var(--ink);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 6px 0 var(--ink);
  overflow: hidden;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.2, 1.3, 0.4, 1);
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  background: repeating-linear-gradient(90deg, var(--game, #27306d) 0 18px, var(--game-accent, #ffd98a) 18px 26px);
}

.card.show { opacity: 1; transform: translateY(0); }

body[data-layout="landscape"] .card {
  left: auto;
  right: 24px;
  bottom: 24px;
  width: 400px;
  margin: 0;
}

.card-close {
  position: absolute;
  top: 14px;
  right: 12px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  cursor: pointer;
}

.card-close svg { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; }

.card-top {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  align-items: center;
  margin-top: 6px;
  padding-right: 34px;
}

.card-art {
  width: 96px;
  height: 96px;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: radial-gradient(circle at 50% 35%, #fff6dc, #f6e3c2);
}

.card-head { min-width: 0; }

.card-en {
  margin: 0;
  font-family: var(--font-num);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--game, #27306d);
}

.card-title {
  margin: 0;
  font-size: 24px;
  font-weight: 400;
  line-height: 1.2;
  text-wrap: balance;
}

.card-tags {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.card-tags li {
  padding: 0 9px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--paper-2);
  font-size: 12px;
  line-height: 1.6;
}

.card-blurb {
  margin: 12px 0 0;
  font-size: 15px;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.card-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0;
  padding: 6px 10px;
  border-radius: 12px;
  background: #fff3c4;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.card-progress-label {
  padding: 0 8px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 11.5px;
  line-height: 1.7;
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 14px;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  font-size: 18px;
  letter-spacing: 0.1em;
  text-indent: 0.1em;
  line-height: 1.2;
  text-decoration: none;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.15s ease;
}

.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

.btn-primary {
  background: var(--game, #27306d);
  color: #ffffff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}

.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost { background: var(--paper); }
.btn-ghost:hover { background: #ffffff; }

.fallback {
  position: fixed;
  top: 140px;
  left: 16px;
  right: 16px;
  padding: 16px 24px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  font-size: 18px;
  line-height: 2;
}

@keyframes banner-in {
  from { opacity: 0; translate: 0 -20px; }
  to { opacity: 1; translate: 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
