/* Portrait Gate geometry mirrors the firmware's 240 × 320 display. */
:is(.gate-board, .lcd-gate-board):not(.landscape) {
  --gate-number-height: 88px;
  --gate-header-height: 156px;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #a60005;
  color: #fff;
  font-family: Arial, STHeiti, "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-weight: 400;
  letter-spacing: 0;
  text-align: left;
  box-sizing: border-box;
}

:is(.gate-board, .lcd-gate-board):not(.landscape) :is(.gate-number, .lcd-gate-number) {
  position: absolute;
  inset: 0 0 auto;
  display: grid;
  place-items: center;
  height: var(--gate-number-height);
  background: #00143a;
  color: #ffe200;
  font-size: 84px;
  font-weight: 700;
  line-height: 1;
}

:is(.gate-board, .lcd-gate-board):not(.landscape) :is(.gate-flight-strip, .lcd-gate-flight-strip) {
  position: absolute;
  inset: var(--gate-number-height) 0 auto;
  height: calc(var(--gate-header-height) - var(--gate-number-height));
  padding: 0;
  background: #daeefa;
  color: #000;
}

:is(.gate-board, .lcd-gate-board):not(.landscape) :is(.gate-flight-main, .lcd-gate-flight-main) {
  position: absolute;
  top: 4px;
  left: 3px;
  display: grid;
  grid-template-columns: 141px 89px;
  gap: 4px;
  width: 234px;
  height: 32px;
  font-size: 26px;
  line-height: 32px;
}

:is(.gate-board, .lcd-gate-board):not(.landscape) :is(.gate-flight-main, .lcd-gate-flight-main) > span {
  position: relative;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

:is(.gate-board, .lcd-gate-board):not(.landscape) :is(.gate-flight-main, .lcd-gate-flight-main) > span:last-child {
  text-align: right;
}

:is(.gate-board, .lcd-gate-board):not(.landscape) :is(.gate-shared, .lcd-gate-shared) {
  position: absolute;
  top: 36px;
  left: 3px;
  width: 234px;
  height: 28px;
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 26px;
  line-height: 28px;
}

:is(.gate-board, .lcd-gate-board):not(.landscape) :is(.gate-route, .lcd-gate-route, .gate-destination, .lcd-gate-destination, .gate-status, .lcd-gate-status) {
  position: absolute;
  left: 3px;
  width: 234px;
  height: 28px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  color: #fff;
  white-space: nowrap;
  font-size: 22px;
  line-height: 28px;
  display: block;
  text-align: left;
}

:is(.gate-board, .lcd-gate-board):not(.landscape) :is(.gate-route, .lcd-gate-route) {
  top: calc(var(--gate-header-height) + 6px);
}

:is(.gate-board, .lcd-gate-board):not(.landscape) :is(.gate-destination, .lcd-gate-destination) {
  top: 196px;
  height: 32px;
  color: #ffe200;
  font-size: 26px;
  line-height: 32px;
}

:is(.gate-board, .lcd-gate-board):not(.landscape) :is(.gate-status, .lcd-gate-status) {
  top: 268px;
  text-align: right;
}

.gate-wipe-overlay { position: absolute; z-index: 1; overflow: hidden; pointer-events: none; }
:is(.gate-board, .lcd-gate-board):not(.landscape) :is(.gate-status, .lcd-gate-status).final-call,
:is(.gate-board, .lcd-gate-board).landscape :is(.gate-status, .lcd-gate-status).final-call {
  color: #ff0000;
}
.gate-wipe-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--gate-wipe-background, #a60005);
}
.gate-wipe-face > :is(.gate-route, .lcd-gate-route, .gate-destination, .lcd-gate-destination, .gate-status, .lcd-gate-status),
.gate-wipe-face :is(.preview-marquee-inner, .lcd-marquee-inner) { animation: none !important; }
.gate-wipe-paused :is(.preview-marquee-inner, .lcd-marquee-inner) {
  animation-play-state: paused !important;
}
.gate-wipe-old {
  animation: gate-horizontal-wipe-out var(--gate-wipe-duration,2500ms) linear both;
}
@keyframes gate-horizontal-wipe-out {
  from { clip-path: inset(0 0 0 var(--gate-wipe-start)); }
  to { clip-path: inset(0 0 0 var(--gate-wipe-end)); }
}

/* Native display pixels: constant 40px/s with an 18px gap between copies. */
.gate-destination-track {
  display: inline-flex !important;
  width: max-content;
  gap: 18px;
  padding: 0 !important;
  animation: gate-destination-scroll var(--gate-scroll-duration) linear infinite !important;
}
.gate-destination-copy { display: inline-block; flex: 0 0 auto; }
@keyframes gate-destination-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(calc(-1 * var(--gate-scroll-distance))); }
}
@media print, (prefers-reduced-motion: reduce) {
  .gate-destination-track { animation: none !important; }
}

/* Taiwan Gate: native 240x320 / 320x240 coordinates, shared with firmware. */
.taiwan-gate-board {
  --tw-logo-h:62px; --tw-flight-h:28px;
  position:relative;width:100%;height:100%;overflow:hidden;box-sizing:border-box;
  background:#2d384e;color:#fff;font-family:Arial,STHeiti,"PingFang SC","Microsoft JhengHei",sans-serif;
  font-weight:400;text-align:left;
}
.taiwan-gate-board > * {position:absolute;box-sizing:border-box;overflow:hidden;}
.taiwan-gate-topbar {inset:0 0 auto;height:30px;background:#080e1e;}
.taiwan-gate-number {position:absolute;left:8px;top:0;width:150px;height:30px;font-size:26px;line-height:30px;}
.taiwan-gate-topbar .tpe-topbar {position:absolute;inset:0 0 0 auto;width:72px;height:30px;padding:0;background:transparent;}
.taiwan-gate-topbar .tpe-topbar-clock {position:absolute;right:6px;top:4px;margin:0;grid-template-columns:26px 9px 26px;height:23px;}
.taiwan-gate-logo-window {left:6px;top:40px;width:96px;height:62px;}
.taiwan-gate-logo-slot {display:flex;align-items:center;justify-content:center;width:100%;height:var(--tw-logo-h);}
.taiwan-gate-logo {display:block;width:100%;aspect-ratio:2;background-image:url('/static/icons/airline_logos.png');background-size:1000% 1000%;background-repeat:no-repeat;}.taiwan-gate-time{left:110px;top:38px;width:124px;height:36px;line-height:36px;font-size:30px;font-weight:700;padding-left:2px;white-space:nowrap;}.taiwan-gate-flight-window{left:110px;top:78px;width:124px;height:28px;}.taiwan-gate-flight-slot{display:block;height:var(--tw-flight-h);line-height:var(--tw-flight-h);padding-left:2px;font-size:26px;white-space:nowrap;}.taiwan-gate-destination{left:8px;top:118px;width:224px;height:100px;display:flex;align-items:center;justify-content:center;font-size:39px;line-height:46px;white-space:nowrap;}.taiwan-gate-destination .preview-marquee-inner{padding:0;}.taiwan-gate-status{left:0;top:226px;width:240px;height:94px;display:flex;align-items:center;justify-content:center;padding:1px 2px;background:#008f91;color:white;font-size:39px;line-height:46px;white-space:nowrap;}.taiwan-gate-status-copy{display:block;max-width:100%;white-space:pre;text-align:center;}.taiwan-gate-status.cancelled{background:#be1224;color:#fff;}.taiwan-gate-status.estimated{background:#f6d22c;color:#080e1e;}.taiwan-gate-status.empty{background:transparent;}.taiwan-gate-board.landscape{--tw-logo-h:60px;--tw-flight-h:27px;}.taiwan-gate-board.landscape .taiwan-gate-number{width:210px;}.taiwan-gate-board.landscape .taiwan-gate-logo-window{top:38px;width:88px;height:60px;}.taiwan-gate-board.landscape .taiwan-gate-time{left:102px;top:36px;width:104px;height:34px;line-height:34px;font-size:30px;}.taiwan-gate-board.landscape .taiwan-gate-flight-window{left:102px;top:74px;width:104px;height:27px;}.taiwan-gate-board.landscape .taiwan-gate-flight-slot{font-size:26px;}.taiwan-gate-board.landscape .taiwan-gate-destination{left:6px;top:112px;width:308px;height:108px;font-size:39px;}.taiwan-gate-board.landscape .taiwan-gate-status{left:212px;top:38px;width:108px;height:60px;font-size:39px;}