/* Mobile szafki — landscape shelf, on-box open, 60/90s rounds. */
:root {
  --surface: #FFFFFF;
  --surface-2: #FFF7ED;
  --orange: #FF6531;
  --orange-deep: #EA580C;
  --orange-soft: #FFEDD5;
  --text: #1C1917;
  --muted: #78716C;
  --line: #FED7AA;
  --on-orange: #FFFFFF;
  --ok: #16A34A;
  --ok-soft: #DCFCE7;
  --bad: #DC2626;
  --bad-soft: #FEE2E2;
  --rack: #13447C;
  --font: "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 480px at 80% -10%, var(--orange-soft) 0%, transparent 55%),
    linear-gradient(180deg, #fff 0%, var(--surface-2) 100%);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.view[hidden] { display: none !important; }

.rotate-gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 60;
  place-items: center;
  padding: 1.5rem;
  text-align: center;
  background: rgba(255, 247, 237, 0.4);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  cursor: pointer;
}
body.is-rotate-hint .rotate-gate { display: grid; }

.round-break {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 70;
  place-items: center;
  padding: 1.5rem;
  text-align: center;
  background: rgba(255, 247, 237, 0.45);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  cursor: pointer;
}
body.is-round-break .round-break { display: grid; }
.round-break__card {
  appearance: none;
  -webkit-appearance: none;
  max-width: 22rem;
  width: 100%;
  margin: 0;
  padding: 1.25rem 1.15rem 1.3rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgba(28, 25, 23, 0.14);
  color: inherit;
  font: inherit;
  text-align: center;
  cursor: pointer;
}
.round-break__card:active { transform: scale(0.98); }
.round-break__eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--orange);
}
.round-break__title {
  margin: 0 0 0.45rem;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.round-break__body {
  margin: 0 0 0.65rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}
.round-break__stats {
  margin: 0 0 0.85rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.45;
  color: var(--text);
}
.round-break__next {
  margin: 0 0 0.55rem;
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--orange-deep);
}
.round-break__cta {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.app-switch {
  position: fixed;
  top: calc(8px + var(--safe-t));
  right: calc(8px + var(--safe-r));
  z-index: 9999;
  display: flex;
  gap: 4px;
  opacity: 0.55;
}
.app-switch a {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-decoration: none;
  display: grid;
  place-items: center;
}
.app-switch a.is-current {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--on-orange);
  opacity: 1;
}

.view--landing,
.view--results {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-t)) 16px calc(28px + var(--safe-b));
}
.landing,
.results {
  width: min(26rem, 100%);
  padding: 1.35rem 1.25rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 12px 36px rgba(28, 25, 23, 0.06);
}
.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--orange);
}
h1 {
  margin: 0 0 0.55rem;
  font-size: clamp(1.45rem, 5.5vw, 1.85rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
}
.lead {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.bullets {
  margin: 0 0 1rem;
  padding-left: 1.15rem;
  color: var(--text);
  font-size: 0.9rem;
}
.bullets li { margin: 0.25rem 0; }
.rotate-hint {
  margin: 0.75rem 0 0;
  text-align: center;
  font-size: 0.82rem;
}

.session {
  margin: 0 0 1rem;
  padding: 0.7rem 0.75rem;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.session__lab {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.session__opts {
  display: flex;
  gap: 0.45rem;
}
.session__btn {
  flex: 1;
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.session__btn.is-on {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--on-orange);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn:active { transform: scale(0.98); }
.btn--primary {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--on-orange);
}
.btn--primary:hover { background: var(--orange-deep); border-color: var(--orange-deep); }
.results__actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 1.1rem;
}

.rotate-gate__card {
  appearance: none;
  -webkit-appearance: none;
  max-width: 18rem;
  width: 100%;
  margin: 0;
  padding: 1.15rem 1.1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgba(28, 25, 23, 0.14);
  color: inherit;
  font: inherit;
  text-align: center;
  cursor: pointer;
}
.rotate-gate__card:active { transform: scale(0.98); }
.rotate-gate__phone {
  width: 52px;
  height: 88px;
  margin: 0 auto 1rem;
  border: 3px solid var(--orange);
  border-radius: 10px;
  background: var(--orange-soft);
  animation: tipPhone 1.4s ease-in-out infinite;
  transform-origin: 50% 70%;
}
@keyframes tipPhone {
  0%, 100% { transform: rotate(0deg); }
  40% { transform: rotate(90deg); }
  60% { transform: rotate(90deg); }
}
.rotate-gate__title {
  margin: 0 0 0.4rem;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.rotate-gate__body {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

/* --- Game: always landscape stage (force-rotate when viewport is tall) --- */
.view--game {
  position: fixed;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: 100dvw;
  height: 100dvh;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding:
    calc(8px + var(--safe-t))
    calc(10px + var(--safe-r))
    calc(8px + var(--safe-b))
    calc(10px + var(--safe-l));
  overflow: hidden;
  background:
    radial-gradient(900px 480px at 80% -10%, var(--orange-soft) 0%, transparent 55%),
    linear-gradient(180deg, #fff 0%, var(--surface-2) 100%);
}

/* Portrait / tall window: treat short side as height, long as width */
@media (max-aspect-ratio: 1/1) {
  .view--game {
    width: 100dvh;
    height: 100dvw;
    transform: translate(-50%, -50%) rotate(90deg);
    padding: 8px 10px;
  }
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  flex-shrink: 0;
}
.topbar__mode { display: flex; flex-direction: column; gap: 0.05rem; min-width: 0; }
.pill {
  display: inline-flex;
  width: fit-content;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: var(--orange-soft);
  color: var(--orange-deep);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.pill.is-wms {
  background: var(--ok-soft);
  color: var(--ok);
}
.muted { color: var(--muted); font-size: 0.75rem; }
.topbar__stats {
  display: flex;
  gap: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.topbar__stats div {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}
.topbar__stats b { font-size: 1.05rem; }
.topbar__stats small { color: var(--muted); font-size: 0.65rem; }
.topbar__stats .is-low { color: var(--bad); }
.sfx-btn {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 1rem;
}

.game-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(12rem, 40%) 1fr;
  gap: 0.55rem;
}

.pick-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 0.45rem 0.5rem 0.5rem;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.pick-card__lab {
  margin: 0 0 0.3rem;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  flex-shrink: 0;
}
.pick-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  flex: 1;
}
.pick-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.3rem 0.35rem;
  align-items: start;
  padding: 0.28rem 0.35rem;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid transparent;
}
.pick-row.is-done {
  opacity: 0.55;
  text-decoration: line-through;
}
.pick-row.is-next {
  border-color: var(--orange);
  background: var(--orange-soft);
}
.pick-row__ico {
  font-size: 1.05rem;
  line-height: 1;
  margin-top: 0.1rem;
}
.pick-row__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
}
.pick-row__name {
  font-weight: 800;
  font-size: 0.82rem;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  word-break: break-word;
}
.pick-row__ean {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
  line-height: 1.25;
  word-break: break-all;
}
.pick-row__loc {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--orange);
  letter-spacing: 0.06em;
  line-height: 1.2;
  margin-top: 0.05rem;
}
.pick-row__qty {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--orange-deep);
  font-size: 0.78rem;
  margin-top: 0.1rem;
}

.shelf-col {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.cabinet-nav {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 0.4rem;
  align-items: center;
  flex-shrink: 0;
}
.nav-arrow {
  width: 48px; height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--orange);
  color: var(--on-orange);
  font-size: 1.35rem;
  font-weight: 800;
  cursor: pointer;
  line-height: 1;
}
.nav-arrow:active { background: var(--orange-deep); }
.nav-arrow:disabled {
  opacity: 0.35;
  cursor: default;
}
.cabinet-nav__title {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}
.cabinet-nav__title strong {
  font-size: 1rem;
  color: var(--rack);
}

.cabinet {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 0;
}
.floor {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 2.6rem 1fr;
  gap: 0.35rem;
  align-items: stretch;
  padding: 0.3rem;
  border-radius: 10px;
  background: rgba(19, 68, 124, 0.06);
  border: 1px solid transparent;
}
.floor.is-hot {
  border-color: var(--orange);
  background: var(--orange-soft);
}
.floor__lab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  border-radius: 8px;
  background: var(--rack);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  text-align: center;
  padding: 0.25rem 0.1rem;
  line-height: 1.15;
}
.floor__lab strong {
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}
.floor.is-hot .floor__lab {
  background: var(--orange);
}
.floor__boxes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  min-height: 0;
}

.box {
  --cardboard: #C9A66B;
  --cardboard-2: #B89555;
  --cardboard-edge: #8B6914;
  position: relative;
  min-height: 0;
  padding: 0.7rem 0.4rem 0.35rem;
  border-radius: 4px 4px 6px 6px;
  border: 1px solid var(--cardboard-edge);
  border-bottom-width: 3px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(139, 105, 20, 0.07) 0 1px,
      transparent 1px 5px
    ),
    linear-gradient(165deg, #D8B87A 0%, var(--cardboard) 42%, var(--cardboard-2) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 3px 0 rgba(92, 64, 18, 0.25),
    0 6px 12px rgba(28, 25, 23, 0.12);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
}
.box__flap {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 10px;
  background: linear-gradient(180deg, #A67C3D 0%, #C4A05A 70%, transparent 100%);
  border-bottom: 1px dashed rgba(92, 64, 18, 0.35);
  pointer-events: none;
}
.box:active:not(:disabled) { transform: scale(0.97); }
.box:disabled { cursor: default; }
.box.is-taken {
  border-color: var(--ok);
  filter: saturate(0.7) brightness(1.05);
  opacity: 0.88;
}
.box.is-target {
  border-color: var(--orange);
  box-shadow:
    0 0 0 2px var(--orange),
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 3px 0 rgba(92, 64, 18, 0.25),
    0 6px 12px rgba(255, 101, 49, 0.25);
  animation: targetPulse 1.2s ease-in-out infinite;
}
@keyframes targetPulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--orange), 0 3px 0 rgba(92, 64, 18, 0.25); }
  50% { box-shadow: 0 0 0 4px rgba(255, 101, 49, 0.55), 0 3px 0 rgba(92, 64, 18, 0.25); }
}
.box__ping {
  position: absolute;
  top: 12px; right: 6px;
  font-size: 0.65rem;
  color: var(--orange);
  line-height: 1;
}
.box.is-opening {
  border-color: var(--orange);
  box-shadow: 0 0 0 2px var(--orange-soft), 0 3px 0 rgba(92, 64, 18, 0.25);
  pointer-events: none;
  animation: none;
}
.box.is-flash-ok {
  border-color: var(--ok);
  animation: flashOk 0.4s ease;
}
.box.is-flash-bad {
  border-color: var(--bad);
  animation: flashBad 0.4s ease;
}
@keyframes flashOk {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.04); }
}
@keyframes flashBad {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.box__slot {
  align-self: flex-start;
  margin-top: 0.1rem;
  padding: 0.1rem 0.4rem;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #5C4012;
  background: rgba(255, 247, 237, 0.7);
  border: 1px solid rgba(92, 64, 18, 0.35);
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.box__label {
  margin-top: auto;
  padding: 0.28rem 0.3rem 0.25rem;
  border-radius: 2px;
  background: #FFFEFA;
  border: 1px solid rgba(92, 64, 18, 0.28);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.box__code {
  font-family: var(--mono);
  font-size: 0.62rem;
  word-break: break-all;
  color: #1C1917;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.02em;
}
.box__barcode {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 1px;
  height: 20px;
  padding: 0 1px;
  background: #FFFEFA;
}
.box__barcode i {
  display: block;
  flex: 0 0 auto;
  height: 100%;
  background: #1C1917;
  border-radius: 0;
}
.box__taken {
  position: absolute;
  top: 12px; right: 6px;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--ok);
  background: var(--ok-soft);
  border-radius: 50%;
  width: 1.2rem; height: 1.2rem;
  display: grid;
  place-items: center;
}

/* On-shelf open / result (no modal) */
.box__fx {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.35rem;
  background: rgba(255, 255, 255, 0.92);
  text-align: center;
  pointer-events: none;
}
.box__fx.is-ok { background: rgba(220, 252, 231, 0.95); }
.box__fx.is-bad { background: rgba(254, 226, 226, 0.95); }
.box__fx-lab {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
}
.box__fx.is-ok .box__fx-lab { color: var(--ok); }
.box__fx.is-bad .box__fx-lab { color: var(--bad); }
.box__fx-sub {
  margin: 0;
  font-size: 0.62rem;
  color: var(--muted);
  line-height: 1.2;
  max-height: 2.4em;
  overflow: hidden;
}

.spin {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid var(--orange-soft);
  border-top-color: var(--orange);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hint {
  margin: 0;
  min-height: 1.1em;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  flex-shrink: 0;
}

.compare {
  display: grid;
  gap: 0.5rem;
  margin: 0.25rem 0 0.85rem;
}
.compare__row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.35rem;
  align-items: center;
  padding: 0.55rem 0.6rem;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.85rem;
}
.compare__row b { font-variant-numeric: tabular-nums; }
.compare__lab { color: var(--muted); font-weight: 600; }
.pick-order {
  margin: 0.35rem 0 0.15rem;
  padding: 0.2rem 0.35rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--orange-deep);
  background: var(--orange-soft);
  border-radius: 6px;
  border: 1px solid var(--line);
}
.pick-order:first-child { margin-top: 0; }

.compare__row--shift {
  margin-top: 0.35rem;
  padding-top: 0.45rem;
  border-top: 1px dashed var(--line);
}
.compare__row--shift b { color: var(--orange-deep); }
.speed-banner {
  padding: 0.85rem 0.9rem;
  border-radius: 12px;
  background: var(--orange);
  color: var(--on-orange);
  font-weight: 800;
  text-align: center;
  font-size: 1.05rem;
  line-height: 1.3;
}
.speed-banner span {
  display: block;
  font-weight: 600;
  font-size: 0.82rem;
  opacity: 0.92;
  margin-top: 0.25rem;
}

/* Short stage (real landscape phone OR forced portrait→landscape) */
@media (max-height: 430px), (max-aspect-ratio: 1/1) {
  .box__code { font-size: 0.58rem; }
  .cabinet-nav { grid-template-columns: 42px 1fr 42px; }
  .nav-arrow { width: 42px; height: 42px; font-size: 1.2rem; }
  .pick-row__name { font-size: 0.76rem; }
  .pick-row__ean { font-size: 0.68rem; }
  .pick-row__loc { font-size: 0.88rem; }
  .game-layout { grid-template-columns: minmax(11rem, 42%) 1fr; }
}
