@import url("https://fonts.googleapis.com/css2?family=Lilita+One&family=Nunito:wght@700;800;900&display=swap");

:root {
  --ink: #2a120c;
  --cream: #fff1d6;
  --sauce: #c81d25;
  --crust: #e09f3e;
  --paper: #fffaf0;
  color: var(--ink);
  font-family: Nunito, "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: #2a120c;
}

button { font: inherit; touch-action: manipulation; }

button:focus-visible {
  outline: 3px solid var(--crust);
  outline-offset: 2px;
}

.app {
  width: min(100vw, 440px);
  height: 100dvh;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: #2a120c;
  color: var(--cream);
  display: flex;
  flex-direction: column;
}

.screen { min-height: 0; }

#game {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

#game[hidden],
#play[hidden],
#intro[hidden],
#result[hidden] { display: none !important; }

.gate {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: auto;
  padding: calc(20px + env(safe-area-inset-top)) 20px calc(22px + env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse 80% 48% at 50% 18%, rgba(224, 159, 62, 0.5), transparent 62%),
    linear-gradient(180deg, #8a4b24 0%, #2a120c 62%);
}

.gate-art {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 160px;
}

.gate-art svg { width: min(260px, 78vw); height: auto; }

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--crust);
}

h1, h2 {
  font-family: "Lilita One", "Arial Black", sans-serif;
  font-weight: 400;
  letter-spacing: 0.01em;
  margin: 0;
}

.gate h1 {
  font-size: clamp(2.7rem, 14vw, 4rem);
  line-height: 0.86;
  text-transform: uppercase;
  color: var(--cream);
  text-shadow: 4px 4px 0 var(--ink);
}

.gate h1 span { color: var(--crust); }

.lede {
  margin: 12px 0 0;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.35;
  max-width: 28ch;
}

.fine {
  margin: 8px 0 0;
  color: rgba(255, 241, 214, 0.82);
  font-weight: 700;
  line-height: 1.35;
}

.gate-actions, .result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.btn, .item {
  border: 3px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  border-radius: 16px;
  min-height: 48px;
  padding: 10px 14px;
  font-weight: 900;
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
}

.btn:active:not(:disabled),
.item:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--ink);
}

.btn.primary {
  background: var(--sauce);
  color: var(--cream);
}

.btn.ghost {
  background: transparent;
  color: var(--cream);
  box-shadow: none;
  border-color: rgba(255, 241, 214, 0.45);
}

.btn:disabled, .item:disabled {
  opacity: 0.45;
  cursor: default;
}

#intro .btn, #result .btn { width: 100%; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 0;
}

.top h1 {
  font-size: 1.2rem;
  text-transform: uppercase;
  color: var(--cream);
}

.top h1 span { color: var(--crust); }

.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: var(--cream);
  color: var(--ink);
  font-weight: 900;
  font-size: 1.2rem;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
}

.icon-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--ink);
}

.status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 0;
  font-weight: 900;
  font-size: 0.78rem;
}

.pill, .count {
  background: var(--cream);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 8px;
}

.count.bonus { background: var(--crust); }

.look-wrap {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.looks {
  display: inline-flex;
  gap: 4px;
}

.looks i {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--cream);
  background: transparent;
}

.looks i.on {
  background: var(--sauce);
  box-shadow: inset 0 -3px 0 rgba(42, 18, 12, 0.35);
}

.stage {
  position: relative;
  height: 158px;
  flex: 0 0 auto;
  margin-top: 6px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 55% 80% at 78% 30%, rgba(224, 159, 62, 0.28), transparent 70%),
    repeating-linear-gradient(90deg, transparent 0 22px, rgba(42, 18, 12, 0.12) 22px 24px),
    linear-gradient(180deg, #8a4b24 0%, #4a2412 58%, #2a120c 100%);
}

.stage.is-fail {
  background:
    radial-gradient(ellipse 70% 80% at 50% 40%, rgba(200, 29, 37, 0.35), transparent 70%),
    linear-gradient(180deg, #5a1820 0%, #2a120c 80%);
}

.stage.is-win {
  background:
    radial-gradient(ellipse 70% 80% at 50% 30%, rgba(224, 159, 62, 0.55), transparent 68%),
    linear-gradient(180deg, #a86a28 0%, #4a2412 70%);
}

.queue {
  position: absolute;
  z-index: 3;
  top: 8px;
  left: 8px;
  right: 8px;
  height: 40px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.head {
  position: relative;
  width: 28px;
  height: 28px;
  flex: 0 1 28px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background-color: var(--skin, #f0c29a);
  background-image:
    radial-gradient(circle at 35% 44%, #2a120c 1.7px, transparent 2.1px),
    radial-gradient(circle at 66% 44%, #2a120c 1.7px, transparent 2.1px);
  background-repeat: no-repeat;
  box-shadow: 2px 2px 0 var(--ink);
}

.head::before {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: -5px;
  height: 10px;
  background: var(--hair, #3b2418);
  border: 2px solid var(--ink);
  border-radius: 8px 8px 3px 3px;
}

.head.morag { --skin: #f0c29a; --hair: #d9d3c7; }
.head.office { --skin: #e7b48a; --hair: #24160f; }
.head.tourist { --skin: #f3c7a4; --hair: #e09f3e; }
.head.band { --skin: #d99a6c; --hair: #6b2a12; }
.head.stevie { --skin: #f0c29a; --hair: #1b120c; }
.head.sandra { --skin: #f6d2b0; --hair: #4a2c24; }
.head.hens { --skin: #f3c7a4; --hair: #2f6fad; }
.head.nurse { --skin: #a56b45; --hair: #fff1d6; }
.head.alan { --skin: #e0ac84; --hair: #3b2418; }
.head.gull { --skin: #f7f4ea; --hair: transparent; }

.head.morag::before {
  left: 6px;
  right: 6px;
  height: 12px;
  top: -8px;
  border-radius: 50%;
}

.head.tourist::before {
  left: -4px;
  right: -4px;
  top: -6px;
  height: 8px;
  border-radius: 8px;
}

.head.hens::before {
  left: -2px;
  right: -2px;
  top: -3px;
  height: 14px;
  border-radius: 10px 10px 4px 4px;
}

.head.nurse::before {
  left: 3px;
  right: 3px;
  top: -7px;
  height: 9px;
  border-radius: 3px 3px 2px 2px;
  background: #fff;
}

.head.alan::before {
  left: -3px;
  right: -3px;
  top: -6px;
  height: 8px;
  border-radius: 4px 4px 2px 2px;
}

.head.gull::before { display: none; }

.head.gull::after {
  content: "";
  position: absolute;
  right: -6px;
  top: 11px;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 8px solid var(--crust);
}

.head.stevie::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: -6px;
  height: 7px;
  border-radius: 2px;
  border: 2px solid var(--ink);
  background: repeating-linear-gradient(90deg, #e09f3e 0 4px, #7ec8c3 4px 8px);
}

.head.is-current {
  z-index: 2;
  animation: bob 0.8s ease-in-out infinite;
  box-shadow: 0 0 0 3px var(--cream), 0 0 0 6px var(--crust);
}

.head.is-served {
  box-shadow: 0 0 0 2px var(--cream), 0 0 0 5px var(--crust);
}

.head.is-dirty {
  box-shadow: 0 0 0 2px var(--cream), 0 0 0 5px var(--sauce);
}

.head.is-abandoned {
  opacity: 0.28;
  filter: grayscale(0.85);
}

.shop-sign {
  position: absolute;
  z-index: 1;
  right: 14px;
  top: 54px;
  margin: 0;
  font-family: "Lilita One", "Arial Black", sans-serif;
  font-size: 1.45rem;
  line-height: 0.9;
  color: var(--cream);
  text-shadow: 3px 3px 0 var(--ink);
  transform: rotate(2deg);
}

.shop-sign span {
  display: block;
  font-family: Nunito, sans-serif;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.server {
  position: absolute;
  z-index: 1;
  left: 4px;
  bottom: 16px;
  width: 124px;
  height: auto;
  overflow: visible;
}

.counter-lip {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  height: 26px;
  background: var(--cream);
  border-top: 4px solid var(--ink);
}

.prop-pie {
  position: absolute;
  z-index: 3;
  right: 18px;
  bottom: 8px;
  width: 46px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background:
    radial-gradient(ellipse at 50% 42%, var(--cream) 0 36%, transparent 38%),
    var(--crust);
  box-shadow: 3px 3px 0 var(--ink);
}

.prop-pie::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 9px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 14px 0 var(--ink);
}

.prop-pie::after {
  content: "";
  position: absolute;
  left: 14px;
  top: 16px;
  width: 14px;
  height: 6px;
  border-bottom: 2px solid var(--ink);
  border-radius: 0 0 10px 10px;
}

.burst {
  position: absolute;
  z-index: 5;
  left: 64%;
  top: 58%;
  width: 58%;
  margin: 0;
  text-align: center;
  pointer-events: none;
  font-family: "Lilita One", "Arial Black", sans-serif;
  font-size: clamp(1.35rem, 6vw, 1.85rem);
  line-height: 0.9;
  color: var(--cream);
  text-shadow:
    3px 3px 0 var(--ink),
    -2px -2px 0 var(--ink),
    2px -2px 0 var(--ink),
    -2px 2px 0 var(--ink),
    5px 5px 0 var(--sauce);
  transform: translate(-50%, -50%);
}

.burst.go { animation: burst 0.7s cubic-bezier(.2, 1.4, .3, 1) both; }

.crumb {
  position: absolute;
  z-index: 6;
  width: 9px;
  height: 9px;
  margin: -4px 0 0 -4px;
  border: 2px solid var(--ink);
  border-radius: 40% 60% 50% 50%;
  pointer-events: none;
  animation: crumb 0.8s ease-out forwards;
}

.panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--cream);
  color: var(--ink);
  border-top: 4px solid var(--ink);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}

.timebar {
  flex: 0 0 auto;
  height: 12px;
  margin-bottom: 8px;
  background: rgba(42, 18, 12, 0.12);
  border: 2px solid var(--ink);
  border-radius: 99px;
  overflow: hidden;
}

.timebar i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--crust);
  transform-origin: left center;
  transform: scaleX(1);
}

.timebar.is-low i { background: var(--sauce); }

.bubble-wrap {
  position: relative;
  flex: 0 0 auto;
  margin-bottom: 8px;
}

.speech {
  margin: 0;
  min-height: 3.6em;
  max-height: 6.2em;
  overflow: auto;
  background: #fff;
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 16px 16px 16px 6px;
  box-shadow: 4px 4px 0 var(--ink);
  padding: 8px 10px;
  font-weight: 800;
  font-size: 0.92rem;
  line-height: 1.25;
}

.bubble-wrap.is-timing .speech { padding-right: 58px; }

.timer {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 48px;
  height: 48px;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: 3px 3px 0 var(--ink);
}

.timer svg { width: 100%; height: 100%; display: block; }

.timer span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: "Lilita One", "Arial Black", sans-serif;
  font-size: 1.05rem;
  color: var(--ink);
}

.ring-bg, .ring { fill: none; stroke-width: 4; }

.ring-bg { stroke: rgba(42, 18, 12, 0.15); }

.ring {
  stroke: var(--crust);
  stroke-linecap: round;
  stroke-dasharray: 100.53;
  stroke-dashoffset: calc(100.53 * (1 - var(--p, 1)));
  transform: rotate(-90deg);
  transform-origin: 22px 22px;
}

.timer.is-low { animation: pulse 0.45s ease-in-out infinite; }
.timer.is-low .ring { stroke: var(--sauce); }
.timer.is-low span { color: var(--sauce); }

#intro, #result {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

#intro p, #result p {
  margin: 0 0 12px;
  font-weight: 800;
  line-height: 1.35;
}

#play {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tray {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  align-items: center;
  min-height: 46px;
  overflow-x: auto;
  padding: 6px;
  background: rgba(255, 255, 255, 0.55);
  border: 3px dashed var(--ink);
  border-radius: 14px;
}

.tray-empty {
  margin: 0;
  font-weight: 800;
  color: rgba(42, 18, 12, 0.62);
}

.chip {
  flex: 0 0 auto;
  border: 2px solid var(--ink);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  min-height: 32px;
  padding: 4px 10px;
  font-weight: 900;
  font-size: 0.78rem;
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
}

.items {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-content: start;
  padding: 2px 2px 4px 0;
}

.item {
  font-size: 0.86rem;
  line-height: 1.15;
  text-align: center;
  padding: 8px;
}

.item[data-item="scotch"] { background: #e09f3e; }
.item[data-item="macaroni"] { background: #f6d56a; }
.item[data-item="steak"] { background: #c4843a; }
.item[data-item="roll"] { background: #efc48a; }
.item[data-item="empire"] { background: #fffaf0; }
.item[data-item="scone"] { background: #f3e2b8; }
.item[data-item="bru"] { background: #ff8a1e; }
.item[data-item="bag"] { background: #fff; }
.item[data-item="brown"] { background: #6b3e22; color: var(--cream); }
.item[data-item="red"] { background: var(--sauce); color: var(--cream); }

.item.is-hint {
  border-color: var(--sauce);
  box-shadow: 3px 3px 0 var(--sauce);
  animation: hint 0.8s ease-in-out infinite;
}

.actions {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 8px;
}

.score-num {
  font-family: "Lilita One", "Arial Black", sans-serif;
  font-size: 2.5rem;
  line-height: 0.95;
  color: var(--sauce);
  margin: 0 0 6px;
}

.bonus-num {
  display: inline-block;
  margin: 0 0 8px;
  padding: 4px 10px;
  background: var(--crust);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 999px;
  font-weight: 900;
}

.kicker {
  display: inline-block;
  margin: 0 0 8px;
  padding: 3px 8px;
  background: var(--sauce);
  color: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 999px;
  font-weight: 900;
  font-size: 0.82rem;
}

.result h2 {
  font-size: clamp(1.7rem, 8vw, 2.25rem);
  text-transform: uppercase;
  line-height: 0.92;
  margin: 4px 0 8px;
  color: var(--ink);
  text-shadow: 3px 3px 0 var(--crust);
}

.share-note {
  margin: 0;
  font-weight: 800;
  line-height: 1.35;
  white-space: pre-wrap;
  color: #6b3e22;
}

.mouth { display: none; }

.mood-idle .mouth-idle,
.mood-ok .mouth-ok,
.mood-dirty .mouth-dirty,
.mood-combo .mouth-combo,
.mood-fail .mouth-fail { display: block; }

.mood-dirty .eyes,
.mood-fail .eyes {
  transform: scaleY(0.55);
  transform-box: fill-box;
  transform-origin: center;
}

.mood-combo .eyes {
  transform: scaleY(0.2);
  transform-box: fill-box;
  transform-origin: center;
}

.server.mood-ok { animation: nod 0.45s ease; }
.server.mood-dirty { animation: recoil 0.45s ease; }
.server.mood-combo { animation: hop 0.6s ease; }
.server.mood-fail { animation: recoil 0.55s ease; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes nod {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(4px); }
}

@keyframes recoil {
  0%, 100% { transform: translateX(0); }
  35% { transform: translateX(-6px); }
  70% { transform: translateX(4px); }
}

@keyframes hop {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
}

@keyframes hint {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@keyframes burst {
  0% { transform: translate(-50%, -20%) scale(0.35) rotate(-8deg); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
}

@keyframes crumb {
  0% { transform: scale(0.2); opacity: 1; }
  100% { transform: translateY(-28px) scale(1); opacity: 0; }
}

@media (max-height: 760px) {
  .stage { height: 124px; }
  .server { width: 104px; }
  .shop-sign { top: 46px; font-size: 1.15rem; }
  .speech { min-height: 3.1em; max-height: 4.8em; }
  .panel { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .timebar { height: 8px; margin-bottom: 6px; }
  .bubble-wrap { margin-bottom: 6px; }
  #play { gap: 6px; }
  .status { padding-top: 4px; }
}

@media (max-height: 640px) {
  .stage { height: 74px; }
  .server { width: 58px; bottom: 4px; }
  .shop-sign, .prop-pie { display: none; }
  .speech { min-height: 2.6em; max-height: 4.2em; font-size: 0.82rem; padding: 6px 8px; }
  .tray { min-height: 36px; padding: 4px; }
  .items { gap: 4px; }
  .top { padding-top: calc(2px + env(safe-area-inset-top)); }
  .top h1 { font-size: 1rem; }
  .queue { top: 4px; height: 32px; }
  .head { width: 24px; height: 24px; flex-basis: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
