:root {
  color-scheme: light;
  --brand: #d41445;
  --coral: #ff6847;
  --navy: #111a2d;
  --ink: #182237;
  --muted: #6c7585;
  --waiting: #d95b25;
  --waiting-soft: #fff0e7;
  --preparing: #a97300;
  --preparing-soft: #fff4cf;
  --ready: #087859;
  --ready-deep: #045b42;
  --ready-soft: #def5ec;
  font-family:
    "Avenir Next", "Segoe UI Variable", "Segoe UI", Inter, ui-sans-serif,
    system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #dfe4ea;
}

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 100vh;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.display-header {
  display: grid;
  grid-template-columns: minmax(175px, 0.75fr) minmax(280px, 1.5fr) minmax(180px, 0.75fr);
  align-items: center;
  gap: 1rem;
  min-height: 60px;
  padding: 0.45rem clamp(0.8rem, 1.5vw, 1.6rem);
  color: #fff;
  border-bottom: 3px solid var(--brand);
  background: linear-gradient(100deg, #472733 0%, #382432 100%);
  box-shadow: 0 4px 14px rgba(15, 24, 41, 0.18);
  z-index: 2;
}

.display-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.club-brand-logo {
  width: 64px;
  height: 38px;
  padding: 1px 13px;
  flex: 0 0 auto;
  object-fit: contain;
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 9px;
  background: #d8103f;
}

.display-brand > span:last-child {
  display: grid;
}

.display-brand strong {
  font-size: clamp(1.15rem, 1.5vw, 1.55rem);
  letter-spacing: -0.04em;
}

.display-brand small {
  margin-top: 0.08rem;
  color: rgba(255, 255, 255, 0.58);
  font-size: clamp(0.58rem, 0.7vw, 0.72rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.display-title {
  text-align: center;
}

.display-title p,
.display-title h1 {
  margin: 0;
}

.display-title p {
  color: #ff9d86;
  font-size: clamp(0.58rem, 0.7vw, 0.72rem);
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.display-title h1 {
  margin-top: 0.12rem;
  font-size: clamp(1.05rem, 1.55vw, 1.6rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.display-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.7rem;
}

.live-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0 0.8rem;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.78rem;
  font-weight: 850;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.live-status i,
.footer-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #42d794;
  box-shadow: 0 0 0 5px rgba(66, 215, 148, 0.13);
}

body.is-offline .live-status i,
body.is-offline .footer-dot {
  background: #ff795d;
  box-shadow: 0 0 0 5px rgba(255, 121, 93, 0.14);
}

.display-tool {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: rgba(255, 255, 255, 0.82);
  font: inherit;
  font-size: 1.2rem;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
}

.display-tool svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.display-tool:hover,
.display-tool:focus-visible,
.display-tool.can-install {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  outline: 3px solid rgba(255, 255, 255, 0.15);
}

.display-tool.can-install {
  color: #fff;
  border-color: rgba(255, 157, 134, 0.6);
  background: rgba(212, 20, 69, 0.55);
}

.status-board {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr) minmax(0, 1.3fr);
  gap: clamp(0.65rem, 1vw, 1.1rem);
  min-height: 0;
  padding: clamp(0.65rem, 1.2vw, 1.25rem);
  background:
    radial-gradient(circle at 5% 0%, rgba(212, 20, 69, 0.04), transparent 35rem),
    #dfe4ea;
}

.status-lane {
  --lane: var(--waiting);
  --lane-soft: var(--waiting-soft);
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #c5cbd5;
  border-radius: clamp(14px, 1.4vw, 22px);
  background: #f4f6f8;
  box-shadow: 0 4px 16px rgba(18, 29, 48, 0.08);
}

.status-lane::before {
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  content: "";
  background: var(--lane);
}

.lane-preparing {
  --lane: var(--preparing);
  --lane-soft: var(--preparing-soft);
}

.lane-ready {
  --lane: var(--ready);
  --lane-soft: var(--ready-soft);
  border-color: #8abaaa;
  background: #edf7f3;
  box-shadow: 0 7px 24px rgba(8, 120, 89, 0.12);
}

.status-lane > header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: clamp(0.55rem, 0.9vw, 1rem);
  min-height: clamp(72px, 9vh, 104px);
  padding: 1rem clamp(0.8rem, 1.3vw, 1.35rem) 0.85rem;
  border-bottom: 1px solid #d5dae2;
  background: rgba(255, 255, 255, 0.88);
}

.lane-ready > header {
  color: #fff;
  border-bottom-color: var(--ready-deep);
  background: linear-gradient(130deg, var(--ready-deep), var(--ready));
}

.lane-step,
.lane-count {
  display: grid;
  place-items: center;
  color: var(--lane);
  font-weight: 950;
  border-radius: 14px;
  background: var(--lane-soft);
}

.lane-step {
  width: clamp(38px, 3.6vw, 52px);
  aspect-ratio: 1;
  font-size: clamp(0.9rem, 1.4vw, 1.25rem);
}

.lane-count {
  min-width: clamp(36px, 3.4vw, 50px);
  height: clamp(36px, 3.4vw, 50px);
  padding-inline: 0.5rem;
  font-size: clamp(0.9rem, 1.3vw, 1.25rem);
}

.lane-ready .lane-step,
.lane-ready .lane-count {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

.status-lane h2,
.status-lane p {
  margin: 0;
}

.status-lane h2 {
  font-size: clamp(1rem, 1.55vw, 1.65rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.status-lane header p {
  margin-top: 0.17rem;
  color: var(--muted);
  font-size: clamp(0.6rem, 0.8vw, 0.84rem);
  font-weight: 700;
}

.lane-ready header p {
  color: rgba(255, 255, 255, 0.72);
}

.ticket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 142px), 1fr));
  align-content: start;
  gap: clamp(0.55rem, 0.9vw, 0.95rem);
  max-height: calc(100% - clamp(72px, 9vh, 104px));
  padding: clamp(0.7rem, 1.1vw, 1.15rem);
  overflow: hidden auto;
  scrollbar-width: thin;
}

.ticket {
  display: grid;
  place-items: center;
  min-height: clamp(76px, 10vh, 118px);
  padding: 0.45rem;
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(1.9rem, 3.6vw, 4.25rem);
  font-weight: 950;
  line-height: 1;
  letter-spacing: -0.055em;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 2px solid #d0d5dd;
  border-radius: clamp(12px, 1.2vw, 18px);
  background: #fff;
  box-shadow: 0 4px 12px rgba(19, 29, 48, 0.08);
}

.lane-waiting .ticket {
  border-color: #edc1ac;
  background: #fff9f5;
}

.lane-preparing .ticket {
  border-color: #e7ca71;
  background: #fffaf0;
}

.ready-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
}

.lane-ready .ticket {
  min-height: clamp(90px, 12vh, 142px);
  color: #fff;
  font-size: clamp(2.35rem, 4.5vw, 5.4rem);
  border-color: var(--ready-deep);
  background: linear-gradient(145deg, #096e53, #078c66);
  box-shadow: 0 8px 20px rgba(5, 91, 66, 0.2);
}

.lane-ready .ticket.is-new {
  animation: ready-arrival 850ms ease-out both;
}

@keyframes ready-arrival {
  0% {
    opacity: 0;
    transform: scale(0.86);
  }
  58% {
    transform: scale(1.045);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.lane-empty {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 42%;
  padding: 2rem 1rem;
  color: #929aa7;
  text-align: center;
}

.lane-empty > span {
  display: grid;
  place-items: center;
  width: clamp(52px, 5vw, 74px);
  aspect-ratio: 1;
  font-size: clamp(1.25rem, 2vw, 2rem);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
}

.lane-empty p {
  margin-top: 0.75rem;
  font-size: clamp(0.7rem, 1vw, 1rem);
  font-weight: 750;
}

.display-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: clamp(42px, 5vh, 58px);
  padding: 0.65rem clamp(1.2rem, 2.4vw, 3rem);
  color: #5d6675;
  font-size: clamp(0.62rem, 0.85vw, 0.85rem);
  font-weight: 700;
  border-top: 1px solid #c5cbd4;
  background: #f7f8fa;
}

.display-footer p {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
}

.display-message {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2rem;
  text-align: center;
  background: rgba(226, 230, 236, 0.94);
  backdrop-filter: blur(7px);
  z-index: 5;
}

.display-message > div {
  max-width: 540px;
  padding: 2.5rem;
  border: 1px solid #cbd1da;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(15, 25, 43, 0.16);
}

.display-message span {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  margin: 0 auto 1rem;
  color: var(--brand);
  font-size: 2rem;
  border-radius: 20px;
  background: #ffe9ef;
}

.display-message h2 {
  margin: 0;
  font-size: 1.5rem;
}

.display-message p {
  margin: 0.55rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.install-dialog,
.history-dialog {
  width: min(620px, calc(100vw - 2rem));
  padding: 1.5rem;
  color: var(--ink);
  border: 0;
  border-radius: 24px;
  background: #f7f8fa;
  box-shadow: 0 24px 80px rgba(11, 20, 37, 0.35);
}

.install-dialog::backdrop,
.history-dialog::backdrop {
  background: rgba(7, 14, 28, 0.68);
  backdrop-filter: blur(4px);
}

.install-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  color: #566176;
  font: inherit;
  font-size: 1.55rem;
  border: 0;
  border-radius: 12px;
  background: #e9ecf1;
  cursor: pointer;
}

.install-close:focus-visible,
.install-close:hover {
  color: var(--navy);
  outline: 3px solid rgba(212, 20, 69, 0.18);
}

.install-heading {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-right: 3rem;
}

.install-club-mark {
  width: clamp(52px, 10vw, 68px);
  height: auto;
  flex: 0 0 auto;
  border-radius: 15px;
}

.install-heading p,
.install-heading h2 {
  margin: 0;
}

.install-heading p {
  color: var(--brand);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.install-heading h2 {
  margin-top: 0.15rem;
  font-size: clamp(1.35rem, 3vw, 2rem);
  letter-spacing: -0.035em;
}

.install-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1.25rem;
}

.install-options section {
  padding: 1rem;
  border: 1px solid #d7dce4;
  border-radius: 16px;
  background: #fff;
}

.install-options strong {
  color: var(--navy);
  font-size: 0.9rem;
}

.install-options p,
.install-note {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.history-dialog {
  width: min(700px, calc(100vw - 2rem));
  max-height: min(78vh, 760px);
  overflow: hidden;
}

.history-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-right: 3rem;
}

.history-heading p,
.history-heading h2,
.history-note,
.history-empty p {
  margin: 0;
}

.history-heading p {
  color: var(--brand);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.history-heading h2 {
  margin-top: 0.15rem;
  font-size: clamp(1.35rem, 3vw, 2rem);
  letter-spacing: -0.035em;
}

.history-heading > strong {
  min-width: max-content;
  padding: 0.55rem 0.75rem;
  color: #5b6576;
  font-size: 0.75rem;
  border: 1px solid #d9dee5;
  border-radius: 999px;
  background: #fff;
}

.history-note {
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.7rem;
  max-height: min(52vh, 500px);
  margin-top: 1.1rem;
  overflow: hidden auto;
  scrollbar-width: thin;
}

.history-ticket {
  display: grid;
  gap: 0.35rem;
  padding: 0.9rem 1rem;
  border: 1px solid #d6dbe3;
  border-radius: 15px;
  background: #fff;
}

.history-ticket strong {
  overflow: hidden;
  color: var(--navy);
  font-size: 1.55rem;
  letter-spacing: -0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-ticket time {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.history-empty {
  display: grid;
  place-items: center;
  gap: 0.65rem;
  min-height: 180px;
  margin-top: 1rem;
  color: #7b8493;
  text-align: center;
  border: 1px dashed #cbd1da;
  border-radius: 18px;
  background: #fff;
}

.history-empty span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: var(--ready);
  font-size: 1.2rem;
  border-radius: 50%;
  background: var(--ready-soft);
}

.install-options p {
  margin: 0.45rem 0 0;
}

.install-note {
  margin: 1rem 0 0;
  text-align: center;
}

@media (max-width: 900px) {
  html,
  body {
    overflow: auto;
  }

  .display-header {
    grid-template-columns: 1fr auto;
  }

  .display-title {
    display: none;
  }

  .status-board {
    grid-template-columns: 1fr;
  }

  .status-lane {
    min-height: 300px;
  }

  .ticket-grid {
    max-height: none;
  }
}

@media (max-width: 520px) {
  .display-brand small,
  .live-status {
    display: none;
  }

  .display-brand > span {
    display: none;
  }

  .club-brand-logo {
    width: 58px;
    height: 36px;
    padding-inline: 12px;
  }

  .display-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .install-options {
    grid-template-columns: 1fr;
  }

  .history-list {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
