:root {
  color-scheme: light;
  --bg: #fff8ec;
  --panel: #fffaf1;
  --ink: #2b251d;
  --muted: #6c6256;
  --primary: #5168f4;
  --primary-dark: #2e3fb4;
  --secondary: #f7a94b;
  --green: #52c06d;
  --danger: #d94c45;
  --shadow: 0 18px 40px rgba(43, 37, 29, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  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: rgba(255, 250, 241, 0.92);
  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 rgba(81, 104, 244, 0.28);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
}

.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 {
  display: block;
  width: 100%;
  height: auto;
}

.layer-bg {
  inset: 0;
}

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

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

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

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

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

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

.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: rgba(81, 104, 244, 0.14);
  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: rgba(255, 255, 255, 0.75);
}

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

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

.mode-grid,
.difficulty-grid,
.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: rgba(255, 255, 255, 0.82);
  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 rgba(81, 104, 244, 0.2);
}

.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;
}

.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: rgba(81, 104, 244, 0.14);
}

.match-card.matched {
  border-color: var(--green);
  background: rgba(82, 192, 109, 0.18);
}

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

.shop-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  border-radius: 14px;
  background: #f2faff;
}

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

.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: rgba(247, 169, 75, 0.22);
  font-weight: 800;
}

.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;
  }
}
