/* Krazy Cooking — the kitchen screen, built for one thumb in portrait.
   Top: HUD. Middle: the dining counter (customers, their plates = the order
   tickets). Bottom, in the thumb zone: the appliances. Everything is sized
   off the viewport so nothing clips on short phones (down to ~600px tall). */

#dayScreen {
  --hud-h: 56px;
  background: #2a1838;
  height: 100%;
  touch-action: none;
}

/* ------------------------------------------------------------------ HUD */

.hud {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  background: rgba(20, 10, 30, 0.85);
  z-index: 20;
}
.hud .icon-btn { width: 44px; height: 44px; font-size: 18px; flex: 0 0 auto; }
.hud-goal { flex: 1; min-width: 0; }
.hud-goal-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 5px;
}
.hud-where {
  font-family: var(--display);
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.hud-coins { white-space: nowrap; font-weight: 700; }
.hud-coins b { font-family: var(--display); font-size: 18px; color: var(--gold); }
.hud-target { color: var(--muted); }
.goal-bar {
  position: relative;
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
}
.goal-fill {
  height: 100%;
  width: 0;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent-2), var(--gold));
  transition: width 0.3s ease;
}
.goal-star {
  position: absolute;
  top: 50%;
  left: min(var(--at), calc(100% - 8px));
  transform: translate(-50%, -50%);
  font-style: normal;
  font-size: 15px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.35);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  transition: color 0.2s, transform 0.2s;
}
.goal-star.lit { color: var(--gold); transform: translate(-50%, -50%) scale(1.25); }
.hud-time {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 19px;
  font-weight: 700;
  background:
    radial-gradient(closest-side, #241433 78%, transparent 80% 100%),
    conic-gradient(var(--blue) calc(var(--t, 1) * 360deg), rgba(255, 255, 255, 0.12) 0);
}
.hud-time.low {
  background:
    radial-gradient(closest-side, #3a1020 78%, transparent 80% 100%),
    conic-gradient(var(--accent) calc(var(--t, 1) * 360deg), rgba(255, 255, 255, 0.12) 0);
  animation: lowPulse 0.8s ease-in-out infinite;
}
@keyframes lowPulse { 50% { transform: scale(1.08); } }

/* --------------------------------------------------------------- dining */

.dining {
  flex: 0 0 auto;
  position: relative;
  padding: 6px 8px 0;
  background-size: cover;
  background-position: center 30%;
}
.dining::before { /* dim the photo so the tickets read */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(20, 10, 30, 0.35), rgba(20, 10, 30, 0.6));
  pointer-events: none;
}
.dining::after { /* the counter the plates sit on */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 30%;
  background: linear-gradient(#e7834a, #c9632f 14%, #a54f26);
  border-top: 3px solid #f6a36c;
  box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.25);
}
.dining > * { position: relative; z-index: 1; }

.queue {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  min-height: 0;
  height: 0;
  overflow: visible;
}
.queue-chip {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px 2px 3px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 12px;
  font-weight: 700;
}
.queue-chip img { width: 22px; height: 22px; border-radius: 50%; margin-right: -8px; border: 2px solid #2a1838; background: #fff; }
.queue-chip span { margin-left: 10px; }

.seats {
  display: grid;
  grid-template-columns: repeat(var(--n, 3), 1fr);
  gap: 6px;
}
.seat {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  padding-bottom: 6px;
  border-radius: 16px;
  transition: transform 0.15s, filter 0.15s;
}
.seat.empty .cust, .seat.empty .ticket-name { visibility: hidden; }
.seat.empty .plate { opacity: 0.45; }

.cust {
  position: relative;
  width: clamp(48px, 13vw, 60px);
  aspect-ratio: 1;
  border-radius: 50%;
  padding: 4px;
  background: conic-gradient(var(--pc, var(--green)) calc(var(--p, 1) * 360deg), rgba(0, 0, 0, 0.35) 0);
}
.cust img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #fff;
  object-fit: cover;
  display: block;
}
.cust .badge {
  position: absolute;
  right: -6px;
  top: -4px;
  font-size: 15px;
  line-height: 1;
  padding: 3px;
  border-radius: 50%;
  background: #2a1838;
}
.seat.arrive .cust { animation: custIn 0.45s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes custIn { from { transform: translateY(-24px) scale(0.6); opacity: 0; } }
.seat.angry .cust { animation: custShake 0.45s ease-in-out infinite; }
@keyframes custShake { 25% { transform: rotate(-7deg); } 75% { transform: rotate(7deg); } }

.ticket-name {
  margin: 3px 0 2px;
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  color: #2a1838;
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

/* The plate doubles as the order ticket: every item the customer wants is
   drawn on it, faded until it's added. */
.plate {
  position: relative;
  width: min(100%, 136px);
  aspect-ratio: 1.25;
  background: url("/assets/kk/plate.png") center / contain no-repeat;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 0 1px;
  padding: 10% 12%;
}
.plate img {
  width: clamp(28px, 9vw, 40px);
  height: clamp(28px, 9vw, 40px);
  object-fit: contain;
  transition: opacity 0.15s, filter 0.15s, transform 0.2s;
}
.plate img.ghost { opacity: 0.38; filter: grayscale(0.8) brightness(1.1); transform: scale(0.82); }
.plate img.on { filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35)); }
.plate img.pop { animation: pop 0.3s cubic-bezier(0.2, 1.8, 0.4, 1); }
@keyframes pop { from { transform: scale(1.6); } }
.seat.complete .plate { animation: plateGlow 0.45s ease-in-out; }
@keyframes plateGlow { 50% { transform: scale(1.12); filter: drop-shadow(0 0 12px var(--gold)); } }
.seat.leaving { animation: seatOut 0.4s ease-in forwards; }
@keyframes seatOut { to { transform: translateY(-14px); opacity: 0.2; } }

/* Drop targets while a food is held or dragged. */
.seat.wants { filter: drop-shadow(0 0 8px rgba(46, 204, 113, 0.95)); }
.seat.wants .plate::after {
  content: "";
  position: absolute;
  inset: 4% 8%;
  border-radius: 50%;
  border: 3px dashed rgba(46, 204, 113, 0.95);
  animation: spin 6s linear infinite;
}
.seat.hover { transform: scale(1.06); }
@keyframes spin { to { transform: rotate(360deg); } }

/* -------------------------------------------------------------- kitchen */

.kitchen {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), 1fr);
  grid-template-rows: repeat(var(--rows, 2), minmax(0, 1fr));
  gap: 8px;
  padding: 10px 10px max(10px, env(safe-area-inset-bottom));
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.05) 25%, transparent 25% 75%, rgba(255, 255, 255, 0.05) 75%) 0 0 / 40px 40px,
    linear-gradient(45deg, rgba(255, 255, 255, 0.05) 25%, transparent 25% 75%, rgba(255, 255, 255, 0.05) 75%) 20px 20px / 40px 40px,
    #3b2550;
}

.stn {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: linear-gradient(#5a3d74, #46305c);
  border: 2px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.08s;
}
.stn:active { transform: translateY(2px); }
.stn-name {
  flex: 0 0 auto;
  padding: 5px 6px 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stn-hob {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
}
.stn-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0 4px;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.35));
  pointer-events: none;
}
.pans {
  position: relative;
  display: flex;
  gap: 4px;
  margin-bottom: 18%;
}

/* A slot on the appliance: empty, cooking (ring fills), ready (gold,
   bouncing: tap or drag it), close to burning (red pulse), burnt. */
.pan {
  --sz: clamp(44px, 13vw, 60px);
  position: relative;
  width: var(--sz);
  height: var(--sz);
  border-radius: 50%;
  display: grid;
  place-items: center;
  touch-action: none;
}
.pan.empty { visibility: hidden; }
.pan::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--ring, #fff) calc(var(--p, 0) * 1%), rgba(0, 0, 0, 0.45) 0);
  -webkit-mask: radial-gradient(closest-side, transparent 76%, #000 78%);
  mask: radial-gradient(closest-side, transparent 76%, #000 78%);
}
.pan img {
  width: 78%;
  height: 78%;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.4));
  pointer-events: none;
}
.pan.cooking img { filter: saturate(0.5) brightness(0.85); }
.pan.ready { --ring: var(--gold); animation: readyBob 0.9s ease-in-out infinite; }
.pan.ready::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--gold), 0 0 16px 4px rgba(255, 215, 0, 0.6);
}
@keyframes readyBob { 50% { transform: translateY(-4px); } }
.pan.warn { --ring: var(--accent); animation: warnShake 0.35s ease-in-out infinite; }
.pan.warn::after { box-shadow: 0 0 0 3px var(--accent), 0 0 18px 6px rgba(255, 46, 99, 0.7); }
@keyframes warnShake { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
.pan.burnt img { filter: grayscale(1) brightness(0.3); }
.pan.burnt::before { background: rgba(0, 0, 0, 0.6); }
.pan.burnt::after { content: "💨"; position: absolute; top: -12px; right: -6px; font-size: 20px; box-shadow: none; }
.pan.selected::after { box-shadow: 0 0 0 4px #fff, 0 0 18px 6px rgba(255, 255, 255, 0.7); }
.pan.lifted { opacity: 0.3; }

.stn-chips {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 0 4px 6px;
}
.chip {
  flex: 1 1 0;
  max-width: 64px;
  min-width: 0;
  height: clamp(40px, 11vw, 48px);
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.3);
  display: grid;
  place-items: center;
  padding: 2px;
  cursor: pointer;
}
.chip img { width: 100%; height: 100%; max-width: 38px; object-fit: contain; pointer-events: none; }
.chip:active { transform: scale(0.92); }
.chip.needed {
  border-color: var(--green);
  background: rgba(46, 204, 113, 0.22);
  box-shadow: 0 0 10px rgba(46, 204, 113, 0.45);
}
.stn.busy .chip { opacity: 0.45; }
.stn.busy .chip.needed { box-shadow: none; }

/* The bin is a kitchen tile like the rest (and a drop target). */
.stn.bin-tile {
  justify-content: center;
  align-items: center;
  background: linear-gradient(#4a3b46, #382c35);
}
.bin-tile img { width: min(70%, 72px); aspect-ratio: 1; object-fit: contain; }
.bin-tile .stn-name { padding-top: 0; }
.bin-tile.armed { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 0 16px rgba(255, 46, 99, 0.6); }
.bin-tile.hover { transform: scale(1.05); }

.coach-ring { box-shadow: 0 0 0 3px #fff, 0 0 0 7px rgba(8, 217, 214, 0.8) !important; animation: coachPulse 1.1s ease-in-out infinite; z-index: 5; }
@keyframes coachPulse { 50% { box-shadow: 0 0 0 3px #fff, 0 0 0 12px rgba(8, 217, 214, 0.25) !important; } }

/* The coach sits on the seam between dining and kitchen and never takes
   taps, so it can't cover what it's pointing at. */
.coach {
  position: absolute;
  left: 12px;
  right: 12px;
  z-index: 40;
  padding: 7px 12px;
  border-radius: 14px;
  background: #fff;
  color: #2a1838;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  transform: translateY(-50%);
  animation: coachIn 0.25s ease;
}
@keyframes coachIn { from { opacity: 0; transform: translateY(-30%); } }

.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 64px;
  height: 64px;
  object-fit: contain;
  pointer-events: none;
  z-index: 200;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.5));
  transform: translate(-50%, -70%) scale(1.15);
}

/* ------------------------------------------------------- juice & floats */

.float-text {
  position: absolute;
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  color: var(--gold);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.65);
  transform: translate(-50%, -50%);
  animation: floatUp 1.1s ease-out forwards;
  z-index: 60;
  pointer-events: none;
  white-space: nowrap;
}
.float-text.combo { color: #ff9f1c; font-size: 24px; }
.float-text.bad { color: #ff6b6b; font-size: 26px; }
@keyframes floatUp { to { transform: translate(-50%, -190%); opacity: 0; } }

.toast {
  position: absolute;
  left: 50%;
  bottom: 30%;
  transform: translateX(-50%);
  z-index: 80;
  max-width: 86%;
  padding: 9px 16px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.82);
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  pointer-events: none;
  animation: toastIn 0.2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ------------------------------------------------------ level intro card */

.day-intro {
  position: absolute;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(15, 8, 24, 0.72);
  backdrop-filter: blur(3px);
}
.day-intro-card {
  width: min(100%, 360px);
  max-height: 100%;
  overflow-y: auto;
  padding: 22px 20px 16px;
  border-radius: 22px;
  background: linear-gradient(#3d2758, #2a1838);
  border: 2px solid rgba(255, 255, 255, 0.15);
  text-align: center;
  animation: custIn 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.day-intro-loc { font-family: var(--display); font-size: 16px; color: var(--accent-2); }
.day-intro-day { font-family: var(--display); font-size: 34px; font-weight: 700; color: var(--gold); line-height: 1.1; }
.day-intro-target { color: var(--muted); margin: 6px 0 12px; font-size: 14px; }
.day-intro-target b { color: var(--text); }
.day-intro-menu { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; text-align: left; }
.menu-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
}
.menu-row .menu-name { flex: 1; font-weight: 700; font-size: 14px; }
.menu-row .menu-ings { display: flex; gap: 2px; }
.menu-row img { width: 28px; height: 28px; object-fit: contain; }
.day-intro-tip { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------- short phones */

@media (max-height: 700px) {
  .hud { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 6px; }
  .hud .icon-btn { width: 40px; height: 40px; }
  .hud-time { width: 46px; height: 46px; font-size: 17px; }
  .cust { width: 44px; }
  .ticket-name { font-size: 12px; }
  .plate { width: min(100%, 100px); }
  .plate img { width: 26px; height: 26px; }
  .kitchen { gap: 6px; padding-top: 8px; }
}
@media (max-height: 600px) {
  .stn-name { display: none; }
}

/* ----------------------------------------------------------------- tablets */

/* Touch screens 600px+ wide (and 500px+ tall, so phones on their side stay
   as they are): the column fills the tablet, so the customers, plates,
   appliances and buttons all grow. Desktop (mouse) is unchanged. Sizes that
   decide the play area's height use dvh so a level never scrolls. */
@media (min-width: 600px) and (min-height: 500px) and (pointer: coarse) {
  .hud { gap: 16px; padding: max(12px, env(safe-area-inset-top)) 20px 12px; }
  .hud .icon-btn { width: 60px; height: 60px; font-size: 24px; }
  .hud-goal-top { font-size: 18px; margin-bottom: 8px; }
  .hud-coins b { font-size: 26px; }
  .goal-bar { height: 16px; border-radius: 8px; }
  .goal-fill { border-radius: 8px; }
  .goal-star { font-size: 20px; }
  .hud-time { width: 70px; height: 70px; font-size: 26px; }

  .dining { padding: 10px 16px 0; }
  .queue-chip { font-size: 16px; padding: 4px 12px 4px 4px; border-radius: 20px; }
  .queue-chip img { width: 32px; height: 32px; }
  /* Seats are only as wide as their plate: the plate's % padding is taken
     from the seat's width, so a wider seat would squeeze the food. */
  .seats { --pw: min(19dvh, 240px); grid-template-columns: repeat(var(--n, 3), minmax(0, var(--pw))); justify-content: space-around; gap: 16px; }
  .seat { padding-bottom: 10px; }
  .cust { width: clamp(64px, 8dvh, 104px); padding: 6px; }
  .cust .badge { font-size: 22px; padding: 4px; }
  .ticket-name { font-size: 19px; padding: 4px 14px; margin: 6px 0 4px; border-radius: 10px; }
  .plate { width: 100%; }
  .plate img { width: clamp(36px, 4.6dvh, 60px); height: clamp(36px, 4.6dvh, 60px); }

  .kitchen { gap: 14px; padding: 16px 16px max(16px, env(safe-area-inset-bottom)); }
  .stn { border-radius: 24px; border-width: 3px; }
  .stn-name { font-size: 18px; padding: 10px 10px 0; }
  .pans { gap: 10px; }
  .pan { --sz: clamp(64px, 7.5dvh, 100px); }
  .pan.burnt::after { font-size: 28px; top: -16px; }
  .stn-chips { gap: 10px; padding: 0 10px 12px; }
  .chip { height: 72px; max-width: 100px; border-radius: 16px; border-width: 3px; padding: 4px; }
  .chip img { max-width: 56px; }
  .bin-tile img { width: min(60%, 120px); }

  .coach { left: 20px; right: 20px; padding: 12px 20px; font-size: 19px; border-radius: 18px; }
  .drag-ghost { width: 96px; height: 96px; }
  .float-text { font-size: 32px; }
  .float-text.combo { font-size: 34px; }
  .float-text.bad { font-size: 36px; }
  .toast { font-size: 20px; padding: 14px 24px; border-radius: 16px; }

  .day-intro { padding: 32px; }
  .day-intro-card { width: min(100%, 560px); padding: 32px 30px 24px; border-radius: 28px; }
  .day-intro-loc { font-size: 22px; }
  .day-intro-day { font-size: 52px; }
  .day-intro-target { font-size: 19px; margin: 10px 0 18px; }
  .day-intro-menu { gap: 10px; }
  .menu-row { padding: 10px 16px; gap: 12px; border-radius: 16px; }
  .menu-row .menu-name { font-size: 20px; }
  .menu-row .menu-ings { gap: 4px; }
  .menu-row img { width: 44px; height: 44px; }
  .day-intro-tip { font-size: 16px; }
}
/* Tablet on its side: height is the limit, so the dining counter and
   appliances are sized off the height and the kitchen spreads sideways. */
@media (min-width: 600px) and (min-height: 500px) and (pointer: coarse) and (orientation: landscape) {
  .hud { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: 8px; }
  .hud-time { width: 62px; height: 62px; font-size: 23px; }
  .seats { --pw: min(23dvh, 220px); gap: 24px; }
  .cust { width: clamp(52px, 9dvh, 88px); }
  .ticket-name { font-size: 17px; margin: 4px 0 2px; }
  .plate img { width: clamp(32px, 5.6dvh, 54px); height: clamp(32px, 5.6dvh, 54px); }
  .kitchen { gap: 12px; padding-top: 12px; }
  .stn-name { font-size: 17px; padding-top: 6px; }
  .pan { --sz: clamp(52px, 9.5dvh, 88px); }
  .stn-chips { padding-bottom: 8px; }
  .chip { height: clamp(56px, 7.5dvh, 64px); }
  .day-intro { padding: 16px; }
  .day-intro-card { padding: 22px 26px 16px; }
  .day-intro-day { font-size: 44px; }
  .day-intro-target { margin: 6px 0 12px; }
  .menu-row { padding: 6px 14px; }
}
