:root {
  color-scheme: light;
  --bg: #f7f1e8;
  --ink: #25312e;
  --muted: #65746f;
  --paper: #fffdf7;
  --line: rgba(37, 49, 46, 0.16);
  --accent: #2d6a5f;
  --accent-2: #f2b84b;
  --accent-3: #d95b59;
  --shadow: 0 16px 38px rgba(49, 61, 58, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  touch-action: manipulation;
}

button {
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(15rem, 0.9fr) auto minmax(0, auto);
  gap: 0.7rem;
  padding: max(0.8rem, env(safe-area-inset-top)) 0.85rem max(0.8rem, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), transparent 16rem),
    var(--bg);
}

.topbar,
.shop-scene,
.stats,
.play-panel {
  width: min(100%, 45rem);
  margin-inline: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 0.1rem;
  font-size: clamp(1.5rem, 7vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.icon-button {
  width: 2.8rem;
  aspect-ratio: 1;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--shadow);
  font-size: 1.35rem;
  font-weight: 900;
}

.shop-scene {
  position: relative;
  min-height: 15rem;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.75);
  border-radius: 0.5rem;
  background:
    linear-gradient(180deg, #94d7e5 0 45%, #91c77a 45% 100%);
  box-shadow: var(--shadow);
}

.sky,
.shop-building,
.counter {
  position: absolute;
  inset: 0;
}

.cloud {
  position: absolute;
  width: 5rem;
  height: 1.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}

.cloud::before {
  width: 2.2rem;
  height: 2.2rem;
  left: 0.7rem;
  bottom: 0.3rem;
}

.cloud::after {
  width: 2.6rem;
  height: 2.6rem;
  right: 0.6rem;
  bottom: 0.1rem;
}

.cloud.one {
  left: 7%;
  top: 13%;
}

.cloud.two {
  right: 10%;
  top: 20%;
  transform: scale(0.75);
}

.shop-building {
  left: 8%;
  right: 8%;
  top: 28%;
  bottom: 8%;
  border: 0.22rem solid #533d31;
  border-radius: 0.35rem 0.35rem 0.2rem 0.2rem;
  background: #ffe2a9;
}

.shop-building::before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: -30%;
  height: 36%;
  clip-path: polygon(0 100%, 50% 0, 100% 100%);
  background: #c75146;
  border: 0.22rem solid #533d31;
  border-bottom: 0;
}

.awning {
  position: absolute;
  left: -0.25rem;
  right: -0.25rem;
  top: 22%;
  height: 18%;
  background:
    repeating-linear-gradient(90deg, #fff8e7 0 11%, var(--accent-3) 11% 22%);
  border-block: 0.2rem solid #533d31;
}

.sign {
  position: absolute;
  left: 50%;
  top: -18%;
  transform: translateX(-50%);
  min-width: 8.5rem;
  padding: 0.38rem 0.8rem;
  border: 0.18rem solid #533d31;
  border-radius: 0.35rem;
  background: var(--paper);
  text-align: center;
  font-weight: 1000;
  letter-spacing: 0.04em;
}

.window-display {
  position: absolute;
  left: 8%;
  bottom: 12%;
  width: 43%;
  height: 34%;
  display: flex;
  align-items: end;
  justify-content: space-around;
  gap: 0.2rem;
  padding: 0.35rem;
  border: 0.18rem solid #533d31;
  border-radius: 0.25rem;
  background: #dff5fb;
}

.window-display span {
  display: grid;
  justify-items: center;
  gap: 0.08rem;
  font-size: 1.35rem;
}

.window-display small {
  font-size: 0.62rem;
  font-weight: 900;
}

.door {
  position: absolute;
  right: 13%;
  bottom: 0;
  width: 22%;
  height: 42%;
  border: 0.18rem solid #533d31;
  border-bottom: 0;
  border-radius: 0.2rem 0.2rem 0 0;
  background: #8f5b42;
}

.door::after {
  content: "";
  position: absolute;
  right: 18%;
  top: 48%;
  width: 0.42rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #f7d868;
}

.counter {
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding: 0 8% 5%;
  pointer-events: none;
}

.customer {
  position: relative;
  width: 5.4rem;
  height: 5.4rem;
  filter: drop-shadow(0 0.4rem 0 rgba(37, 49, 46, 0.15));
}

.face {
  position: absolute;
  inset: 18% 8% 0;
  border: 0.18rem solid #533d31;
  border-radius: 48% 48% 42% 42%;
  background: var(--customer-color, #fff2f0);
}

.ear {
  position: absolute;
  top: 2%;
  width: 1.7rem;
  height: 2.2rem;
  border: 0.18rem solid #533d31;
  border-radius: 50% 50% 35% 35%;
  background: var(--customer-color, #fff2f0);
}

.ear.left {
  left: 12%;
  transform: rotate(-18deg);
}

.ear.right {
  right: 12%;
  transform: rotate(18deg);
}

.customer[data-type="cat"] .ear,
.customer[data-type="squirrel"] .ear {
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.customer[data-type="bear"] .ear,
.customer[data-type="dog"] .ear {
  height: 1.7rem;
  border-radius: 50%;
}

.eye,
.nose {
  position: absolute;
  border-radius: 50%;
  background: #533d31;
}

.eye {
  top: 38%;
  width: 0.38rem;
  height: 0.55rem;
}

.eye.left {
  left: 34%;
}

.eye.right {
  right: 34%;
}

.nose {
  left: 50%;
  top: 55%;
  width: 0.52rem;
  height: 0.38rem;
  transform: translateX(-50%);
}

.basket {
  width: 6.8rem;
  height: 3.1rem;
  border: 0.22rem solid #6c4933;
  border-top: 0;
  border-radius: 0.2rem 0.2rem 1rem 1rem;
  background:
    repeating-linear-gradient(90deg, rgba(108, 73, 51, 0.2) 0 0.45rem, transparent 0.45rem 0.9rem),
    #d89757;
}

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

.stats div {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 0.1rem;
  padding: 0.5rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: rgba(255, 255, 255, 0.62);
}

.stats span,
.small,
.money-grid span,
.return-box span {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 800;
}

.stats strong {
  font-size: 1.1rem;
}

.play-panel {
  display: grid;
  gap: 0.65rem;
  padding-bottom: 0.2rem;
}

.shop-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}

.shop-card {
  min-height: 4.15rem;
  display: grid;
  place-items: center;
  gap: 0.2rem;
  padding: 0.45rem 0.25rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--paper);
  box-shadow: 0 0.3rem 0 rgba(37, 49, 46, 0.12);
}

.shop-card span {
  font-size: 1.65rem;
}

.shop-card strong {
  font-size: 0.78rem;
}

.receipt,
.return-box {
  display: grid;
  gap: 0.65rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--paper);
  box-shadow: 0 0.35rem 0 rgba(37, 49, 46, 0.08);
}

.receipt[hidden],
.return-box[hidden],
.coin-tray[hidden],
button[hidden] {
  display: none;
}

#itemLine {
  font-size: clamp(1.35rem, 6vw, 2rem);
  line-height: 1.1;
}

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

.money-grid div,
.return-box > div:first-child {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
  padding: 0.55rem;
  border-radius: 0.4rem;
  background: #f4efe3;
}

.money-grid strong,
.return-box strong {
  font-size: clamp(1.05rem, 5vw, 1.65rem);
  line-height: 1;
}

.change-box {
  outline: 0.18rem solid rgba(217, 91, 89, 0.24);
}

.coin-tray {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.4rem;
}

.coin,
.mini-coin {
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0.16rem solid rgba(72, 67, 58, 0.7);
  background: #d7dce0;
  box-shadow: inset 0 0 0 0.18rem rgba(255, 255, 255, 0.48), 0 0.22rem 0 rgba(37, 49, 46, 0.16);
  font-weight: 1000;
}

.coin {
  width: 100%;
  aspect-ratio: 1;
  min-height: 3rem;
  font-size: clamp(0.85rem, 4vw, 1.25rem);
}

.coin-5,
.coin-50 {
  background: #d5b46a;
}

.coin-10 {
  background: #bd7a50;
  color: #fff8ed;
}

.coin-100,
.coin-500 {
  background: #cfd5d8;
}

.coin-1 {
  background: #e7ebed;
}

.return-box {
  grid-template-columns: 0.92fr 1.4fr;
  align-items: center;
}

.coin-stack {
  min-height: 2.4rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.32rem;
}

.mini-coin {
  width: 2rem;
  aspect-ratio: 1;
  font-size: 0.75rem;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 0.5rem;
}

.primary-button,
.secondary-button {
  min-height: 3.2rem;
  border-radius: 0.5rem;
  font-weight: 1000;
  box-shadow: 0 0.3rem 0 rgba(37, 49, 46, 0.16);
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.secondary-button {
  background: #fff;
  border: 1px solid var(--line);
}

.actions .primary-button:first-child:last-child,
#nextButton {
  grid-column: 1 / -1;
}

.message {
  min-height: 3.25rem;
  display: grid;
  align-items: center;
  padding: 0.75rem 0.85rem;
  border-radius: 0.5rem;
  background: #243733;
  color: #fff;
  font-weight: 800;
  line-height: 1.45;
}

.message[data-tone="good"] {
  background: #266c4a;
}

.message[data-tone="warn"] {
  background: #9e443f;
}

.offline-note {
  color: var(--muted);
  font-size: 0.73rem;
  line-height: 1.45;
}

body[data-theme="flower"] {
  --bg: #fff0f2;
  --accent: #8d4f8a;
  --accent-2: #e7c94f;
  --accent-3: #e8759a;
}

body[data-theme="toy"] {
  --bg: #eef4ff;
  --accent: #345bb6;
  --accent-2: #f1c846;
  --accent-3: #43a9b2;
}

body[data-theme="sweets"] {
  --bg: #fff3df;
  --accent: #a34864;
  --accent-2: #7cc9be;
  --accent-3: #e48a47;
}

body[data-theme="flower"] .shop-building {
  background: #ffe5ef;
}

body[data-theme="toy"] .shop-building {
  background: #dcecff;
}

body[data-theme="sweets"] .shop-building {
  background: #ffe0ba;
}

@media (max-width: 380px) {
  .app {
    gap: 0.5rem;
    padding-inline: 0.65rem;
  }

  .shop-picker {
    grid-template-columns: repeat(2, 1fr);
  }

  .money-grid {
    grid-template-columns: 1fr;
  }

  .coin-tray {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 680px) {
  .app {
    grid-template-rows: auto minmax(19rem, 0.9fr) auto auto;
  }

  .play-panel {
    grid-template-columns: 0.9fr 1.2fr;
    align-items: start;
  }

  .shop-picker {
    grid-row: span 4;
    grid-template-columns: 1fr;
  }

  .message,
  .offline-note,
  .actions {
    grid-column: 2;
  }
}
