:root {
  color-scheme: light;
  --bg: #fff8ec;
  --body-start: #fff8ec;
  --body-end: #edf9ff;
  --panel: #fffaf1;
  --card-bg: rgba(255, 250, 241, 0.92);
  --choice-bg: rgba(255, 255, 255, 0.82);
  --field-bg: #fff;
  --input-border: rgba(81, 104, 244, 0.28);
  --ink: #2b251d;
  --muted: #6c6256;
  --primary: #5168f4;
  --primary-dark: #2e3fb4;
  --primary-soft: rgba(81, 104, 244, 0.14);
  --primary-wash: rgba(81, 104, 244, 0.07);
  --primary-border: rgba(81, 104, 244, 0.28);
  --selected-shadow: rgba(81, 104, 244, 0.2);
  --secondary: #f7a94b;
  --secondary-soft: rgba(247, 169, 75, 0.22);
  --share-bg: rgba(247, 169, 75, 0.16);
  --green: #52c06d;
  --green-soft: rgba(82, 192, 109, 0.18);
  --danger: #d94c45;
  --shadow: 0 18px 40px rgba(43, 37, 29, 0.12);
}

body[data-theme="theme-ocean"] {
  --body-start: #e6fbff;
  --body-end: #d8f3ef;
  --card-bg: rgba(240, 253, 255, 0.94);
  --choice-bg: rgba(255, 255, 255, 0.86);
  --field-bg: #f8feff;
  --input-border: rgba(20, 122, 159, 0.28);
  --ink: #12313c;
  --muted: #526f78;
  --primary: #147a9f;
  --primary-dark: #0f5d7a;
  --primary-soft: rgba(20, 122, 159, 0.14);
  --primary-wash: rgba(20, 122, 159, 0.08);
  --primary-border: rgba(20, 122, 159, 0.3);
  --selected-shadow: rgba(20, 122, 159, 0.22);
  --secondary: #2ec4b6;
  --secondary-soft: rgba(46, 196, 182, 0.22);
  --share-bg: rgba(46, 196, 182, 0.16);
  --green: #22a06b;
  --green-soft: rgba(34, 160, 107, 0.18);
  --danger: #e14d6f;
}

body[data-theme="theme-space"] {
  color-scheme: dark;
  --body-start: #0f172a;
  --body-end: #312e81;
  --card-bg: rgba(17, 24, 39, 0.9);
  --choice-bg: rgba(30, 41, 59, 0.88);
  --field-bg: #111827;
  --input-border: rgba(124, 58, 237, 0.42);
  --ink: #f8fafc;
  --muted: #cbd5e1;
  --primary: #8b5cf6;
  --primary-dark: #c4b5fd;
  --primary-soft: rgba(139, 92, 246, 0.24);
  --primary-wash: rgba(139, 92, 246, 0.16);
  --primary-border: rgba(139, 92, 246, 0.42);
  --selected-shadow: rgba(139, 92, 246, 0.3);
  --secondary: #facc15;
  --secondary-soft: rgba(250, 204, 21, 0.22);
  --share-bg: rgba(250, 204, 21, 0.16);
  --green: #38bdf8;
  --green-soft: rgba(56, 189, 248, 0.2);
  --danger: #fb7185;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.26);
}

body[data-theme="theme-candy"] {
  --body-start: #fff1f8;
  --body-end: #dcfce7;
  --card-bg: rgba(255, 247, 253, 0.94);
  --choice-bg: rgba(255, 255, 255, 0.86);
  --field-bg: #fff;
  --input-border: rgba(236, 72, 153, 0.28);
  --ink: #402034;
  --muted: #7a5a70;
  --primary: #ec4899;
  --primary-dark: #be185d;
  --primary-soft: rgba(236, 72, 153, 0.14);
  --primary-wash: rgba(236, 72, 153, 0.08);
  --primary-border: rgba(236, 72, 153, 0.3);
  --selected-shadow: rgba(236, 72, 153, 0.22);
  --secondary: #8b5cf6;
  --secondary-soft: rgba(139, 92, 246, 0.2);
  --share-bg: rgba(94, 234, 212, 0.24);
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.18);
  --danger: #f43f5e;
}

body[data-theme="theme-forest"] {
  --body-start: #f3f7e8;
  --body-end: #d9ead3;
  --card-bg: rgba(252, 250, 237, 0.94);
  --choice-bg: rgba(255, 255, 248, 0.86);
  --field-bg: #fffdf2;
  --input-border: rgba(47, 111, 62, 0.28);
  --ink: #21351f;
  --muted: #63705a;
  --primary: #2f6f3e;
  --primary-dark: #1f5130;
  --primary-soft: rgba(47, 111, 62, 0.14);
  --primary-wash: rgba(47, 111, 62, 0.08);
  --primary-border: rgba(47, 111, 62, 0.3);
  --selected-shadow: rgba(47, 111, 62, 0.22);
  --secondary: #9a6b34;
  --secondary-soft: rgba(154, 107, 52, 0.22);
  --share-bg: rgba(132, 204, 22, 0.18);
  --green: #65a30d;
  --green-soft: rgba(101, 163, 13, 0.18);
  --danger: #b45309;
}

body[data-theme="theme-volcano"] {
  color-scheme: dark;
  --body-start: #1f1f24;
  --body-end: #451a03;
  --card-bg: rgba(38, 38, 42, 0.92);
  --choice-bg: rgba(55, 55, 60, 0.88);
  --field-bg: #2a2a2f;
  --input-border: rgba(249, 115, 22, 0.4);
  --ink: #fff7ed;
  --muted: #fed7aa;
  --primary: #f97316;
  --primary-dark: #fdba74;
  --primary-soft: rgba(249, 115, 22, 0.22);
  --primary-wash: rgba(249, 115, 22, 0.16);
  --primary-border: rgba(249, 115, 22, 0.4);
  --selected-shadow: rgba(249, 115, 22, 0.3);
  --secondary: #ef4444;
  --secondary-soft: rgba(239, 68, 68, 0.24);
  --share-bg: rgba(239, 68, 68, 0.18);
  --green: #facc15;
  --green-soft: rgba(250, 204, 21, 0.18);
  --danger: #fb7185;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

body[data-theme="theme-arctic"] {
  --body-start: #f0fbff;
  --body-end: #dbeafe;
  --card-bg: rgba(255, 255, 255, 0.94);
  --choice-bg: rgba(248, 253, 255, 0.9);
  --field-bg: #ffffff;
  --input-border: rgba(2, 132, 199, 0.28);
  --ink: #0f172a;
  --muted: #475569;
  --primary: #0284c7;
  --primary-dark: #075985;
  --primary-soft: rgba(2, 132, 199, 0.14);
  --primary-wash: rgba(2, 132, 199, 0.08);
  --primary-border: rgba(2, 132, 199, 0.3);
  --selected-shadow: rgba(2, 132, 199, 0.22);
  --secondary: #38bdf8;
  --secondary-soft: rgba(56, 189, 248, 0.22);
  --share-bg: rgba(186, 230, 253, 0.34);
  --green: #0d9488;
  --green-soft: rgba(13, 148, 136, 0.18);
  --danger: #dc2626;
}

body[data-theme="theme-sunset"] {
  --body-start: #fff0d6;
  --body-end: #e0e7ff;
  --card-bg: rgba(255, 247, 237, 0.94);
  --choice-bg: rgba(255, 255, 255, 0.86);
  --field-bg: #fffaf5;
  --input-border: rgba(219, 39, 119, 0.28);
  --ink: #332040;
  --muted: #725c79;
  --primary: #db2777;
  --primary-dark: #9d174d;
  --primary-soft: rgba(219, 39, 119, 0.14);
  --primary-wash: rgba(219, 39, 119, 0.08);
  --primary-border: rgba(219, 39, 119, 0.3);
  --selected-shadow: rgba(219, 39, 119, 0.22);
  --secondary: #4338ca;
  --secondary-soft: rgba(67, 56, 202, 0.18);
  --share-bg: rgba(251, 146, 60, 0.2);
  --green: #059669;
  --green-soft: rgba(5, 150, 105, 0.18);
  --danger: #e11d48;
}

body[data-theme="theme-royal"] {
  --body-start: #fff7db;
  --body-end: #ede9fe;
  --card-bg: rgba(255, 251, 235, 0.94);
  --choice-bg: rgba(255, 255, 255, 0.86);
  --field-bg: #fffdf5;
  --input-border: rgba(109, 40, 217, 0.28);
  --ink: #2e1747;
  --muted: #6d5b7c;
  --primary: #6d28d9;
  --primary-dark: #4c1d95;
  --primary-soft: rgba(109, 40, 217, 0.14);
  --primary-wash: rgba(109, 40, 217, 0.08);
  --primary-border: rgba(109, 40, 217, 0.3);
  --selected-shadow: rgba(109, 40, 217, 0.22);
  --secondary: #d9a82c;
  --secondary-soft: rgba(217, 168, 44, 0.24);
  --share-bg: rgba(244, 197, 66, 0.2);
  --green: #15803d;
  --green-soft: rgba(21, 128, 61, 0.18);
  --danger: #be123c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--body-start) 0%, var(--body-end) 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  width: min(1180px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 1rem 0 2rem;
}

.card {
  margin: 1rem 0;
  padding: 1rem;
  border-radius: 28px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 1rem;
  align-items: center;
}

.hero h1,
.card h2,
.card h3 {
  margin: 0.2rem 0 0.6rem;
}

.eyebrow {
  margin: 0;
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profile-panel {
  display: grid;
  gap: 0.45rem;
}

.profile-row,
.answer-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

input {
  min-width: 0;
  padding: 0.8rem;
  border: 2px solid var(--input-border);
  border-radius: 14px;
  background: var(--field-bg);
  color: var(--ink);
}

textarea {
  width: 100%;
  min-height: 5rem;
  padding: 0.8rem;
  border: 2px solid var(--input-border);
  border-radius: 14px;
  background: var(--field-bg);
  color: var(--ink);
  resize: vertical;
}

.profile-row button,
.answer-form button,
.primary-action,
.secondary-action,
.shop-button {
  padding: 0.82rem 1rem;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.secondary-action,
.shop-button.secondary {
  border: 2px solid var(--primary);
  background: transparent;
  color: var(--primary);
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(280px, 1.15fr) minmax(240px, 0.85fr);
  gap: 1rem;
}

.dog-card {
  text-align: center;
}

.dog-yard {
  position: relative;
  min-height: 310px;
  overflow: hidden;
  border-radius: 28px;
  background: linear-gradient(180deg, #ccefff 0%, #d8f3c3 62%, #b7df86 100%);
}

.yard-art {
  position: absolute;
}

.yard-art svg,
.yard-art img {
  display: block;
  width: 100%;
  height: auto;
}

.layer-bg {
  inset: 0;
}

.layer-bg svg {
  width: 100%;
  height: 100%;
}

.layer-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.layer-sky {
  left: 52%;
  top: 5%;
  width: 28%;
  z-index: 1;
  opacity: 0.95;
}

.layer-house {
  left: 5%;
  bottom: 8%;
  width: 30%;
  z-index: 2;
}

.layer-friend {
  left: 17%;
  bottom: 4%;
  width: 17%;
  z-index: 3;
}

.layer-dog {
  left: 38%;
  bottom: 5%;
  width: 25%;
  z-index: 4;
}

.layer-collar {
  left: 41.25%;
  bottom: 13.5%;
  width: 18.5%;
  z-index: 5;
}

.layer-bowl {
  right: 12%;
  bottom: 6%;
  width: 17%;
  z-index: 6;
}

.layer-food {
  right: 2%;
  bottom: 8%;
  width: 13%;
  z-index: 6;
}

.layer-toy {
  left: 31%;
  bottom: 3%;
  width: 10%;
  z-index: 6;
}

.dog-house {
  position: absolute;
  right: 17%;
  bottom: 87px;
  width: 130px;
  height: 112px;
  border: 6px solid #8d412e;
  border-radius: 18px 18px 8px 8px;
  background: #d46b48;
}

.dog-house::before {
  content: "";
  position: absolute;
  top: -54px;
  left: -18px;
  width: 154px;
  height: 78px;
  clip-path: polygon(50% 0, 100% 70%, 0 70%);
  background: #7d5be7;
}

.dog-house.fancy {
  background: #5fb7ee;
  border-color: #2b5f8a;
}

.dog-house.castle {
  background: #c0a2ff;
  border-color: #5940a0;
}

.dog {
  position: absolute;
  left: 22%;
  bottom: 50px;
  width: 240px;
  height: 210px;
}

.dog-body {
  position: absolute;
  left: 70px;
  bottom: 0;
  width: 150px;
  height: 104px;
  border: 6px solid #6a3f22;
  border-radius: 52% 48% 42% 44%;
  background: #c57a3f;
}

.dog-head {
  position: absolute;
  left: 28px;
  top: 20px;
  width: 118px;
  height: 100px;
  border: 6px solid #6a3f22;
  border-radius: 52% 48% 48% 44%;
  background: #d9944f;
  z-index: 2;
}

.dog-ear {
  position: absolute;
  top: 35px;
  width: 38px;
  height: 66px;
  border-radius: 50%;
  background: #744523;
  z-index: 3;
}

.dog-ear.left {
  left: 16px;
  transform: rotate(20deg);
}

.dog-ear.right {
  left: 124px;
  transform: rotate(-22deg);
}

.dog-eye,
.dog-nose {
  position: absolute;
  display: block;
  border-radius: 50%;
  background: #20140d;
}

.dog-eye {
  top: 40px;
  width: 12px;
  height: 12px;
}

.dog-eye.left {
  left: 42px;
}

.dog-eye.right {
  left: 78px;
}

.dog-nose {
  left: 56px;
  top: 62px;
  width: 22px;
  height: 16px;
}

.dog-collar {
  position: absolute;
  left: 62px;
  top: 116px;
  width: 98px;
  height: 18px;
  border: 3px solid #24327d;
  border-radius: 999px;
  background: #5168f4;
  z-index: 4;
}

.dog-collar.lightning {
  background: #f7df4b;
  border-color: #9b7a00;
}

.dog-collar.champion {
  background: #e94d8a;
  border-color: #8a214b;
}

.dog-bowl {
  position: absolute;
  right: 22%;
  bottom: 42px;
  width: 86px;
  height: 42px;
  border: 5px solid #9b6424;
  border-radius: 0 0 38px 38px;
  background: #f7a94b;
}

.dog-bowl.star {
  background: #ffd85a;
}

.dog-bowl.diamond {
  background: #8de8ff;
}

.dog-food {
  position: absolute;
  right: calc(22% + 18px);
  bottom: 84px;
  font-size: 1.8rem;
}

.equipped-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
}

.equipped-list span {
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: var(--primary-soft);
  font-size: 0.85rem;
  font-weight: 700;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
}

.stat-grid div {
  padding: 0.9rem;
  border-radius: 18px;
  background: var(--choice-bg);
}

.stat-grid strong {
  display: block;
  font-size: 2rem;
}

.stat-grid span {
  color: var(--muted);
  font-size: 0.9rem;
}

.mode-grid,
.difficulty-grid,
.timer-choice,
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
}

.choice-card,
.shop-item,
.match-card {
  padding: 1rem;
  border: 2px solid transparent;
  border-radius: 20px;
  background: var(--choice-bg);
  color: var(--ink);
  text-align: left;
}

.choice-card {
  display: grid;
  gap: 0.35rem;
}

.choice-card.selected {
  border-color: var(--primary);
  box-shadow: 0 10px 24px var(--selected-shadow);
}

.choice-card strong,
.shop-item strong {
  font-size: 1.05rem;
}

.choice-card span,
.shop-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.streak-options {
  margin: 0.75rem 0 1rem;
  padding: 0.9rem;
  border: 2px dashed var(--primary-border);
  border-radius: 22px;
  background: var(--primary-wash);
}

.streak-options h3,
.streak-options p,
.share-card h3,
.share-card p {
  margin: 0.2rem 0 0.6rem;
}

.share-card {
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0;
  padding: 1rem;
  border-radius: 22px;
  background: var(--share-bg);
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.primary-action {
  width: 100%;
}

.game-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.timer-pill {
  padding: 0.6rem 0.9rem;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 1.3rem;
  font-weight: 900;
}

.progress-text {
  color: var(--muted);
  font-weight: 700;
}

.equation {
  margin: 1rem 0;
  font-size: clamp(3rem, 14vw, 6rem);
  font-weight: 900;
  text-align: center;
}

.answer-form {
  max-width: 360px;
  margin: 0 auto;
}

.feedback {
  min-height: 1.5rem;
  font-weight: 800;
  text-align: center;
}

.feedback.good {
  color: #23803d;
}

.feedback.bad {
  color: var(--danger);
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.matching-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 1rem;
}

.match-column {
  display: grid;
  gap: 0.55rem;
}

.match-card {
  cursor: pointer;
  font-weight: 800;
  text-align: center;
}

.match-card.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.match-card.matched {
  border-color: var(--green);
  background: var(--green-soft);
}

.shop-item {
  display: grid;
  gap: 0.6rem;
}

.shop-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  border-radius: 14px;
  background: var(--primary-wash);
}

.shop-preview svg,
.shop-preview img {
  width: 100%;
  max-height: 92px;
}

.theme-swatch {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
  width: 100%;
}

.theme-swatch span {
  min-height: 76px;
  border-radius: 12px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}

.shop-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.coin-pill {
  padding: 0.28rem 0.5rem;
  border-radius: 999px;
  background: var(--secondary-soft);
  font-weight: 800;
}

.site-footer {
  margin: 1.5rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.site-footer hr {
  border: 0;
  border-top: 2px solid var(--primary-border);
  margin: 0 0 0.85rem;
}

.site-footer p {
  margin: 0;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .hero,
  .dashboard,
  .matching-board {
    grid-template-columns: 1fr;
  }

  .dog {
    left: 8%;
  }

  .dog-house {
    right: 8%;
  }

  .dog-bowl {
    right: 12%;
  }

  .profile-row,
  .answer-form {
    grid-template-columns: 1fr;
  }
}
