:root {
  --soy: #2a140c;
  --broth: #e8a54b;
  --chili: #e23d2a;
  --cream: #fff4d8;
  --ink: #1a0d08;
  --nori: #1f4a34;
  --foam: #fffaf0;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1a0d08;
  font-family: Nunito, "Trebuchet MS", system-ui, sans-serif;
  touch-action: none;
}

#app {
  height: 100%;
  height: 100dvh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

#hud {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 12px 0;
}

.hp-wrap {
  position: relative;
  height: 28px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: #4a1d18;
  overflow: hidden;
  box-shadow: 2px 2px 0 #000;
}

.hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(180deg, #ff7a62 0%, var(--chili) 60%, #b51f16 100%);
  transform-origin: left center;
  transition: width 0.12s linear;
}

#hp-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  text-shadow: 0 1px 0 #000;
  pointer-events: none;
}

.hud-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--foam);
  font-weight: 800;
  font-size: 15px;
  text-shadow: 0 1px 0 #000;
  gap: 8px;
}

.hud-bit.gold { color: var(--broth); }

#hud-broth {
  display: inline-block;
}

#hud-broth.pop {
  animation: broth-pop 0.28s ease;
}

@keyframes broth-pop {
  40% { transform: scale(1.55); }
}

#btn-settings,
#btn-leave-endless {
  min-width: 52px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 12px;
  background: var(--cream);
  color: var(--ink);
  font-size: 0.85rem;
  box-shadow: 2px 2px 0 #000;
}

#btn-leave-endless {
  min-width: 76px;
  min-height: 44px;
  font-size: 0.75rem;
  background: #fff4d8;
}

.set-toggle,
.face-pick {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.95rem;
  box-shadow: 3px 3px 0 var(--ink);
}

.set-toggle.on,
.face-pick.on {
  background: var(--nori);
  color: #fff;
}

.face-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.face-row .face-pick {
  margin-top: 0;
}

#stage {
  position: relative;
  flex: 1;
  min-height: 180px;
  margin: 6px 8px 0;
  border-radius: 18px;
  overflow: hidden;
  background: #6b3a22;
  box-shadow: inset 0 0 0 3px var(--ink);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
}

.banner {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--cream);
  color: var(--ink);
  font-family: Bangers, Impact, sans-serif;
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  box-shadow: 4px 4px 0 var(--ink);
  pointer-events: none;
  z-index: 2;
}

.hidden { display: none !important; }

#toasts {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 74px);
  right: 10px;
  width: min(210px, 64vw);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--cream);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 8px 10px;
  box-shadow: 3px 3px 0 var(--ink);
  animation: toast-in 0.35s ease;
}

.toast.out {
  animation: toast-out 0.35s ease forwards;
}

.toast-kicker {
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9a4a28;
}

.toast-name {
  font-family: Bangers, Impact, sans-serif;
  font-size: 1.35rem;
  letter-spacing: 0.03em;
  line-height: 1;
}

.toast-pay {
  font-size: 0.78rem;
  font-weight: 900;
}

@keyframes toast-in {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toast-out {
  to { transform: translateX(120%); opacity: 0; }
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: rgba(18, 8, 6, 0.62);
  z-index: 3;
}

.overlay.hidden { display: none; }

.panel {
  width: min(94%, 360px);
  max-height: 92%;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  background: var(--cream);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 22px;
  padding: 16px 14px 14px;
  text-align: center;
  box-shadow: 5px 5px 0 var(--ink);
}

.shop-panel {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel h1, .panel h2 {
  margin: 0;
  font-family: Bangers, Impact, sans-serif;
  font-weight: 400;
  letter-spacing: 0.03em;
}

.panel h1 { font-size: clamp(2.1rem, 10vw, 2.8rem); }
.panel h2 { font-size: 1.8rem; }

.kicker {
  margin: 0 0 2px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9a4a28;
}

.lead {
  margin: 6px 0 10px;
  font-weight: 800;
}

.panel p {
  margin: 6px 0;
  font-size: 0.95rem;
}

.best {
  font-weight: 900;
  color: #9a4a28;
}

.wallet {
  font-weight: 900;
  color: #9a4a28;
}

.wallet.dim {
  color: #7a4a32;
  font-size: 0.85rem;
}

button {
  font-family: inherit;
  font-weight: 900;
  border: 3px solid var(--ink);
  border-radius: 16px;
  cursor: pointer;
  touch-action: manipulation;
}

.big {
  display: block;
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
  background: var(--chili);
  color: #fff;
  font-size: 1.05rem;
  box-shadow: 3px 3px 0 var(--ink);
}

.big:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.big.alt {
  background: var(--cream);
  color: var(--ink);
}

.shop-panel .big {
  flex: none;
  margin-top: 8px;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  min-height: 64px;
  padding: 10px 12px;
  text-align: left;
  background: #fff;
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}

.card:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.card-name {
  font-size: 1.05rem;
  font-weight: 900;
}

.card-lv {
  font-size: 0.78rem;
  font-weight: 800;
  color: #9a4a28;
}

.card-blurb {
  margin-top: 2px;
  font-size: 0.86rem;
  font-weight: 700;
}

.card.lucky {
  background: linear-gradient(180deg, #fff7b0 0%, #ffd14a 100%);
  box-shadow: 3px 3px 0 #9a4a28, 0 0 0 2px #fff inset;
}

.card-lv.lucky-tag {
  color: #c45c2a;
  letter-spacing: 0.02em;
}

.reroll {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  flex: none;
  background: #fff;
  color: var(--ink);
  font-size: 0.95rem;
  box-shadow: 3px 3px 0 var(--ink);
}

.reroll:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.reroll:disabled {
  opacity: 0.45;
}

.shop-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 4px;
  text-align: left;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding-right: 2px;
}

.shop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 56px;
  padding: 8px 10px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: #fff;
}

.shop-item .info { min-width: 0; }
.shop-item .name { font-weight: 900; font-size: 0.95rem; }
.shop-item .blurb { font-size: 0.75rem; font-weight: 700; color: #7a4a32; }
.shop-item.got { opacity: 0.72; }

.buy {
  flex: none;
  min-width: 72px;
  min-height: 44px;
  padding: 0 10px;
  background: var(--broth);
  color: var(--ink);
}

.buy.on {
  background: var(--nori);
  color: #fff;
}

.buy.ready {
  background: var(--chili);
  color: #fff;
}

.buy:disabled {
  opacity: 0.45;
}

#controls {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 12px;
  padding: 10px 14px 8px;
}

#float-stick {
  position: fixed;
  left: 0;
  top: 0;
  width: 132px;
  height: 132px;
  margin: -66px 0 0 -66px;
  z-index: 6;
  pointer-events: none;
}

#stick-base {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: rgba(255, 244, 216, 0.42);
  position: relative;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25), 0 4px 0 rgba(26, 13, 8, 0.35);
}

#stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: var(--broth);
  box-shadow: 2px 2px 0 var(--ink);
  pointer-events: none;
}

#btn-dash {
  width: 92px;
  min-height: 92px;
  border-radius: 50%;
  background: #ffd14a;
  color: var(--ink);
  font-size: 1rem;
  box-shadow: 4px 4px 0 var(--ink);
}

#btn-dash:active,
#btn-dash.held {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

#btn-dash:disabled {
  opacity: 0.45;
}
