:root {
  --bg-top: #f8c267;
  --bg-bottom: #f7f0d4;
  --ink: #213047;
  --muted: #5f6f85;
  --panel: rgba(255, 251, 240, 0.9);
  --panel-strong: #fff9ef;
  --accent: #f26b5e;
  --accent-2: #29a19c;
  --shadow: 0 22px 50px rgba(65, 49, 22, 0.18);
  --radius: 24px;
}

body[data-scene="night"] {
  --bg-top: #20345d;
  --bg-bottom: #0e1729;
  --ink: #eff3ff;
  --muted: #cbd5f1;
  --panel: rgba(15, 24, 40, 0.82);
  --panel-strong: #18253c;
  --shadow: 0 22px 50px rgba(5, 8, 16, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Trebuchet MS", "Avenir Next", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.7), transparent 35%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body {
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  padding: 18px 14px 24px;
}

.topbar,
.panel-head,
.pet-meta,
.status-cluster,
.game-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  margin: 0 auto 14px;
  max-width: 1080px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--muted);
}

small {
  font-size: 0.92rem;
  line-height: 1.35;
}

.primary-btn,
.ghost-btn,
.chip-btn,
.shop-btn,
.action-btn,
.choice-btn {
  border-radius: 16px;
  padding: 12px 14px;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary-btn:hover,
.ghost-btn:hover,
.chip-btn:hover,
.shop-btn:hover,
.action-btn:hover,
.pet-touch-zone:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: var(--accent);
  color: white;
  box-shadow: 0 12px 22px rgba(242, 107, 94, 0.25);
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
}

.wide {
  width: 100%;
}

.phone-stage {
  max-width: 1080px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(12px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.setup-panel {
  max-width: 540px;
  margin: 20px auto 0;
  padding: 24px;
}

.setup-form {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.setup-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.setup-form input,
.setup-form select {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(33, 48, 71, 0.12);
  background: rgba(255, 255, 255, 0.85);
}

.setup-preview {
  min-height: 220px;
  display: grid;
  place-items: center;
  padding: 14px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(255, 242, 214, 0.9));
}

.game-layout {
  display: block;
}

.log-block {
  background: rgba(255, 248, 232, 0.92);
  border-radius: 22px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.button-stack,
.status-bars,
.alert-list,
.pet-list,
.panel-buttons,
.mode-buttons {
  display: grid;
  gap: 10px;
}

.pet-stage {
  padding: 18px;
}

.compact {
  margin-bottom: 10px;
}

.token-card {
  min-width: 82px;
  padding: 10px 14px;
  text-align: center;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff2cb, #ffdf88);
}

.token-card span {
  display: block;
  font-size: 0.76rem;
  color: #7e5d1f;
}

.token-card strong {
  font-size: 1.4rem;
}

.compact-token {
  min-width: 92px;
}

.pet-touch-zone {
  width: 100%;
  margin: 14px 0;
  padding: 18px 14px 22px;
  border-radius: 30px;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.72), transparent 40%),
    linear-gradient(180deg, #d8f5f3, #bde2c0 58%, #9bd384);
  position: relative;
  overflow: hidden;
}

body[data-scene="night"] .pet-touch-zone {
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.16), transparent 40%),
    linear-gradient(180deg, #22396c, #1a2958 52%, #22381f);
}

.pet-touch-zone::after {
  content: "";
  position: absolute;
  inset: auto 18px 0;
  height: 26%;
  background: rgba(124, 182, 81, 0.18);
  border-radius: 50%;
  filter: blur(12px);
}

.pet-speech {
  width: fit-content;
  max-width: min(72%, 320px);
  padding: 12px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 14px;
}

.pet-canvas {
  min-height: 340px;
  display: grid;
  place-items: center;
}

.pet-svg {
  display: block;
  overflow: visible;
}

.status-row {
  display: grid;
  grid-template-columns: 96px 1fr 42px;
  align-items: center;
  gap: 10px;
}

.meter {
  height: 12px;
  border-radius: 999px;
  background: rgba(33, 48, 71, 0.12);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: inherit;
}

.action-btn,
.shop-btn,
.chip-btn,
.choice-btn {
  text-align: left;
  background: rgba(255, 255, 255, 0.85);
}

.featured {
  background: linear-gradient(180deg, rgba(255, 241, 192, 0.96), rgba(255, 255, 255, 0.9));
}

.equipped {
  outline: 2px solid var(--accent-2);
}

.action-btn strong,
.shop-btn strong,
.chip-btn strong,
.choice-btn strong {
  display: block;
  font-size: 1rem;
}

.action-btn small,
.shop-btn small,
.chip-btn small,
.choice-btn small,
.alert-item small {
  color: var(--muted);
}

.alert-item {
  background: rgba(255, 255, 255, 0.78);
  border-radius: 16px;
  padding: 10px 12px;
}

.pet-card {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
}

.action-panel {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.mode-row {
  display: flex;
  justify-content: center;
}

.mode-buttons {
  width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.chip-btn {
  background: rgba(255, 255, 255, 0.72);
  text-align: center;
}

.chip-btn.active {
  background: var(--accent);
  color: white;
}

.panel-buttons {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-options {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.pet-card .thumbnail {
  width: 72px;
  height: 72px;
}

.pet-card.active {
  outline: 2px solid var(--accent-2);
}

.modal {
  border: 0;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(19, 31, 48, 0.36);
}

.modal-card {
  width: min(92vw, 520px);
  padding: 18px;
  border-radius: 24px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.mini-game-arena {
  min-height: 320px;
  margin-top: 16px;
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.7), transparent 34%),
    linear-gradient(180deg, #fff6da, #ffcba8);
}

.runner-world,
.ufo-world {
  position: relative;
  width: 100%;
  height: 320px;
  overflow: hidden;
}

.runner-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 46px;
  height: 8px;
  background: rgba(29, 50, 39, 0.32);
}

.runner-pet,
.ufo-player {
  position: absolute;
  bottom: 54px;
  left: 14%;
  font-size: 2rem;
  transition: left 120ms ease;
}

.runner-obstacle,
.ufo-item {
  position: absolute;
  bottom: 54px;
  font-size: 2rem;
}

.ufo-item {
  top: 0;
  bottom: auto;
  transform: translateX(-50%);
}

.ufo-lanes {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.ufo-lane {
  border-left: 1px dashed rgba(33, 48, 71, 0.14);
}

.ufo-lane:first-child {
  border-left: 0;
}

.runner-hint {
  position: absolute;
  left: 16px;
  top: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 0.88rem;
}

.heart-target {
  position: absolute;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #ff7a89;
  color: white;
  font-size: 1.8rem;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 24px rgba(255, 122, 137, 0.32);
  animation: bob 1.2s ease-in-out infinite alternate;
}

@keyframes bob {
  from {
    transform: translateY(-4px) scale(1);
  }
  to {
    transform: translateY(4px) scale(1.06);
  }
}

.sync-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 900px) {
  .pet-canvas {
    min-height: 300px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 12px 10px 20px;
  }

  .topbar,
  .status-cluster {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-buttons,
  .mode-buttons,
  .choice-options,
  .button-stack {
    grid-template-columns: 1fr;
  }

  .pet-canvas {
    min-height: 260px;
  }
}
