:root {
  --bg: #ecfbff;
  --paper: #fffdf7;
  --ink: #24313a;
  --muted: #65717a;
  --blue: #2f80ed;
  --green: #4ecb8f;
  --purple: #9b8cff;
  --pink: #ff8fab;
  --gold: #f4b942;
  font-family: ui-rounded, "Avenir Next", "Nunito", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 14%, rgba(255,209,102,.38), transparent 28%),
    radial-gradient(circle at 82% 9%, rgba(155,140,255,.28), transparent 28%),
    linear-gradient(180deg, #ecfbff, #fff8e8);
}
button, input { font: inherit; }
.game-header {
  width: min(1120px, calc(100% - 28px));
  margin: 16px auto 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.home-link, .soft-button {
  border: 0;
  text-decoration: none;
  border-radius: 999px;
  padding: 12px 16px;
  color: #17456e;
  background: rgba(255,255,255,.78);
  font-weight: 950;
  box-shadow: 0 10px 25px rgba(36,49,58,.08);
  cursor: pointer;
}
.game-shell { width: min(1120px, calc(100% - 28px)); margin: 22px auto 40px; }
.start-panel {
  min-height: calc(100dvh - 120px);
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 26px;
  align-items: center;
}
.kicker {
  display: inline-flex;
  margin: 0 0 16px;
  padding: 8px 13px;
  border-radius: 999px;
  background: #fff;
  color: #1559b7;
  font-weight: 950;
}
h1 { font-size: clamp(3.1rem, 7vw, 6.4rem); line-height: .9; letter-spacing: -.07em; margin: 0 0 20px; max-width: 8ch; }
h2 { font-size: clamp(2rem, 4vw, 3.4rem); line-height: .92; letter-spacing: -.055em; margin: 0; }
p { color: var(--muted); line-height: 1.55; font-size: 1.08rem; max-width: 34rem; }
.hatch-form, .care-panel {
  background: rgba(255,253,247,.9);
  border: 4px solid rgba(255,255,255,.72);
  border-radius: 34px;
  padding: 24px;
  box-shadow: 0 22px 60px rgba(47,128,237,.16);
}
.hatch-form label, legend { font-weight: 950; color: var(--ink); }
input {
  width: 100%;
  margin: 8px 0 18px;
  border: 3px solid rgba(47,128,237,.18);
  border-radius: 18px;
  padding: 14px 15px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(47,128,237,.14); }
fieldset { border: 0; padding: 0; margin: 0 0 20px; }
.egg-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.egg-options label {
  display: flex; align-items: center; gap: 8px;
  background: #f5f9fc;
  border-radius: 18px;
  padding: 10px;
  cursor: pointer;
}
.egg-options input { width: auto; margin: 0; }
.egg { font-size: 1.8rem; filter: drop-shadow(0 6px 6px rgba(36,49,58,.12)); }
.green { color: var(--green); }
.purple { color: var(--purple); }
.pink { color: var(--pink); }
.gold { color: var(--gold); }
.main-button {
  width: 100%; border: 0; border-radius: 999px; padding: 15px 18px;
  color: #fff; background: var(--blue); font-weight: 950;
  box-shadow: 0 14px 28px rgba(47,128,237,.25); cursor: pointer;
}
.play-panel { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 24px; align-items: stretch; }
.hidden { display: none; }
.dragon-stage {
  position: relative;
  min-height: calc(100dvh - 118px);
  border-radius: 42px;
  overflow: hidden;
  background: linear-gradient(180deg, #bcefff, #eafff7 65%, #b7efc5);
  box-shadow: 0 22px 60px rgba(47,128,237,.18);
  border: 5px solid rgba(255,255,255,.72);
}
.sky-piece { position: absolute; border-radius: 999px; background: rgba(255,255,255,.78); }
.sky-piece.one { width: 210px; height: 76px; left: 45px; top: 65px; }
.sky-piece.two { width: 170px; height: 64px; right: 38px; top: 145px; }
.dragon {
  --dragon-color: #4ecb8f;
  --dragon-dark: #2f9f73;
  --dragon-light: #8ee8bd;
  --dragon-scale: .82;
  position: absolute;
  width: min(500px, 86%);
  aspect-ratio: 520 / 360;
  left: 50%;
  top: 55%;
  transform: translate(-50%, -50%) scale(var(--dragon-scale));
  transform-origin: 50% 72%;
  transition: left .65s ease, top .65s ease, transform .65s ease;
}
.dragon.teen { --dragon-scale: .96; }
.dragon.adult { --dragon-scale: 1.1; }
.dragon.elder { --dragon-scale: 1.22; }
.dragon.purple { --dragon-color: #9b8cff; --dragon-dark: #6a5fd0; --dragon-light: #c8c1ff; }
.dragon.pink { --dragon-color: #ff8fab; --dragon-dark: #d9577c; --dragon-light: #ffc0d0; }
.dragon.gold { --dragon-color: #f4b942; --dragon-dark: #c98918; --dragon-light: #ffd979; }
.dragon.adult .horn, .dragon.elder .horn { transform-box: fill-box; transform-origin: center bottom; transform: scale(1.15); }
.dragon.elder .spike, .dragon.elder .head-spike { transform-box: fill-box; transform-origin: center bottom; transform: scale(1.14); }
.dragon-art {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.body-path, .neck-path, .head-path, .snout-path, .tail-path, .front-leg, .rear-leg, .front-foot, .rear-foot {
  fill: var(--dragon-color);
  stroke: var(--dragon-dark);
  stroke-width: 7;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.body-path, .head-path, .neck-path {
  fill: var(--dragon-color);
}
.snout-path, .lower-jaw {
  fill: var(--dragon-light);
  stroke: var(--dragon-dark);
  stroke-width: 6;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.tail-path {
  fill: none;
  stroke: var(--dragon-dark);
  stroke-width: 48;
  stroke-linecap: round;
}
.front-wing, .back-wing {
  fill: var(--dragon-light);
  stroke: var(--dragon-dark);
  stroke-width: 7;
  stroke-linejoin: round;
  opacity: .95;
}
.back-wing { opacity: .55; }
.front-wing-line, .back-wing-line {
  fill: none;
  stroke: rgba(255,255,255,.45);
  stroke-width: 8;
  stroke-linecap: round;
}
.belly-path {
  fill: #ffe99d;
  stroke: rgba(36,49,58,.16);
  stroke-width: 5;
}
.horn, .spike, .head-spike {
  fill: #fff3b0;
  stroke: #d79a2b;
  stroke-width: 5;
  stroke-linejoin: round;
}
.eye-white { fill: #fffdf7; stroke: rgba(36,49,58,.2); stroke-width: 4; }
.pupil, .nostril { fill: #20313b; }
.brow-line, .mouth-line, .claws {
  fill: none;
  stroke: #20313b;
  stroke-width: 6;
  stroke-linecap: round;
}
.claws { stroke: #fff3b0; }
.flame-breath {
  opacity: 0;
  transform-origin: 520px 150px;
  fill: #ff623e;
}
.flame-breath path:nth-child(2) { fill: #ffd166; }
.dragon.spark .flame-breath { opacity: 1; }
.dragon.sleepy .front-wing { transform: rotate(4deg); transform-origin: 230px 190px; }
.dragon.feed-action .mouth-line { stroke-width: 9; }
.dragon.nap-action {
  left: 25%;
  top: 72%;
  transform: translate(-50%, -50%) scale(calc(var(--dragon-scale) * .72)) rotate(-5deg);
}
.dragon.play-action { transform: translate(-50%, -50%) scale(var(--dragon-scale)) rotate(-3deg); }
.bed {
  position: absolute;
  left: 28px;
  bottom: 30px;
  width: 210px;
  height: 92px;
  border-radius: 28px;
  background: #fffdf7;
  box-shadow: 0 18px 35px rgba(36,49,58,.12);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .35s ease, transform .35s ease;
  z-index: 0;
}
.bed:before {
  content: "";
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 14px;
  height: 34px;
  border-radius: 16px;
  background: #9b8cff;
}
.pillow {
  position: absolute;
  left: 22px;
  top: 13px;
  width: 70px;
  height: 36px;
  border-radius: 14px;
  background: #eafff7;
}
.blanket {
  position: absolute;
  right: 16px;
  bottom: 10px;
  width: 120px;
  height: 52px;
  border-radius: 20px;
  background: linear-gradient(135deg, #ff8fab, #ffd166);
}
.sleep-bubble {
  position: absolute;
  left: 132px;
  top: -25px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #fff;
  color: #1559b7;
  font-weight: 950;
  opacity: 0;
}
.dragon-stage.nap-mode .bed { opacity: 1; transform: translateY(0); }
.dragon-stage.nap-mode .sleep-bubble { opacity: 1; }
.food-snack, .play-ball {
  position: absolute;
  font-size: 2.4rem;
  opacity: 0;
  z-index: 3;
  pointer-events: none;
}
.food-snack { left: 62%; top: 56%; }
.play-ball { left: 58%; top: 72%; }
.dragon-stage.feed-mode .food-snack { animation: feed-snack 1.05s ease forwards; }
.dragon-stage.play-mode .play-ball { animation: play-ball 1.1s ease forwards; }

.name-row { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.coins { display: flex; align-items: center; gap: 6px; border-radius: 999px; padding: 10px 14px; background: #fff4ca; color: #704f08; font-weight: 950; }
.message { min-height: 54px; margin: 18px 0; padding: 14px; border-radius: 20px; background: #f2f8ff; color: #35526d; font-weight: 800; }
.stat-list { display: grid; gap: 13px; }
.stat { display: grid; grid-template-columns: 70px 1fr 40px; gap: 10px; align-items: center; font-weight: 950; }
.meter { height: 16px; border-radius: 999px; background: #e8eef3; overflow: hidden; }
.meter i { display: block; height: 100%; width: 80%; border-radius: inherit; background: linear-gradient(90deg, var(--green), var(--blue)); transition: width .24s ease; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.actions button, .shop-buttons button {
  border: 0; border-radius: 18px; padding: 14px 12px;
  background: #fff; color: #17456e; font-weight: 950;
  box-shadow: 0 8px 18px rgba(36,49,58,.08); cursor: pointer;
}
.actions button:hover, .shop-buttons button:hover, .soft-button:hover { transform: translateY(-1px); }
.shop { margin-top: 20px; padding-top: 18px; border-top: 2px solid rgba(36,49,58,.08); }
.shop h3 { margin: 0 0 10px; }
.shop-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 880px) {
  .start-panel, .play-panel { grid-template-columns: 1fr; min-height: auto; }
  .dragon-stage { min-height: 440px; }
  .care-panel { order: -1; }
  h1 { max-width: 9ch; }
}
@media (prefers-reduced-motion: no-preference) {
  .dragon.happy:not(.nap-action):not(.play-action) { animation: bob 2.8s ease-in-out infinite; }
  .dragon.sleepy:not(.nap-action) { animation: sleepy 3s ease-in-out infinite; }
  .dragon.excited:not(.nap-action) { animation: excited .55s ease-in-out 5; }
  @keyframes bob { 0%,100% { transform: translate(-50%, -50%) scale(var(--dragon-scale)); } 50% { transform: translate(-50%, calc(-50% - 12px)) scale(var(--dragon-scale)); } }
  @keyframes sleepy { 0%,100% { transform: translate(-50%, -50%) scale(var(--dragon-scale)) rotate(-2deg); } 50% { transform: translate(-50%, calc(-50% + 6px)) scale(var(--dragon-scale)) rotate(2deg); } }
  @keyframes excited { 0%,100% { transform: translate(-50%, -50%) scale(var(--dragon-scale)); } 50% { transform: translate(-50%, -50%) scale(calc(var(--dragon-scale) * 1.08)); } }
  @keyframes feed-snack { 0% { opacity: 0; transform: translate(-110px, 80px) scale(.8); } 25% { opacity: 1; } 72% { opacity: 1; transform: translate(38px, -72px) scale(.55); } 100% { opacity: 0; transform: translate(60px, -82px) scale(.2); } }
  @keyframes play-ball { 0% { opacity: 0; transform: translate(-130px, 20px) scale(.7); } 20% { opacity: 1; } 50% { transform: translate(-30px, -95px) scale(1); } 80% { opacity: 1; transform: translate(90px, 0) scale(.85); } 100% { opacity: 0; transform: translate(120px, 30px) scale(.6); } }
}
