:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #dce6f2;
  --text: #111827;
  --muted: #334155;
  --primary: #0f3d66;
  --primary-ink: #ffffff;
  --danger: #8b1e1e;
  --danger-ink: #ffffff;
  --focus: #ffb703;
  --font-size-base: 20px;
  --font-size-h1: 1.7rem;
  --font-size-h2: 1.35rem;
  --radius: 14px;
  --space-1: 10px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --header-img-height: 88px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-size: var(--font-size-base);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f9fcff 0%, #eaf1f8 100%);
}

body {
  min-height: 100vh;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.app-header {
  padding: var(--space-3);
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  align-items: center;
  background: var(--primary);
  color: var(--primary-ink);
  pointer-events: auto;
}

.header-property {
  min-width: 300px;
}

.app-header h1 {
  margin: 0 0 var(--space-1) 0;
  font-size: var(--font-size-h1);
}

.clock-wrap {
  text-align: right;
  min-width: 210px;
  pointer-events: none;
}

.header-images {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  height: var(--header-img-height);
  max-height: var(--header-img-height);
  overflow: hidden;
  pointer-events: auto;
}

.header-property {
  pointer-events: none;
}

.header-image {
  height: var(--header-img-height);
  max-height: var(--header-img-height);
  width: auto;
  max-width: 42%;
  flex: 0 0 auto;
  border-radius: 10px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.15);
}

.header-images img,
.header-images .header-image {
  height: var(--header-img-height) !important;
  max-height: var(--header-img-height) !important;
  width: auto !important;
}

.header-image-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
  border: 2px dashed rgba(255, 255, 255, 0.45);
}

#clock {
  display: block;
  font-size: var(--font-size-h2);
}

.muted {
  margin: 0;
  opacity: 0.9;
}

main {
  padding: var(--space-3);
  padding-bottom: var(--space-2);
  pointer-events: auto;
  overflow: hidden;
}

.poster-wrap {
  max-width: 1500px;
  margin: 0 auto;
  height: 100%;
}

.poster-note,
.poster-error {
  margin: 0 0 var(--space-2) 0;
  border-radius: 10px;
  padding: var(--space-2);
  font-weight: 700;
}

.poster-note {
  background: #eaf2fb;
  border: 2px solid #c0d0e4;
}

.poster-error {
  background: #ffecec;
  border: 2px solid #d7b5b5;
}

.poster-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
}

.poster-card {
  background: var(--surface);
  border: 2px solid #c7d3df;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.88rem;
  overflow: hidden;
  cursor: default;
  pointer-events: none;
}

.poster-card h2 {
  margin: 0 0 6px 0;
  font-size: 1.05rem;
}

.poster-card p {
  margin: 0 0 5px 0;
  line-height: 1.25;
}

.poster-card ul {
  margin: 0 0 4px 0;
  padding-left: 22px;
}

.poster-card li {
  margin-bottom: 3px;
  line-height: 1.2;
}

.wifi-qr-wrap {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

.wifi-qr canvas,
.wifi-qr img {
  width: 120px;
  height: 120px;
  border-radius: 8px;
  border: 2px solid #c7d3df;
  background: #fff;
}

.app-footer {
  position: sticky;
  bottom: 0;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-1);
  background: rgba(12, 25, 38, 0.96);
  padding: var(--space-1);
  backdrop-filter: blur(2px);
}

.footer-btn {
  border: none;
  border-radius: var(--radius);
  padding: var(--space-2);
  background: #1f4f7a;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
}

.footer-square {
  width: 100%;
  height: clamp(320px, 28vh, 540px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.footer-stationary {
  cursor: pointer;
  pointer-events: auto;
}

.footer-carousel {
  background: #25608f;
  cursor: pointer;
  pointer-events: auto;
  overflow: hidden;
  position: relative;
}

.footer-carousel:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
}

.ad-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}

.ad-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  background: #000;
}

.ad-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  background: #0f3d66;
  color: #ffffff;
  font-size: 1.2rem;
}

.popout-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(8, 15, 26, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
}

.popout-content {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.ad-popout-open .popout-content {
  background: #000;
}

.popout-content .poster-card {
  width: 100%;
  height: 100%;
  margin: 0;
  border: none;
  border-radius: 0;
  font-size: 1rem;
  cursor: default;
}

.popout-content .ad-image,
.popout-content .ad-video,
.popout-content .ad-fallback {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

.ad-popout-media {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

@media (max-width: 1200px) {
  .poster-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
