:root {
  color-scheme: light;
  --paper: #f3ecdf;
  --paper-deep: #e6dccb;
  --ink: #2c241b;
  --ink-soft: #6a5c4e;
  --cream: #fffaf3;
  --blue: #8ecae6;
  --blue-deep: #1d6f93;
  --gold: #f0c14d;
  --line: 3px solid var(--ink);
  --shadow: 0 3px 0 var(--ink);
  --radius: 1.15rem;
  --tap: 3.25rem;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: #d9d0c2;
  color: var(--ink);
  font-family: system-ui, "Segoe UI", sans-serif;
  font-size: 1.05rem;
  line-height: 1.35;
}

button, input, select { font: inherit; color: inherit; }

button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:disabled { opacity: 0.38; cursor: default; }

:focus-visible {
  outline: 3px solid var(--blue-deep);
  outline-offset: 3px;
}

img {
  max-width: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

.phone {
  width: min(100%, 28rem);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  position: relative;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  padding-top: calc(0.55rem + env(safe-area-inset-top));
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 4;
}

.top h1,
.brand {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.spacer { width: 2.75rem; }

.icon-btn,
.text-btn {
  min-height: 2.75rem;
  min-width: 2.75rem;
  border: var(--line);
  border-radius: 999px;
  background: var(--cream);
  box-shadow: var(--shadow);
  padding: 0.35rem 0.8rem;
  font-weight: 700;
}

.top-actions { display: flex; gap: 0.35rem; align-items: center; }

.icon-btn img { width: 1.7rem; height: 1.7rem; object-fit: contain; display: block; }

main {
  padding: 0.15rem 0.75rem 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

.nameline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0 0 0.3rem;
}

.nameline h1 {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nameline .where {
  margin: 0;
  flex: 0 1 46%;
  max-width: 46%;
  text-align: right;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

h1 {
  font-size: 1.7rem;
  line-height: 1.15;
  margin: 0.2rem 0 0.8rem;
}

h2 {
  font-size: 1.05rem;
  margin: 1.1rem 0 0.45rem;
}

.hint, .where, .caption {
  color: var(--ink-soft);
  margin: 0.25rem 0 0.8rem;
}

.caption {
  text-align: center;
  font-weight: 700;
  color: var(--ink);
}

.stack { display: flex; flex-direction: column; gap: 0.7rem; }

.primary, .ghost, .choice, .person, .tilebtn, .round {
  border: var(--line);
  box-shadow: var(--shadow);
  background: var(--cream);
}

.primary, .ghost, .choice {
  width: 100%;
  min-height: var(--tap);
  border-radius: 999px;
  padding: 0.65rem 1rem;
  font-weight: 800;
}

.primary { background: var(--blue); }

.primary:active, .ghost:active, .choice:active, .person:active, .tilebtn:active, .round:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.choice {
  text-align: left;
  border-radius: var(--radius);
}

.choice.selected { background: var(--blue); }

.mode-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.4rem;
  margin: 0.2rem 0 0.8rem;
}

.mode-row .choice {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  text-align: center;
  padding: 0.5rem 0.3rem;
  font-size: 0.92rem;
  line-height: 1.15;
}

.person {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 4.2rem;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius);
  font-size: 1.35rem;
  font-weight: 800;
  text-align: left;
}

.swatch {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  background: var(--person);
  border: 2px solid var(--ink);
  flex: none;
}

label.field { display: block; font-weight: 700; margin-bottom: 0.35rem; }

input[type="text"],
input[type="password"],
select {
  width: 100%;
  font-size: 1.15rem;
  padding: 0.75rem 0.85rem;
  border: var(--line);
  border-radius: 0.9rem;
  background: var(--cream);
}

.colors { display: flex; gap: 0.7rem; flex-wrap: wrap; margin: 0.4rem 0 0.8rem; }

.dot {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 999px;
  border: var(--line);
  background: var(--person);
  box-shadow: var(--shadow);
}

.dot[aria-pressed="true"] { outline: 3px solid var(--ink); outline-offset: 3px; }

.pair-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }

.pair-choice button[aria-pressed="true"] { background: var(--blue); }

.scale {
  display: flex;
  justify-content: space-between;
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.percent-readout {
  font-size: 1.8rem;
  font-weight: 800;
  text-align: center;
  margin: 0;
}

input[type="range"] { width: 100%; accent-color: var(--blue-deep); }

.steps {
  max-height: 9rem;
  overflow: auto;
  margin: 0;
  padding-left: 1.3rem;
}

.stage {
  position: relative;
  background: white;
  border: var(--line);
  border-radius: 1.4rem;
  overflow: hidden;
}

.stage.compact,
.player {
  width: min(100%, 11.25rem);
  margin-inline: auto;
}

.stage.tiny {
  width: min(100%, 8.5rem);
  margin-inline: auto;
}

.creature, .player img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: white;
}

.barwrap { position: relative; flex: 1; min-width: 0; }

.banner {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  min-height: 100%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0c14d;
  border: var(--line);
  border-radius: 0.7rem;
  padding: 0.25rem 0.45rem;
  text-align: center;
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.15;
}

.banner[hidden] { display: none; }

@keyframes pop {
  0% { transform: scale(0.94); }
  45% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.creature.pop { animation: pop 0.4s ease; }

.bar-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.8rem 0;
}

.bar-row .barline { flex: 1; margin: 0; min-width: 0; }

.cam {
  flex: none;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 0.8rem;
  border: var(--line);
  background: var(--cream);
  color: var(--ink);
  display: grid;
  place-items: center;
  padding: 0;
}

.cam svg { width: 1.5rem; height: 1.5rem; }

.barline {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin: 0.8rem 0;
}

.levelno {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 3.4rem;
}

.levelno span {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 0.9;
}

.levelno small { font-size: 0.75rem; color: var(--ink-soft); }

.segs { display: flex; flex-wrap: wrap; gap: 0.28rem; padding-top: 0.3rem; }

.seg {
  width: 1.35rem;
  height: 1.7rem;
  border: 2px solid var(--ink);
  border-radius: 0.4rem;
  background: var(--cream);
}

.seg.on { background: var(--blue); }

.seg.tiny { width: 0.95rem; height: 1.25rem; }

.row-label {
  margin: 0.35rem 0 0.15rem;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.icons {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding: 0.4rem 0.15rem 0.45rem;
}

button.icon {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  color: inherit;
}

.icon {
  flex: 0 0 4.4rem;
  text-align: center;
}

.icon img {
  width: 2.7rem;
  height: 2.7rem;
  object-fit: contain;
}

.icon span {
  display: block;
  font-size: 0.72rem;
  line-height: 1.15;
  font-weight: 700;
}

.icon.off span { color: var(--ink-soft); font-weight: 600; }

.icon.allowed img,
.icon.unlock img {
  box-shadow: 0 0 0 3px var(--gold);
  border-radius: 0.7rem;
}

.icon.unlock img { animation: unlock-ring 0.8s ease; }

.icon.spend img,
.icon.spend .pile {
  box-shadow: 0 0 0 3px var(--person, var(--gold));
  border-radius: 0.7rem;
}

.pile {
  position: relative;
  width: 2.7rem;
  height: 2.7rem;
  margin: 0 auto;
  display: block;
}

.pile img { position: absolute; inset: 0; }

.pile img.over { transform: translate(0.28rem, -0.2rem); }

.tilebtn:disabled { opacity: 0.4; }

.pending { margin: 0.4rem 0 1.1rem; }

.photos {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  margin: 0.4rem 0 0.8rem;
}

.photos .photo {
  flex: 0 0 auto;
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0.6rem;
  background: transparent;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.photos img {
  width: 5.5rem;
  height: 5.5rem;
  object-fit: cover;
  border-radius: 0.6rem;
  border: var(--line);
  background: white;
}

.photos .photo span {
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(44, 36, 27, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
}

.lightbox img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0.6rem;
  background: white;
}

.lightbox-x {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  width: 2.8rem;
  height: 2.8rem;
  border: var(--line);
  border-radius: 999px;
  background: var(--cream);
  box-shadow: var(--shadow);
  font-size: 1.4rem;
  font-weight: 800;
}

.dino-line { font-size: 1.35rem; margin: 0.6rem 0 0.2rem; }

.creature-pick {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.45rem;
  align-items: center;
  margin-top: 0.75rem;
}

.creature-pick .ghost {
  width: auto;
  min-width: 2.75rem;
  padding-inline: 0.7rem;
}

.creature-pick .stage.tiny {
  width: 100%;
  max-width: 8.5rem;
  margin-inline: 0;
  justify-self: center;
}

@keyframes unlock-ring {
  0% { box-shadow: 0 0 0 0 var(--gold); }
  35% { box-shadow: 0 0 0 6px var(--gold); }
  100% { box-shadow: 0 0 0 3px var(--gold); }
}

.tip {
  position: fixed;
  z-index: 20;
  max-width: 14rem;
  background: #fffaf3;
  border: var(--line);
  border-radius: 0.8rem;
  padding: 0.4rem 0.6rem;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.2;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.carry {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.2rem 0 0.4rem;
}

.carry img { width: 3.6rem; height: 3.6rem; object-fit: contain; }

.carry span { font-weight: 800; }

.dock {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.9rem;
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: linear-gradient(transparent, var(--paper) 18%);
  padding-top: 0.7rem;
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 0.4rem 0;
}

.num {
  font-size: 4rem;
  font-weight: 800;
  min-width: 2ch;
  text-align: center;
  margin: 0;
}

.round {
  width: 4rem;
  height: 4rem;
  border-radius: 999px;
  font-size: 2rem;
  font-weight: 800;
}

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }

.tilebtn {
  min-height: 5.1rem;
  border-radius: 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 0.35rem 0.4rem;
}

.tilebtn img { width: 2.7rem; height: 2.7rem; object-fit: contain; }

.toggle[aria-pressed="true"] { background: var(--gold); }

.stats { margin: 0.4rem 0 0.8rem; }

.stats p { margin: 0.2rem 0; }

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.tile-card { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }

.tile {
  width: 100%;
  padding: 0.4rem;
  border: var(--line);
  border-radius: 1rem;
  background: white;
  box-shadow: var(--shadow);
  text-align: left;
}

.fav {
  width: 100%;
  min-height: 2.6rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
}

.ghost[aria-pressed="true"] { background: var(--blue); }

.tile img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: white;
  border-radius: 0.6rem;
}

.tile b { display: block; margin-top: 0.25rem; }

.tile small { color: var(--ink-soft); }

.switcher { display: grid; grid-template-columns: 1fr auto auto; gap: 0.4rem; align-items: center; }

.switcher .ghost { width: auto; min-width: 2.75rem; padding-inline: 0.7rem; }

.player {
  padding: 0;
  border: var(--line);
  border-radius: 1.4rem;
  overflow: hidden;
  background: white;
  box-shadow: var(--shadow);
  display: block;
}

.player[aria-pressed="true"] { outline: 4px solid var(--gold); outline-offset: 2px; }

.quote {
  background: white;
  border: var(--line);
  border-radius: 0.9rem;
  padding: 0.6rem 0.75rem;
  margin: 0.6rem 0;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 2px solid var(--paper-deep);
}

.row .ghost { width: auto; min-height: 2.6rem; }

.error { color: #8d2f28; font-weight: 700; margin: 0.3rem 0; }

.save-error {
  margin: 0 1rem 1rem;
  padding: 0.75rem;
  background: #f6d6d1;
  border: var(--line);
  border-radius: 0.8rem;
  font-weight: 700;
}

.ask {
  position: fixed;
  inset: 0;
  background: rgba(44, 36, 27, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 20;
}

.ask .box {
  width: min(100%, 24rem);
  background: var(--paper);
  border: var(--line);
  border-radius: 1.2rem;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.ask p { font-size: 1.2rem; font-weight: 800; margin: 0.2rem 0 0.9rem; }

.add-row { display: flex; gap: 0.45rem; align-items: center; }

.add-row input { flex: 1; }

.add-row .primary { width: auto; min-width: 4.5rem; }

.morsel {
  position: fixed;
  width: 7.8rem;
  height: 7.8rem;
  z-index: 15;
  pointer-events: none;
  object-fit: contain;
}

[hidden] { display: none !important; }

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

@media (min-width: 900px) {
  body { padding: 1.5rem 0; }
  .phone {
    min-height: calc(100vh - 3rem);
    min-height: calc(100dvh - 3rem);
    border: var(--line);
    border-radius: 1.6rem;
    box-shadow: 0 12px 0 rgba(44, 36, 27, 0.18);
  }
}
