:root {
  --sky: #7ec8e3;
  --sky-2: #b8e4f5;
  --grass: #8fd18a;
  --cream: #fff8ef;
  --ink: #2a3340;
  --muted: #5a6a7a;
  --pink: #ff7eb3;
  --lilac: #8b7dff;
  --mint: #3ecf8e;
  --sun: #ffd56a;
  --panel: rgba(255, 248, 239, 0.94);
  --shadow: 0 12px 40px rgba(42, 51, 64, 0.18);
  --radius: 22px;
  --font: 'Nunito', system-ui, sans-serif;
  --display: 'Fredoka', 'Nunito', system-ui, sans-serif;
}

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

html, body {
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 20% 10%, #ffe8f4 0%, transparent 55%),
    radial-gradient(ellipse 70% 45% at 90% 20%, #d8f0ff 0%, transparent 50%),
    linear-gradient(165deg, var(--sky) 0%, var(--sky-2) 42%, #c8ebc0 42.2%, var(--grass) 100%);
  background-attachment: fixed;
}

body {
  min-height: 100svh;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--lilac);
  outline-offset: 3px;
}

#app {
  max-width: 980px;
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1rem;
  margin-bottom: 1rem;
  background: var(--panel);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05rem;
}

.brand-mark { font-size: 1.2rem; }

.money {
  margin-left: auto;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
  background: var(--sun);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  box-shadow: 0 3px 0 rgba(200, 150, 40, 0.35);
}

.icon-btn {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  background: #eef2f7;
  font-size: 1.1rem;
  font-weight: 700;
}
.icon-btn:hover { background: #e0e7f0; }

.screen[hidden] { display: none !important; }
.screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel {
  width: min(100%, 520px);
  background: var(--panel);
  border-radius: var(--radius);
  padding: clamp(1.4rem, 4vw, 2.2rem);
  box-shadow: var(--shadow);
  text-align: center;
}
.panel.wide { width: min(100%, 860px); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  text-align: left;
}
.panel-head h2 { margin: 0; }

h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.2rem, 8vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0.2rem 0 0.8rem;
}

h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin-bottom: 0.5rem;
}

.kicker {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--lilac);
}

.lede {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.5;
  max-width: 38ch;
  margin: 0 auto 1.4rem;
}

.hint {
  color: var(--muted);
  margin-bottom: 1rem;
}

.how-grid {
  display: grid;
  gap: 0.75rem;
  text-align: left;
  margin-bottom: 1.5rem;
}
.how-grid div {
  background: #f3f7fb;
  border-radius: 14px;
  padding: 0.85rem 1rem;
}
.how-grid b {
  display: block;
  font-family: var(--display);
  margin-bottom: 0.2rem;
  color: var(--pink);
}
.how-grid span {
  color: var(--muted);
  font-size: 0.95rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  justify-content: center;
  margin-top: 0.5rem;
}

.primary, .secondary, .task-btn {
  border-radius: 999px;
  padding: 0.75rem 1.35rem;
  font-weight: 800;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.primary:hover, .secondary:hover, .task-btn:hover {
  transform: translateY(-2px);
}
.primary:active, .secondary:active, .task-btn:active {
  transform: translateY(1px);
}

.primary {
  background: var(--pink);
  color: #fff;
  box-shadow: 0 4px 0 #d4558a;
}
.primary:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.secondary {
  background: #eef2f7;
  color: var(--ink);
  box-shadow: 0 3px 0 #cfd6e0;
}

.back-link {
  display: inline-block;
  margin-top: 1.4rem;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}
.back-link:hover { color: var(--lilac); }

/* Pet grid */
.pet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.85rem;
  margin-top: 0.5rem;
}

.pet-card {
  background: #fff;
  border-radius: 18px;
  padding: 0.75rem 0.5rem 1rem;
  box-shadow: 0 6px 0 rgba(42, 51, 64, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  transition: transform 0.15s ease;
}
.pet-card:hover { transform: translateY(-4px); }
.pet-card strong {
  font-family: var(--display);
  font-size: 1rem;
}

.pet-preview {
  display: flex;
  justify-content: center;
  margin: 0.5rem 0 1rem;
}
.pet-preview.big .pet-svg { width: min(220px, 70vw); height: auto; }

.pet-svg .idle-bob {
  animation: bob 2.8s ease-in-out infinite;
  transform-origin: center;
  transform-box: fill-box;
}
.pet-svg .wiggle {
  animation: wiggle 2.2s ease-in-out infinite;
  transform-origin: center;
  transform-box: fill-box;
}
.pet-svg .pet-eyes {
  animation: blink 5s ease-in-out infinite;
  transform-origin: center;
  transform-box: fill-box;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(6deg); }
}
@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  96% { transform: scaleY(0.1); }
}

@media (prefers-reduced-motion: reduce) {
  .pet-svg .idle-bob,
  .pet-svg .wiggle,
  .pet-svg .pet-eyes { animation: none; }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  text-align: left;
  margin-bottom: 1rem;
  font-weight: 700;
}
.field input[type="text"] {
  border: 3px solid #e0e7f0;
  border-radius: 14px;
  padding: 0.8rem 1rem;
  font-size: 1.1rem;
  background: #fff;
}
.field input[type="text"]:focus {
  border-color: var(--lilac);
  outline: none;
}

.customise-controls {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
  text-align: left;
}
.colour-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #f3f7fb;
  border-radius: 14px;
  padding: 0.65rem 0.9rem;
  font-weight: 700;
}
.colour-field input[type="color"] {
  width: 3rem;
  height: 2.4rem;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

/* Hub */
.hub {
  width: min(100%, 720px);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stage {
  position: relative;
  min-height: 280px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 4px solid rgba(255,255,255,0.65);
}

.pet-stage { filter: drop-shadow(0 10px 16px rgba(42,51,64,0.2)); }

.pet-name-tag {
  margin-top: 0.35rem;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.25rem;
  background: rgba(255,248,239,0.9);
  padding: 0.35rem 1rem;
  border-radius: 999px;
}

.hub-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
}

.task-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  background: #fff;
  padding: 0.9rem 0.5rem;
  border-radius: 18px;
  box-shadow: 0 5px 0 rgba(42, 51, 64, 0.1);
  font-family: var(--display);
  font-size: 0.95rem;
}
.task-btn span { font-size: 1.45rem; line-height: 1; }
.task-btn.soft { background: #f3f0ff; }

@media (max-width: 540px) {
  .hub-actions { grid-template-columns: repeat(2, 1fr); }
  .topbar { border-radius: 18px; }
  .brand strong { font-size: 0.95rem; }
}

/* Shop / dress */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  justify-content: center;
}
.tab {
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  font-weight: 800;
  background: #eef2f7;
}
.tab.active {
  background: var(--lilac);
  color: #fff;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.85rem;
}

.shop-card {
  background: #fff;
  border-radius: 16px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  box-shadow: 0 5px 0 rgba(42, 51, 64, 0.08);
  text-align: center;
}
.shop-card strong { font-family: var(--display); }
.shop-card .price {
  font-weight: 800;
  color: var(--pink);
}
.shop-card .desc {
  font-size: 0.85rem;
  color: var(--muted);
}
.shop-card .primary { width: 100%; margin-top: 0.35rem; padding: 0.55rem; font-size: 0.9rem; }

.shop-thumb {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.house-thumb {
  width: 100%;
  height: 72px;
  border-radius: 12px;
}

.dress-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  text-align: left;
}
.dress-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  background: #f3f7fb;
  border-radius: 14px;
  padding: 0.75rem 1rem;
  width: 100%;
}
.dress-item.on {
  background: #ebe6ff;
  box-shadow: inset 0 0 0 2px var(--lilac);
}
.dress-item span {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

/* Minigames */
.minigame-panel { width: min(100%, 720px); }
.minigame-stage {
  min-height: 220px;
  background: #f7fbff;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}
.minigame-bar {
  height: 14px;
  background: #e0e7f0;
  border-radius: 999px;
  overflow: hidden;
}
.minigame-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--mint), var(--sun));
  transition: width 0.12s linear;
}
.minigame-score {
  margin-top: 0.45rem;
  font-weight: 800;
  color: var(--muted);
}

.groom-area, .walk-area, .play-area {
  position: relative;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
}
.groom-tip {
  margin-top: 0.4rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
}
.brush {
  position: absolute;
  font-size: 2rem;
  pointer-events: none;
  transform: translate(-40%, -60%) rotate(-25deg);
  opacity: 0;
  transition: opacity 0.15s;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.2));
}
.brush.show { opacity: 1; }

.walk-area canvas,
.play-area canvas {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  display: block;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%) translateY(120%);
  background: var(--ink);
  color: #fff;
  padding: 0.75rem 1.2rem;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 50;
  max-width: min(90vw, 420px);
  text-align: center;
}
#toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ----- Illustrated expansion ----- */
.pet-art-slot {
  display: grid;
  place-items: center;
}

.pet-art-loading {
  width: min(var(--pet-art-size, 250px), 70vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, #ffb2d1, #8b7dff);
  box-shadow: 0 8px 22px rgba(42, 51, 64, .16);
  font-size: clamp(1.8rem, 8vw, 3.4rem);
  animation: loading-paw 1.2s ease-in-out infinite;
}

.pet-art-unavailable {
  animation: none;
  opacity: .72;
}

.pet-art-image {
  display: block;
  width: min(var(--pet-art-size, 250px), 70vw);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 12px rgba(20, 25, 35, .24));
}

.pet-art-bob {
  animation: illustrated-bob 3s ease-in-out infinite;
}

.champion-art {
  filter:
    drop-shadow(0 0 8px #fff)
    drop-shadow(0 0 16px #ffd56a)
    drop-shadow(0 12px 14px rgba(20, 25, 35, .25));
}

@keyframes illustrated-bob {
  0%, 100% { transform: translateY(0) rotate(-.5deg); }
  50% { transform: translateY(-7px) rotate(.5deg); }
}

@keyframes loading-paw {
  0%, 100% { transform: scale(.94); opacity: .7; }
  50% { transform: scale(1); opacity: 1; }
}

.stage {
  min-height: 0;
  aspect-ratio: 16 / 9;
  background-size: cover !important;
  background-position: center !important;
  justify-content: flex-end;
  padding-bottom: 7%;
  isolation: isolate;
}

.stage::after {
  content: "";
  position: absolute;
  inset: 45% 0 0;
  z-index: -1;
  background: linear-gradient(transparent, rgba(24, 22, 32, .2));
  pointer-events: none;
}

.pet-stage {
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  z-index: 2;
}

.stage.pet-fish .pet-stage { bottom: 20%; }
.stage.pet-giraffe .pet-stage { bottom: 5%; }
.stage.pet-gecko .pet-stage,
.stage.pet-turtle .pet-stage { bottom: 6%; }

.pet-name-tag {
  position: absolute;
  left: 50%;
  bottom: 2%;
  z-index: 3;
  transform: translateX(-50%);
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(30, 25, 40, .18);
}

.home-trophy {
  position: absolute;
  right: 4%;
  bottom: 5%;
  z-index: 3;
  font-size: clamp(2rem, 7vw, 4.2rem);
  filter: drop-shadow(0 6px 8px rgba(30, 25, 40, .35));
}

.room-tabs {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding: .25rem .15rem .5rem;
  scrollbar-width: thin;
}

.room-tab {
  flex: 0 0 auto;
  padding: .55rem .9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .86);
  font-weight: 800;
  box-shadow: 0 3px 0 rgba(42, 51, 64, .1);
}

.room-tab.active {
  color: #fff;
  background: var(--lilac);
}

.badge-panel {
  padding: .85rem 1rem;
  border-radius: 18px;
  background: rgba(255, 248, 239, .94);
  box-shadow: var(--shadow);
}

.badge-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: .65rem;
  font-family: var(--display);
}

.badge-panel-head span {
  color: var(--lilac);
  font-weight: 800;
}

.badge-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: .45rem;
}

.care-badge {
  display: grid;
  place-items: center;
  min-height: 58px;
  padding: .3rem;
  border-radius: 12px;
  color: #87909b;
  background: #e9edf2;
  filter: grayscale(1);
  opacity: .62;
  text-align: center;
}

.care-badge.earned {
  color: var(--ink);
  background: linear-gradient(145deg, #fff4b9, #ffd56a);
  filter: none;
  opacity: 1;
  box-shadow: 0 3px 0 #d9a735;
}

.care-badge b {
  display: block;
  font-size: 1.25rem;
  line-height: 1;
}

.care-badge small {
  display: block;
  margin-top: .2rem;
  font-size: .67rem;
  font-weight: 800;
}

.gala-btn {
  display: block;
  margin: .85rem auto 0;
}

.gala-hint {
  margin: .7rem 0 0;
  color: var(--muted);
  font-size: .83rem;
  text-align: center;
}

.task-btn img {
  width: 2.15rem;
  height: 2.15rem;
}

.look-thumb {
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
}

.look-thumb .pet-art-image {
  width: 112px;
}

.look-source {
  min-height: 1.2rem;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
}

.house-thumb {
  height: 92px;
  background-size: cover !important;
  background-position: center !important;
}

.dress-list {
  max-height: min(46vh, 430px);
  overflow-y: auto;
  padding-right: .2rem;
}

.dress-item {
  display: grid;
  grid-template-columns: 74px 1fr auto;
  align-items: center;
  gap: .65rem;
}

.dress-item .mini-look {
  width: 70px;
  height: 70px;
}

.dress-item .mini-look .pet-art-image {
  width: 70px;
}

.dress-copy {
  display: flex;
  flex-direction: column;
}

.dress-state {
  font-weight: 800;
  color: var(--lilac);
}

.locked-look {
  opacity: .58;
}

.minigame-panel {
  width: min(100%, 860px);
}

.minigame-panel:has(.chess-game),
.minigame-panel:has(.colouring-game) {
  width: min(100%, 960px);
}

.game-instruction {
  color: var(--muted);
  font-weight: 700;
  margin: .45rem 0 .8rem;
}

.play-pet-corner {
  position: absolute;
  left: .45rem;
  bottom: 1.8rem;
  z-index: 2;
  pointer-events: none;
}

.play-pet-corner .pet-art-image {
  width: 105px;
}

/* Cooking */
.cooking-game {
  padding: 1rem;
}

.cooking-centre {
  min-height: 310px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .7rem;
}

.recipe-card,
.ingredient-card,
.decorate-btn {
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 4px 0 rgba(42, 51, 64, .11);
}

.recipe-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  padding: .8rem;
}

.recipe-card:hover,
.ingredient-card:hover,
.decorate-btn:hover {
  transform: translateY(-2px);
}

.recipe-card img,
.ingredient-card img,
.finished-dish {
  object-fit: contain;
}

.recipe-card span {
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.25;
}

.recipe-progress {
  display: grid;
  grid-template-columns: minmax(120px, .7fr) 2fr;
  align-items: center;
  gap: .8rem;
  padding: .65rem .8rem;
  border-radius: 14px;
  background: #fff;
  text-align: left;
}

.eyebrow {
  display: block;
  color: var(--lilac);
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.recipe-progress ol {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  list-style-position: inside;
}

.recipe-progress li {
  padding: .25rem .45rem;
  border-radius: 999px;
  color: var(--muted);
  background: #edf1f5;
  font-size: .72rem;
  font-weight: 800;
}

.recipe-progress li.done {
  color: #226347;
  background: #c9f2df;
}

.recipe-progress li.next {
  color: #4b3f9b;
  background: #e5e0ff;
}

.ingredient-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: .45rem;
}

.ingredient-card {
  min-width: 0;
  padding: .35rem;
  font-size: .72rem;
  font-weight: 800;
}

.ingredient-card img {
  display: block;
  width: 100%;
  height: auto;
}

.ingredient-card.wrong {
  animation: wrong-shake .3s linear;
  box-shadow: 0 0 0 3px #ff6b6b;
}

@keyframes wrong-shake {
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.mixing-bowl {
  position: relative;
  font-size: 5rem;
}

.mixing-bowl i {
  position: absolute;
  width: 9px;
  height: 70px;
  left: 58%;
  top: -20px;
  border-radius: 8px;
  background: #9a643d;
  transform: rotate(25deg);
  transform-origin: bottom;
}

.mixing-bowl.stir i {
  animation: stir .25s ease;
}

@keyframes stir {
  50% { transform: rotate(-32deg); }
}

.decorate-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .65rem;
}

.decorate-btn {
  padding: .8rem 1rem;
  font-weight: 800;
}

/* Colouring */
.colouring-game {
  padding: .7rem;
}

.colouring-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: .55rem;
}

.colouring-tools label {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-weight: 800;
}

.colouring-tools select {
  border: 2px solid #d7ddea;
  border-radius: 10px;
  padding: .45rem;
  background: #fff;
  font: inherit;
}

.palette {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .35rem;
}

.colour-swatch {
  width: 32px;
  height: 32px;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(42, 51, 64, .3);
}

.colour-swatch.selected {
  outline: 3px solid var(--ink);
  transform: scale(1.1);
}

.colour-canvas-wrap {
  position: relative;
  max-width: 760px;
  margin: 0 auto .65rem;
  border: 4px solid #fff;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 5px 18px rgba(42, 51, 64, .15);
}

#colour-canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}

.canvas-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(255, 255, 255, .88);
  font-weight: 800;
}

.canvas-loading[hidden] { display: none; }

/* Chess */
.chess-game {
  position: relative;
  padding: .65rem;
}

.chess-status {
  min-height: 2.6rem;
  display: grid;
  place-items: center;
  margin-bottom: .55rem;
  border-radius: 12px;
  background: #fff;
  font-family: var(--display);
  font-weight: 700;
}

.chess-board {
  width: min(100%, 600px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  margin: 0 auto;
  border: 8px solid #5c426f;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(42, 31, 54, .28);
}

.chess-square {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  overflow: hidden;
}

.chess-square.light { background: #f7e7bf; }
.chess-square.dark { background: #ad82c1; }
.chess-square.selected { box-shadow: inset 0 0 0 5px #4ec4e8; }
.chess-square.in-check { box-shadow: inset 0 0 0 5px #ff4e68; }

.chess-square.legal::after,
.chess-square.capture::after {
  content: "";
  position: absolute;
  z-index: 3;
  width: 24%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(35, 121, 83, .65);
}

.chess-square.capture::after {
  width: 82%;
  border: 5px solid rgba(195, 54, 74, .76);
  background: transparent;
}

.chess-glyph {
  position: relative;
  z-index: 2;
  font-size: clamp(1.6rem, 7vw, 3.8rem);
  line-height: 1;
  text-shadow: 0 2px 2px rgba(0, 0, 0, .2);
}

.chess-piece-image {
  position: relative;
  z-index: 2;
  width: 94%;
  height: 94%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(30, 20, 45, .3));
}

.chess-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .6rem;
  margin-top: .7rem;
}

.promotion-picker {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(42, 31, 54, .78);
  backdrop-filter: blur(4px);
}

.promotion-card {
  width: min(100%, 430px);
  padding: 1.2rem;
  border-radius: 18px;
  background: var(--cream);
  box-shadow: 0 14px 45px rgba(20, 12, 30, .38);
}

.promotion-card p {
  margin: .3rem 0 .9rem;
  color: var(--muted);
}

.promotion-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .55rem;
}

.promotion-choice {
  display: grid;
  place-items: center;
  gap: .2rem;
  padding: .65rem .35rem;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 0 rgba(42, 51, 64, .15);
  text-transform: capitalize;
}

.promotion-choice span {
  font-size: clamp(2rem, 8vw, 3.2rem);
  line-height: 1;
}

/* Pet Gala */
.finale-stage {
  position: relative;
  width: min(100%, 960px);
  min-height: min(82vh, 680px);
  border: 5px solid rgba(255, 255, 255, .7);
  border-radius: var(--radius);
  overflow: hidden;
  background: #3b1f59 url("../assets/finale/ru-gala-room.png") center / cover no-repeat;
  box-shadow: var(--shadow);
}

.finale-confetti {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.finale-pet {
  position: absolute;
  left: 24%;
  bottom: 8%;
  z-index: 3;
  transform: translateX(-50%);
}

.finale-pet .pet-art-image {
  width: min(300px, 34vw);
}

.finale-award {
  position: absolute;
  right: 3%;
  bottom: 4%;
  z-index: 4;
  width: min(48%, 420px);
  padding: clamp(.8rem, 2vw, 1.3rem);
  border-radius: 18px;
  background: rgba(255, 248, 239, .94);
  text-align: center;
  box-shadow: 0 15px 45px rgba(28, 12, 43, .35);
}

.finale-award h2 {
  font-size: clamp(1.25rem, 3vw, 1.8rem);
}

.finale-award p {
  margin: .35rem 0 .7rem;
  color: var(--muted);
  font-size: .9rem;
}

.finale-trophy {
  width: clamp(80px, 12vw, 130px);
  height: auto;
  margin-top: -4rem;
}

.certificate {
  position: relative;
  width: min(100%, 280px);
  margin: -.4rem auto .35rem;
}

.certificate > img {
  display: block;
  width: 100%;
}

.certificate-copy {
  position: absolute;
  inset: 24% 17% 18%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #67421e;
  font-family: var(--display);
}

.certificate-copy span { font-size: .72rem; }
.certificate-copy strong { font-size: clamp(1rem, 3vw, 1.45rem); }
.certificate-copy small { margin-top: .2rem; font-size: .58rem; }

@media (max-width: 680px) {
  #app { padding-inline: .6rem; }
  .badge-strip { grid-template-columns: repeat(3, 1fr); }
  .hub-actions { grid-template-columns: repeat(3, 1fr); }
  .task-btn { font-size: .82rem; }
  .recipe-grid { grid-template-columns: 1fr; }
  .recipe-card { display: grid; grid-template-columns: 85px 1fr; text-align: left; }
  .recipe-card img { grid-row: span 2; width: 85px; height: 85px; }
  .ingredient-grid { grid-template-columns: repeat(4, 1fr); }
  .recipe-progress { grid-template-columns: 1fr; }
  .finale-stage { min-height: 720px; }
  .finale-pet {
    left: 50%;
    bottom: 47%;
  }
  .finale-pet .pet-art-image { width: min(250px, 60vw); }
  .finale-award {
    right: 4%;
    bottom: 3%;
    width: 92%;
  }
}

@media (max-width: 440px) {
  .panel { padding: 1rem; }
  .stage { aspect-ratio: 4 / 3; }
  .pet-art-image { width: min(200px, 43vw); }
  .stage .pet-art-image { width: min(180px, 43vw); }
  .ingredient-grid { grid-template-columns: repeat(3, 1fr); }
  .colouring-tools .secondary { padding: .45rem .7rem; }
  .chess-board { border-width: 5px; }
  .chess-square.selected { box-shadow: inset 0 0 0 3px #4ec4e8; }
}

@media (prefers-reduced-motion: reduce) {
  .pet-art-bob,
  .pet-art-loading { animation: none; }
}
