/* ===== Virtual Pet — pastel UI ===== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-top: #aee1f9;
  --bg-bottom: #fde8f4;
  --card: #ffffff;
  --ink: #5b4a63;
  --ink-soft: #9b8aa6;
  --accent: #ff9ec4;
  --accent-deep: #f4739c;
  --good: #6fca8a;
  --warn: #f5c451;
  --bad: #ef6f6f;
  --shadow: rgba(122, 87, 128, 0.18);
}

html, body {
  height: 100%;
}

body {
  font-family: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

.scene {
  background: var(--card);
  border-radius: 28px;
  box-shadow: 0 18px 40px var(--shadow), 0 4px 10px var(--shadow);
  padding: 24px 28px 20px;
  width: min(460px, 100%);
  text-align: center;
}

.header h1 {
  font-size: 2rem;
  letter-spacing: 0.5px;
}

.subtitle {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin-top: 2px;
}

/* ===== Stage ===== */

.stage {
  position: relative;
  margin: 14px auto 6px;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 10 / 9;
  border-radius: 22px;
  background: radial-gradient(circle at 50% 30%, #fff8f0 0%, #ffeef6 55%, #ffe3ef 100%);
  box-shadow: inset 0 0 0 3px #ffd9e8;
  overflow: visible;
}

#pet-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
  touch-action: manipulation;
}

/* Stage evolution badge floats in the corner of the stage */
.stage-badge {
  position: absolute;
  top: 10px;
  left: 12px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  box-shadow: 0 3px 8px var(--shadow);
  pointer-events: none;
  max-width: 80%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Day/night cycle =====
   The JS toggles .night on the stage: 3 minutes of day, 1 of night,
   cross-fading over 6 s so the sky change is always soft */

.sound-gear {
  left: 0;
}

#night-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  overflow: hidden;
  border-radius: inherit;
}

#night-overlay .night-sky { position: absolute; inset: 0; opacity: 0; transition: opacity 6s ease; }

#night-overlay .day-sun,
#night-overlay .night-moon,
#night-overlay .night-star { display: block; position: absolute; transition: opacity 6s ease; }

#night-overlay .night-sky {
  background: linear-gradient(
    to bottom,
    rgba(23, 26, 74, 0.46) 0%,
    rgba(30, 34, 92, 0.24) 55%,
    rgba(28, 32, 86, 0.40) 100%
  );
}

/* Sun rules the day corner; moon and stars own the night.
   Moon and stars start hidden — they only exist at night. */
#night-overlay .day-sun {
  left: 8%;
  top: 8%;
  font-size: 2rem;
  filter: drop-shadow(0 0 10px rgba(255, 214, 110, 0.85));
}

#night-overlay .night-moon {
  right: 9%;
  top: 8%;
  font-size: 1.9rem;
  opacity: 0;
  filter: drop-shadow(0 0 12px rgba(255, 255, 232, 0.6));
  animation: moon-drift 7s ease-in-out infinite;
}

#night-overlay .night-star {
  color: #fffbe8;
  font-size: 0.85rem;
  opacity: 0;
  text-shadow: 0 0 7px rgba(255, 255, 220, 0.95);
  animation: twinkle 2.8s ease-in-out infinite;
}

/* Stars are little toys only while the night lasts */
.stage.night #night-overlay .night-star { pointer-events: auto; cursor: pointer; }

.stage.night #night-overlay .night-star.star-pop {
  animation: star-pop 0.5s ease !important;
}

@keyframes star-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(2.1) rotate(18deg); opacity: 1; }
  100% { transform: scale(1); }
}

#night-overlay .s1 { left: 14%; top: 22%; }
#night-overlay .s2 { left: 32%; top: 9%;  animation-delay: 0.6s; }
#night-overlay .s3 { left: 55%; top: 18%; animation-delay: 1.2s; font-size: 0.65rem; }
#night-overlay .s4 { right: 22%; top: 30%; animation-delay: 1.8s; font-size: 0.7rem; }
#night-overlay .s5 { left: 70%; top: 8%;  animation-delay: 2.3s; }

.stage.night #night-overlay .night-sky,
.stage.night #night-overlay .night-moon,
.stage.night #night-overlay .night-star { opacity: 1; }

.stage.night #night-overlay .day-sun { opacity: 0; }

@keyframes moon-drift {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

@keyframes twinkle {
  0%, 100% { transform: scale(0.65); opacity: 0.75; }
  50%      { transform: scale(1.15); opacity: 1; }
}

/* First aid kit button: fullwidth, low bar at the bottom of the stage so it
   never covers the fainted pet */
.revive-btn {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.92);
  border: 3px dashed #e35d5d;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(60, 30, 60, 0.22);
  color: var(--ink);
  padding: 8px 14px;
  font-family: inherit;
  cursor: pointer;
  z-index: 25;
  animation: menu-pop 0.3s ease-out;
  transition: transform 0.12s ease;
}

.revive-btn[hidden] { display: none; }

.revive-btn:hover { transform: translateY(-2px); }

.revive-btn:active { transform: translateY(0) scale(0.99); }

.revive-emoji {
  font-size: 1.35rem;
  line-height: 1;
  animation: cross-pulse 1.1s ease-in-out infinite;
}

.revive-btn strong {
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.revive-btn em {
  font-style: normal;
  font-size: 0.72rem;
  color: #8a6f7e;
  line-height: 1.3;
}

@keyframes cross-pulse {
  0%, 100% { transform: scale(1) rotate(-6deg); }
  50%      { transform: scale(1.18) rotate(8deg); }
}

/* Speech bubble floats above the pet */
.bubble {
  position: absolute;
  left: 50%;
  top: 6%;
  transform: translate(-50%, 0);
  background: #fff;
  border: 3px solid var(--accent);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  box-shadow: 0 6px 14px var(--shadow);
  pointer-events: none;
  white-space: nowrap;
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: bubble-pop 0.25s ease-out;
}

.bubble::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: var(--accent);
}

@keyframes bubble-pop {
  from { transform: translate(-50%, 6px) scale(0.85); opacity: 0; }
  to   { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

/* ===== Stats ===== */

.stats {
  display: grid;
  gap: 8px;
  margin: 14px 6px;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-icon {
  width: 26px;
  text-align: center;
  font-size: 1.05rem;
}

.stat-bar {
  flex: 1;
  height: 14px;
  border-radius: 999px;
  background: #f1e6ee;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(122, 87, 128, 0.12);
}

.stat-fill {
  height: 100%;
  width: 50%;
  border-radius: 999px;
  background: var(--good);
  transition: width 0.4s ease, background-color 0.4s ease;
}

.stat-fill.warn { background: var(--warn); }
.stat-fill.bad  { background: var(--bad); }

/* ===== Actions ===== */

.actions {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 4px 0 10px;
}

/* Kawaii "coming soon" pulse for the locked minigames button */
.minigame-btn:disabled {
  position: relative;
  overflow: hidden;
}
.minigame-btn:not([hidden]):disabled::after {
  content: "🔒";
  position: absolute;
  top: 4px;
  right: 5px;
  font-size: 0.62rem;
  filter: none;
}

/* Games popover floats above the action buttons */
.game-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  right: 0;
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 12px 28px rgba(60, 30, 60, 0.28);
  border: 2px solid #f0dcea;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px;
  z-index: 30;
  animation: menu-pop 0.18s ease-out;
}

@keyframes menu-pop {
  from { transform: translateY(6px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.game-menu[hidden] { display: none; }

.game-item {
  border: none;
  border-radius: 14px;
  background: #fdf4fa;
  padding: 10px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  transition: background 0.15s, transform 0.1s ease;
}

.game-item:hover {
  background: #ffeef6;
  transform: translateY(-2px);
}

.game-item:active { transform: translateY(0); }

.gi-icon {
  width: 26px;
  height: 26px;
  display: block;
}

.game-item span {
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.1;
}

/* Danger / secondary buttons for settings */
.danger-btn {
  width: 100%;
  border: none;
  border-radius: 14px;
  background: linear-gradient(180deg, #f29191 0%, #e35d5d 100%);
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 11px;
  cursor: pointer;
  box-shadow: 0 4px 0 #c04848;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  font-family: inherit;
}

.danger-btn.secondary {
  margin-top: 8px;
  padding: 9px;
  font-size: 0.8rem;
  opacity: 0.9;
}

.danger-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #c04848;
}

.ghost-btn {
  border: 2px solid #f0dcea;
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 11px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.ghost-btn:hover { background: #fdf4fa; }

.confirm-text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 16px;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-btn {
  border: none;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #fff;
  font-size: 1.6rem;
  padding: 10px 4px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: 0 5px 0 #d95c85, 0 8px 14px var(--shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.2s;
}

.action-btn span {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.action-btn:hover { filter: brightness(1.05); }

.action-btn:active,
.action-btn.pressed {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #d95c85, 0 4px 8px var(--shadow);
}

.action-btn:disabled,
.action-btn[data-sleeping="true"]#btn-sleep {
  filter: grayscale(0.35) brightness(0.95);
  cursor: not-allowed;
}

.hint {
  color: var(--ink-soft);
  font-size: 0.8rem;
}

/* ===== Minigames overlay: Tic Tac Toe, best of 3 ===== */

#minigame {
  backdrop-filter: blur(14px) brightness(0.92); /* the pet stays hidden while playing */
}

.mg-card { width: min(420px, 100%); }

/* --- Minigame picker menu --- */
.mg-menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mg-menu-item {
  border: 2px solid #f3e2ef;
  border-radius: 18px;
  background: #fdf4fa;
  padding: 16px 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, box-shadow 0.15s;
}

.mg-menu-item:hover {
  background: #fce9f5;
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(60, 30, 60, 0.14);
}

.mg-menu-item b { font-size: 0.95rem; color: var(--ink); }
.mg-menu-emoji { font-size: 1.9rem; line-height: 1; }
.mg-menu-desc {
  font-size: 0.72rem;
  color: var(--ink-soft);
  line-height: 1.25;
  text-align: center;
}

#mg-menu-view .mg-foot .danger-btn.secondary { grid-column: 1 / -1; }

/* --- Simón Dice --- */
.mg-simon-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 6px;
  font-weight: 700;
  color: var(--ink-soft);
}

.mg-sim-board {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  width: min(70vw, 230px);
  margin: 0 auto 16px;
}

.mg-sim-board.mg-shake { animation: mg-shake 0.5s ease; }

.mg-pad {
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0.8;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.12), 0 4px 10px rgba(60, 30, 60, 0.18);
  transition: filter 0.1s, transform 0.1s, opacity 0.15s, box-shadow 0.15s;
}

.mg-pad[data-pad="0"] { background: #4cc98a; --glow: rgba(76, 201, 138, 0.8); }
.mg-pad[data-pad="1"] { background: #f25d9c; --glow: rgba(242, 93, 156, 0.8); }
.mg-pad[data-pad="2"] { background: #7ba7d9; --glow: rgba(123, 167, 217, 0.8); }
.mg-pad[data-pad="3"] { background: #f2b13c; --glow: rgba(242, 177, 60, 0.8); }

.mg-pad:disabled { cursor: default; }
.mg-pad:hover:not(:disabled) { opacity: 0.95; }

.mg-pad.mg-pad-on {
  opacity: 1;
  transform: scale(1.07);
  filter: brightness(1.35);
  box-shadow: 0 0 20px var(--glow), inset 0 0 0 3px rgba(255, 255, 255, 0.65);
}

/* --- Find the pet under the boxes --- */
.mg-find-board {
  position: relative;
  height: 158px;
  width: min(86vw, 300px);
  margin: 0 auto 12px;
}

.mg-find-board.mg-shake { animation: mg-shake 0.5s ease; }

.mg-cup {
  position: absolute;
  bottom: 0;
  width: 29%;
  left: calc(var(--slot, 0) * 35.5% + 1%);
  cursor: default;
}

.mg-cup-body {
  position: relative;
  height: 86px;
  border-radius: 46% 46% 14px 14px;
  background: linear-gradient(180deg, #f7a8c9 0%, #e78ab2 100%);
  box-shadow: inset 0 -6px 10px rgba(60, 30, 60, 0.18), inset 6px 6px 14px rgba(255, 255, 255, 0.5), 0 5px 10px rgba(60, 30, 60, 0.2);
  transition: transform 0.28s cubic-bezier(.5, 1.5, .6, 1);
}

.mg-cup-body::before { /* kawaii knob on top */
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  width: 26px;
  height: 14px;
  border-radius: 99px;
  transform: translateX(-50%);
  background: #f78fb8;
  box-shadow: inset 0 -3px 4px rgba(60, 30, 60, 0.18);
}

.mg-cup.mg-cup-lift .mg-cup-body { transform: translateY(-34px); }

.mg-find-board.pickable .mg-cup { cursor: pointer; }
.mg-find-board.pickable .mg-cup:hover .mg-cup-body { transform: translateY(-8px); }

.mg-cup .mg-find-pet-canvas {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 34px;
  width: 56px;
  height: 56px;
  opacity: 0;
  transition: opacity 0.2s 0.1s;
}

.mg-cup.mg-cup-reveal .mg-find-pet-canvas { opacity: 1; }

.mg-sub {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin: -6px 0 10px;
}

.mg-score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-weight: 800;
}

.mg-side { color: var(--ink-soft); font-size: 0.95rem; }
.mg-side.you { color: #f25d9c; }
.mg-side.pet { color: #7ba7d9; }

.mg-score b {
  display: grid;
  place-items: center;
  min-width: 2em;
  height: 2em;
  border-radius: 12px;
  background: #fdf4fa;
  box-shadow: inset 0 0 0 2px #f3e2ef;
  font-size: 1.2rem;
  color: var(--ink);
}

.mg-score b.mg-pop { animation: mg-score-pop 0.45s cubic-bezier(.34,1.56,.64,1); }

@keyframes mg-score-pop {
  40% { transform: scale(1.35); background: #ffe3f0; }
}

.mg-status {
  text-align: center;
  min-height: 1.5em;
  margin: 8px 0;
  color: var(--ink-soft);
  font-weight: 600;
}

.mg-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: min(76vw, 290px);
  margin: 0 auto 14px;
}

.mg-board.mg-shake { animation: mg-shake 0.5s ease; }
.mg-board.mg-tada { animation: mg-tada 0.55s ease; }

@keyframes mg-shake {
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

@keyframes mg-tada {
  30% { transform: scale(1.05) rotate(2deg); }
  60% { transform: scale(1.05) rotate(-2deg); }
}

.mg-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: 16px;
  background: #fdf4fa;
  box-shadow: inset 0 0 0 2px #f3e2ef;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s, transform 0.12s;
  overflow: hidden;
}

.mg-cell:hover:not(:disabled) { background: #fce9f5; }
.mg-cell:disabled { cursor: default; }

/* ghost mark preview while hovering an empty cell */
.mg-cell:not(:disabled)::after {
  content: "✕";
  font-size: 1.6rem;
  font-weight: 800;
  color: rgba(242, 93, 156, 0.28);
  opacity: 0;
  transition: opacity 0.15s;
}
.mg-cell:not(:disabled):hover::after { opacity: 1; }

/* the marks — X = you, O = your pet */
.mg-mark {
  position: absolute;
  pointer-events: none;
}

.mark-x {
  width: 46%;
  height: 46%;
  transform: rotate(45deg);
  animation: mark-pop 0.42s cubic-bezier(.34,1.56,.64,1);
}
.mark-x::before,
.mark-x::after {
  content: "";
  position: absolute;
  background: #f25d9c;
  border-radius: 99px;
}
.mark-x::before { top: 41%; bottom: 41%; left: 0; right: 0; }
.mark-x::after  { left: 41%; right: 41%; top: 0; bottom: 0; }

.mark-o {
  width: 52%;
  height: 52%;
  border: 5px solid #7ba7d9;
  border-radius: 50%;
  animation: mark-pop 0.42s cubic-bezier(.34,1.56,.64,1);
}

@keyframes mark-pop {
  from { transform: scale(0) rotate(-40deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}

@keyframes mark-pop-o {
  from { transform: scale(0) rotate(40deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}

/* winning cells glow */
.mg-cell.mg-win { background: #ffe0ef; animation: mg-win-pulse 0.6s ease 2; }

@keyframes mg-win-pulse {
  50% { transform: scale(0.93); box-shadow: inset 0 0 0 4px #ffb8dc; }
}

/* the strike-through line of the winning trio */
.mg-line {
  position: absolute;
  height: 7px;
  border-radius: 99px;
  background: linear-gradient(90deg, #f78fb8, #f25d9c);
  box-shadow: 0 0 12px rgba(242, 93, 156, 0.55);
  transform-origin: center;
  transform: scale(0);
  transition: transform 0.45s cubic-bezier(.6,1.8,.5,1) 0.15s;
  z-index: 5;
  pointer-events: none;
}
.mg-line.mg-line-on { transform: scale(1); }

.mg-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mg-foot .danger-btn.secondary { grid-column: 2; }
#mg-restart { grid-column: 1 / -1; }

kbd {
  background: #f4edf2;
  border-radius: 6px;
  border: 1px solid #e3d5de;
  padding: 1px 6px;
  font-family: inherit;
  font-weight: 700;
  color: var(--ink);
}

.header {
  position: relative;
}

.gear {
  position: absolute;
  right: 0;
  top: 4px;
  width: 40px;
  height: 40px;
  border: 2px solid #f0dcea;
  border-radius: 12px;
  background: #fdf4fa;
  font-size: 1.15rem;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s;
}

.gear:hover {
  transform: rotate(25deg) scale(1.08);
  background: #fff;
}

/* ===== Settings modal ===== */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(91, 74, 99, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.modal[hidden] { display: none; }

.modal-card {
  background: var(--card);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(60, 30, 60, 0.35);
  padding: 20px 22px;
  width: min(400px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  text-align: left;
  animation: modal-pop 0.22s ease-out;
}

/* Fixed-height modal: only the characters grid scrolls inside */
.modal-card > * { flex-shrink: 0; }

@keyframes modal-pop {
  from { transform: scale(0.92) translateY(10px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-head h2 { font-size: 1.25rem; }

.close {
  border: none;
  background: #f4edf2;
  color: var(--ink);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s;
}

.close:hover { background: #ecdfec; }

.field {
  display: block;
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

#input-name {
  width: 100%;
  border: 2px solid #f0dcea;
  border-radius: 12px;
  background: #fdf8fc;
  padding: 10px 14px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s;
}

#input-name:focus { border-color: var(--accent); }

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.swatch {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  box-shadow: 0 3px 8px var(--shadow), inset 0 0 0 2px rgba(255,255,255,0.5);
  transition: transform 0.12s ease, border-color 0.15s;
}

.swatch:hover { transform: scale(1.12); }

.swatch.selected {
  border-color: var(--accent-deep);
  transform: scale(1.12);
}

.char-field {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-left: -6px;
  margin-right: -6px;
  padding-left: 6px;
  padding-right: 6px; /* room so the scrollbar doesn't cover the cards */
}

.chars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  align-content: start;
  scrollbar-width: thin;
  scrollbar-color: #e3cfe4 transparent;
}

.chars::-webkit-scrollbar { width: 6px; }
.chars::-webkit-scrollbar-thumb { background: #e3cfe4; border-radius: 999px; }
.chars::-webkit-scrollbar-track { background: transparent; }

.char-card {
  border: 3px solid transparent;
  border-radius: 16px;
  background: #fdf8fc;
  padding: 8px 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, transform 0.12s, background 0.2s;
}

.char-card:hover { transform: translateY(-2px); background: #fff; }

.char-card.selected {
  border-color: var(--accent);
  background: #fff;
}

.char-preview {
  width: 64px;
  height: 64px;
  display: block;
}

.char-card span {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
}

.done-btn {
  width: 100%;
  border: none;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  padding: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 #d95c85;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  margin-top: 4px;
}

.done-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #d95c85;
}

@media (max-width: 400px) {
  .scene { padding: 18px 16px 16px; }
  .actions { grid-template-columns: repeat(2, 1fr); }
}
