:root {
  --screen: 320px;
  --ball: 378px;
  --btn: 60px;
  --ink: #080b13;
  --panel: #141a2b;
  --line: #2f3a5e;
  --text: #e9eeff;
  --muted: #8f9ac4;
}

* { box-sizing: border-box; }

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

body {
  background: #080b13;
  color: var(--text);
  font-family: "Segoe UI", "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 50% 34%, rgba(96, 126, 255, 0.16), transparent 56%),
    radial-gradient(circle at 50% 104%, rgba(255, 84, 124, 0.10), transparent 58%);
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 18px 18px;
  opacity: 0.45;
  pointer-events: none;
}

.wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 0 calc(10px + env(safe-area-inset-bottom));
}

header.top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

#logo {
  display: block;
  image-rendering: pixelated;
  height: 34px;
  width: auto;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.45));
}

.tagline {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--muted);
  text-indent: 0.28em;
}

/* ---------------- 精靈球 ---------------- */

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.ball {
  position: relative;
  width: var(--ball);
  height: var(--ball);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 33% 24%, rgba(255, 255, 255, 0.62) 0 3.2%, rgba(255, 255, 255, 0) 3.4%),
    radial-gradient(circle at 35% 27%, #ff8079 0 15%, #f04c45 15% 52%, #d03531 52% 78%, #a02222 78% 100%);
  box-shadow:
    0 30px 60px rgba(0, 0, 0, 0.6),
    0 6px 0 rgba(0, 0, 0, 0.35),
    inset 0 -14px 30px rgba(0, 0, 0, 0.35);
}

.ball::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 6px rgba(255, 255, 255, 0.05),
    inset 0 0 0 12px rgba(0, 0, 0, 0.18);
  pointer-events: none;
}

.bezel {
  position: relative;
  width: calc(var(--screen) * 1.035);
  height: calc(var(--screen) * 1.035);
  border-radius: 50%;
  background: #090b12;
  display: grid;
  place-items: center;
  box-shadow:
    inset 0 0 0 5px #171c2b,
    0 0 0 4px rgba(0, 0, 0, 0.5),
    0 10px 24px rgba(0, 0, 0, 0.55);
}

#screen {
  display: block;
  width: var(--screen);
  height: var(--screen);
  border-radius: 50%;
  background: #0a1020;
  image-rendering: pixelated;
  touch-action: manipulation;
}

.gloss {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 34% at 32% 10%, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 70%);
}

.led {
  position: absolute;
  left: 13%;
  top: 9%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f4f8ff;
  box-shadow: 0 0 12px rgba(207, 227, 255, 0.9), 0 0 3px #fff;
  opacity: 0.9;
}

/* ---------------- 按鈕 ---------------- */

.pad {
  display: flex;
  gap: calc(var(--btn) * 0.16);
  align-items: center;
}

.pad.busy .btn { opacity: 0.4; }

.btn {
  position: relative;
  width: var(--btn);
  height: var(--btn);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  image-rendering: pixelated;
  transition: transform 60ms steps(2);
}

.btn canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  transition: filter 120ms linear;
}

.btn .cd {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(6, 8, 16, 0.55);
  color: #fff3c4;
  font-style: normal;
  font-size: calc(var(--btn) * 0.26);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.btn .cd[hidden] { display: none; }
.btn.cooling canvas { filter: grayscale(0.75) brightness(0.55); }
.btn.cooling:active { transform: none; }

.btn:active { transform: translateY(3px); }
.btn[disabled] { opacity: 0.45; }

.hint {
  margin: 0;
  min-height: 18px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ---------------- 選單 / 卡片 ---------------- */

.gear {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: calc(10px + env(safe-area-inset-right));
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: rgba(20, 26, 43, 0.85);
  cursor: pointer;
  padding: 0;
}

.gear canvas {
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(4, 6, 12, 0.78);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.sheet[hidden] { display: none; }

.card {
  width: min(370px, 94vw);
  max-height: 86vh;
  overflow: auto;
  padding: 16px 14px 14px;
  border: 3px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  text-align: center;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 18px;
  letter-spacing: 0.06em;
}

.card p.sub {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--muted);
}

.choices {
  display: flex;
  gap: 5px;
  overflow: hidden;
}

.choice {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 2px 7px;
  border: 3px solid #33406b;
  border-radius: 10px;
  background: #1d2540;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.choice:active {
  transform: translateY(2px);
  border-color: #5b6dad;
}

.choice canvas {
  width: 72px;
  height: 72px;
  image-rendering: pixelated;
}

.choice .nm { font-size: 13px; }
.choice .tp { font-size: 11px; color: var(--muted); }

.rows {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 10px;
  margin: 4px 0 14px;
  font-size: 13px;
  text-align: left;
}

.rows .k { color: var(--muted); }
.rows .v { text-align: right; font-variant-numeric: tabular-nums; }

.card .actions {
  display: flex;
  gap: 8px;
}

.card .actions button {
  flex: 1;
  padding: 10px 8px;
  border: 3px solid #33406b;
  border-radius: 10px;
  background: #1d2540;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.card .actions button.danger { border-color: #6b3030; background: #2a1a1f; color: #ffbfbf; }
.card .actions button:active { transform: translateY(2px); }
.card .actions button:disabled { opacity: 0.45; }

.card .note {
  margin: 10px 2px 0;
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
  text-align: left;
}

.install-chip {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 15;
  padding: 10px 18px;
  border: 2px solid #3d4a78;
  border-radius: 10px;
  background: #1a2136;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
}

.install-chip[hidden] { display: none; }
.install-chip:active { transform: translateX(-50%) translateY(2px); }

.bar {
  height: 6px;
  border-radius: 3px;
  background: #0c101d;
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  background: #58c85c;
}

/* ---------------- 樹果 / 日誌 ---------------- */

.berry-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.berry-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 3px solid #33406b;
  border-radius: 10px;
  background: #1d2540;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.berry-row:active { transform: translateY(2px); }
.berry-row:disabled { opacity: 0.4; cursor: default; transform: none; }

.berry-row .dot {
  flex: none;
  width: 14px;
  height: 14px;
  border: 3px solid #10131f;
  border-radius: 4px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35);
}

.berry-row .bn { flex: 1; font-size: 14px; }
.berry-row .bf { font-size: 12px; color: #ffe9a3; }
.berry-row .bc { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.berry-row .bh { width: 18px; text-align: center; font-size: 14px; color: #ff8aa8; }

.journal {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 46vh;
  overflow: auto;
  text-align: left;
}

.jrow { display: flex; gap: 8px; font-size: 13px; line-height: 1.45; }
.jt { flex: none; width: 62px; padding-top: 2px; font-size: 11px; color: var(--muted); }
.jx { flex: 1; color: #dfe6ff; }

.empty-note { margin: 6px 0; font-size: 12px; color: var(--muted); text-align: left; }

/* ---------------- 圖鑑 ---------------- */

.dex-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-height: 52vh;
  overflow: auto;
}

.dex-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px 5px;
  border: 2px solid #2c3555;
  border-radius: 8px;
  background: #1a2238;
  font-size: 11px;
  color: #dfe6ff;
}

.dex-cell canvas {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
}

.dex-cell.caught { border-color: #4f7a4f; background: #1c2a24; }
.dex-cell.unknown { opacity: 0.4; }
.dex-cell .tag { font-style: normal; font-size: 9px; color: var(--muted); }

/* ---------------- 睡眠報告 ---------------- */

.sleep-dream {
  display: flex;
  justify-content: center;
  margin: 8px 0 12px;
}

.sleep-dream canvas {
  width: 96px;
  height: 96px;
  image-rendering: pixelated;
  background: radial-gradient(circle at 50% 60%, #24305a 0%, #141a2b 70%);
  border: 2px solid #2c3555;
  border-radius: 10px;
}

@media (max-height: 720px) {
  #logo { height: 28px; }
  .tagline { display: none; }
}
