:root {
  --bg: #eef7f6;
  --card: #ffffff;
  --line: #d5e6e4;
  --teal: #2c7a7b;
  --teal-dark: #234e52;
  --teal-soft: #e6fffa;
  --gold: #ffd166;
  --text: #1a202c;
  --muted: #5a6778;
  --good: #2f855a;
  --bad: #c05621;
  --wood: #b7793e;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}
body { display: flex; flex-direction: column; height: 100dvh; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

/* ---------- top bar ---------- */

#topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--card);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
#topbar::-webkit-scrollbar { display: none; }
#brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; white-space: nowrap; }
#modes { display: flex; gap: 6px; flex: 1; }
.mode {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}
.mode .e { font-size: 20px; }
.mode.active { border-color: var(--teal); background: var(--teal-soft); color: var(--teal-dark); }
#top-right { display: flex; align-items: center; gap: 6px; }
#levels { display: flex; gap: 4px; }
.lvl {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 9px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  line-height: 1.15;
  white-space: nowrap;
}
.lvl b { font-size: 13px; }
.lvl small { font-size: 11px; color: var(--muted); font-weight: 600; }
.lvl.active { border-color: var(--gold); background: #fff8e1; }
.icon-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 20px;
}

/* ---------- main ---------- */

#main {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.progress { display: flex; align-items: center; gap: 6px; justify-content: center; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: #cfe0de; }
.dot.now { background: var(--teal); box-shadow: 0 0 0 3px #b2dfdb; }
.dot.s0 { background: #fbd38d; }
.dot.s1, .dot.s2 { background: #9ae6b4; }
.dot.s3 { background: var(--good); }
.progress .score { margin-left: 8px; font-weight: 800; color: #b7791f; }

.scene {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.side { display: flex; flex-direction: column; gap: 10px; }

.counter {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  border-bottom: 10px solid var(--wood);
}
.customer { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.face { font-size: 54px; line-height: 1; }
.bubble {
  position: relative;
  flex: 1;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--teal-soft);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
}
.bubble::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 16px;
  border: 8px solid transparent;
  border-left: 0;
  border-right-color: var(--teal-soft);
}
.items { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 92px;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.item .e { font-size: 38px; line-height: 1.1; }
.item .n { font-size: 13px; color: var(--muted); font-weight: 600; }
.item .p, .shelf-item .p {
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #fff8e1;
  border: 1px dashed #d69e2e;
  font-weight: 800;
  font-size: 16px;
}
.sums { display: flex; gap: 10px; flex-wrap: wrap; }
.sums > div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #f7fafa;
  border: 1px solid var(--line);
}
.sums span { font-weight: 700; color: var(--muted); font-size: 14px; }
.sums b { font-size: 24px; }

/* tray */
.tray, .basket {
  background: var(--card);
  border: 3px dashed #9fc9c5;
  border-radius: 18px;
  padding: 10px 12px;
  min-height: 150px;
}
.tray-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; margin-bottom: 6px; }
.tray-sum {
  min-width: 70px;
  padding: 2px 10px;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-size: 22px;
  text-align: center;
}
.tray-coins { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-height: 80px; }
.tray-coin { padding: 0; border: 0; background: none; }
.tray-coin.new { animation: drop .18s ease-out; }
.empty { color: var(--muted); font-size: 14px; font-weight: 600; }
@keyframes drop { from { transform: translateY(-14px) scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }

.money { display: block; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25)); }

/* till */
.till {
  background: #2d3748;
  border-radius: 18px;
  padding: 10px 12px 14px;
  border-top: 8px solid #4a5568;
}
.till-label { color: #e2e8f0; font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.till-coins { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.till-coin {
  display: grid;
  place-items: center;
  min-width: 76px;
  min-height: 76px;
  padding: 4px;
  border: 0;
  border-radius: 14px;
  background: #4a5568;
  transition: transform .08s;
}
.till-coin:active { transform: scale(.92); }

/* actions & feedback */
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.actions.center { justify-content: center; }
.ghost, .go {
  height: 54px;
  padding: 0 18px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 800;
  white-space: nowrap;
}
.ghost { border: 2px solid var(--line); background: #fff; }
.go { border: 0; background: var(--teal); color: #fff; box-shadow: 0 3px 0 var(--teal-dark); }
.go:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--teal-dark); }

.feedback {
  padding: 12px 14px;
  border-radius: 16px;
  background: #fff;
  border: 3px solid;
  animation: pop .2s ease-out;
}
.feedback.ok { border-color: var(--good); }
.feedback.no { border-color: #ed8936; }
.feedback p { margin: 0 0 8px; font-size: 17px; font-weight: 700; line-height: 1.4; }
.feedback .go { width: 100%; margin-top: 4px; }
.fb-stars { font-size: 28px; color: #d69e2e; letter-spacing: 3px; }
.off { color: #e2e8f0; }
.answer-coins { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 6px; }
@keyframes pop { from { transform: scale(.95); opacity: 0; } to { transform: none; opacity: 1; } }

.hint {
  padding: 10px 12px;
  border-radius: 14px;
  background: #fffbea;
  border: 1px solid #f6e05e;
  font-size: 15px;
}
.hops { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.hop { padding: 4px 10px; border-radius: 999px; background: #fff; border: 1px solid #ecc94b; font-weight: 600; }

/* budget */
.mission {
  padding: 10px 14px;
  border-radius: 14px;
  background: #fff8e1;
  border: 1px solid #f6e05e;
  font-size: 17px;
  font-weight: 600;
}
.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px;
  padding: 12px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom: 10px solid var(--wood);
}
.shelf-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 6px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.shelf-item .e { font-size: 40px; line-height: 1.1; }
.shelf-item .n { font-size: 13px; color: var(--muted); font-weight: 600; }
.shelf-item .qty {
  position: absolute;
  top: -8px;
  right: -8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
}
.shelf-item:active { transform: scale(.96); }
.basket.over { border-color: #e53e3e; }
.meter { height: 12px; border-radius: 6px; background: #e2e8f0; overflow: hidden; margin: 6px 0 2px; }
.meter div { height: 100%; background: var(--good); transition: width .15s; }
.basket.over .meter div { background: #e53e3e; }
.left { font-size: 14px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.basket.over .left { color: #c53030; }
.basket-list { display: flex; flex-direction: column; gap: 4px; }
.basket-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7fafa;
  font-weight: 600;
  text-align: left;
}

/* end */
.end { text-align: center; padding: 40px 16px; }
.big-stars { font-size: 56px; color: #d69e2e; letter-spacing: 6px; }
.end h1 { margin: 10px 0 6px; }
.end p { font-size: 18px; margin: 0 0 20px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(90%, 460px);
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(26, 32, 44, .9);
  color: #fff;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  z-index: 60;
}
#toast.show { opacity: 1; }

@media (max-width: 900px) {
  #brand span { display: none; }
  .mode { padding: 8px; }
  .lvl small { display: none; }
}
@media (max-width: 720px) {
  .scene { grid-template-columns: 1fr; }
  .mode { font-size: 0; gap: 0; }
  .mode .e { font-size: 22px; }
  .till-coin { min-width: 64px; min-height: 64px; }
}
