:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: #111;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  user-select: none;
}

main {
  min-height: 100vh;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 116px max(18px, env(safe-area-inset-left));
}

.orders {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: 18px;
}

.order-card {
  border: 0;
  border-radius: 28px;
  min-height: clamp(250px, 35vh, 390px);
  padding: 28px 22px;
  color: #101010;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  cursor: pointer;
  min-width: 0;
  width: 100%;
}

.order-card:active { transform: scale(.985); }
.order-card.green { background: #39d353; }
.order-card.yellow { background: #ffd43b; }
.order-card.red { background: #ff4d4f; color: #fff; }

.pager {
  font-size: clamp(26px, 3.5vw, 40px);
  line-height: 1;
  font-weight: 900;
  text-align: center;
  letter-spacing: -.03em;
  max-width: 100%;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.pager.missing { font-size: clamp(24px, 3.2vw, 36px); }
.pager.product-label { font-size: clamp(30px, 5vw, 54px); line-height: 1.08; }
.pager.product-label.long-label { font-size: clamp(26px, 4.2vw, 44px); }
.pager.product-label.very-long-label { font-size: clamp(22px, 3.5vw, 36px); }
.pager.has-telecomando {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  white-space: nowrap;
}
.pager-word { font-size: clamp(20px, 2.6vw, 30px); }
.pager-number { font-size: clamp(48px, 6vw, 70px); }

.timer {
  margin-top: 24px;
  font-size: clamp(56px, 8vw, 92px);
  line-height: .9;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  letter-spacing: -.06em;
}

.closed-time {
  margin-top: 18px;
  font-size: 18px;
  font-weight: 700;
  opacity: .78;
}

.empty {
  margin: 34vh 0 0;
  text-align: center;
  color: #888;
  font-size: 34px;
  font-weight: 750;
}

.undo-button {
  position: fixed;
  z-index: 20;
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  min-height: 76px;
  border: 2px solid #444;
  border-radius: 20px;
  background: #242424;
  color: #fff;
  font-size: 28px;
  font-weight: 850;
  touch-action: manipulation;
}

.undo-panel {
  position: fixed;
  z-index: 15;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 78vh;
  overflow-y: auto;
  padding: 26px 24px 118px;
  background: #171717;
  border-top: 2px solid #444;
  box-shadow: 0 -14px 40px rgba(0, 0, 0, .5);
}

.undo-panel h2 {
  margin: 0 0 18px;
  font-size: 34px;
}

.delivered-orders {
  display: grid;
  gap: 12px;
}

.delivered-order {
  min-height: 82px;
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  background: #f2f2f2;
  color: #111;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 20px;
  font-size: 24px;
  font-weight: 850;
  text-align: left;
  touch-action: manipulation;
}

.delivered-order span:nth-child(2),
.delivered-order span:nth-child(3) {
  font-variant-numeric: tabular-nums;
}

.delivered-label {
  white-space: pre-line;
  overflow-wrap: anywhere;
  min-width: 0;
}
.delivered-label .pager-word,
.delivered-label .pager-number { font-size: inherit; }

.delivered-label.long-label { font-size: 21px; }
.delivered-label.very-long-label { font-size: 18px; }

.delivered-empty {
  margin: 40px 0;
  text-align: center;
  color: #999;
  font-size: 26px;
}

.connection {
  position: fixed;
  right: 16px;
  bottom: 110px;
  border-radius: 999px;
  background: #fff;
  color: #111;
  padding: 10px 16px;
  font-weight: 750;
}

@media (orientation: landscape) and (min-width: 900px) {
  .orders { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .order-card { min-height: clamp(240px, 43vh, 390px); }
  .pager { font-size: clamp(26px, 3vw, 36px); }
  .pager.missing { font-size: clamp(24px, 2.8vw, 34px); }
  .pager.product-label { font-size: clamp(30px, 3.8vw, 48px); }
  .pager.product-label.long-label { font-size: clamp(25px, 3.2vw, 40px); }
  .pager-word { font-size: clamp(19px, 2.1vw, 26px); }
  .pager-number { font-size: clamp(46px, 5vw, 62px); }
  .timer { font-size: clamp(52px, 7vw, 82px); }
}

@media (orientation: portrait) and (min-width: 700px) {
  .orders { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (display-mode: standalone), (display-mode: fullscreen) {
  body { min-height: 100dvh; }
}
