:root {
  --board-bg: #080807;
  --frame: #181817;
  --frame-edge: #2b2a27;
  --cell-gap: clamp(2px, 0.45vw, 7px);
  --flap-bg-top: #30302e;
  --flap-bg-bottom: #222220;
  --flap-text: #f2eadb;
  --flap-shadow: rgba(0, 0, 0, 0.72);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--board-bg);
}

body {
  color: var(--flap-text);
  font-family: "Arial Narrow", "Roboto Condensed", "DIN Condensed", "Segoe UI", "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", Arial, sans-serif;
}

.display-page {
  min-height: 100%;
}

.display-shell {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 2.2vw, 28px);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.04), transparent 38%),
    linear-gradient(145deg, #0c0c0b 0%, #050505 100%);
}

.embed-mode .display-shell {
  padding: 0;
}

.vestaboard {
  width: min(100%, calc(100vh * 3.18));
  aspect-ratio: 22 / 7;
  display: grid;
  grid-template-rows: repeat(var(--rows, 6), 1fr);
  gap: var(--cell-gap);
  padding: clamp(8px, 1.35vw, 20px);
  border: clamp(5px, 1vw, 14px) solid var(--frame);
  border-top-color: var(--frame-edge);
  border-left-color: var(--frame-edge);
  background:
    linear-gradient(180deg, #171715, #080808),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 16px);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    inset 0 16px 40px rgba(255, 255, 255, 0.035),
    0 18px 60px rgba(0, 0, 0, 0.55);
  --char-size: clamp(12px, min(2.8vw, 7.4vh), 56px);
}

.vestaboard-row {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(var(--columns, 22), 1fr);
  gap: var(--cell-gap);
}

.flap {
  position: relative;
  min-width: 0;
  height: 100%;
  perspective: 620px;
  background: #080808;
  border-radius: 4px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 2px 5px rgba(0, 0, 0, 0.48);
  overflow: hidden;
}

.flap::before,
.flap::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  height: 1px;
  top: 50%;
  z-index: 5;
  background: rgba(0, 0, 0, 0.62);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05);
}

.flap::after {
  display: none;
}

.flap-half,
.flap-flipper {
  position: absolute;
  left: 0;
  width: 100%;
  height: 50%;
  overflow: hidden;
  background: linear-gradient(180deg, var(--flap-bg-top), var(--flap-bg-bottom));
  color: var(--flap-text);
  text-align: center;
  text-shadow: 0 1px 0 #000, 0 0 10px rgba(255, 245, 220, 0.08);
  backface-visibility: hidden;
}

.flap-half .flap-text {
  display: none;
}

.flap-current {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--flap-text);
  font-size: var(--char-size);
  font-weight: 650;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 1px 0 #000, 0 0 10px rgba(255, 245, 220, 0.08);
  transform: scaleX(0.86);
  pointer-events: none;
}

.flap.is-flipping .flap-current {
  opacity: 0;
}

.flap-top {
  top: 0;
  border-radius: 4px 4px 1px 1px;
}

.flap-bottom {
  bottom: 0;
  border-radius: 1px 1px 4px 4px;
  background: linear-gradient(180deg, #252523, #151514);
}

.flap-text {
  position: absolute;
  left: 0;
  width: 100%;
  height: 200%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--char-size);
  font-weight: 650;
  line-height: 1;
  letter-spacing: 0;
  transform: scaleX(0.86);
}

.flap-bottom .flap-text {
  bottom: 0;
}

.flap-top .flap-text,
.flap-flipper.is-top .flap-text {
  top: 0;
}

.flap-flipper {
  z-index: 4;
  opacity: 0;
  transform-style: preserve-3d;
  will-change: transform;
  box-shadow: 0 6px 14px var(--flap-shadow);
}

.flap-flipper.is-top {
  top: 0;
  transform-origin: bottom center;
  border-radius: 4px 4px 1px 1px;
}

.flap-flipper.is-bottom {
  bottom: 0;
  transform-origin: top center;
  border-radius: 1px 1px 4px 4px;
  background: linear-gradient(180deg, #262624, #171716);
}

.flap-flipper.is-bottom .flap-text {
  bottom: 0;
}

.flap.is-flipping .flap-flipper.is-top {
  animation: flipTop 72ms ease-in forwards;
  opacity: 1;
}

.flap.is-flipping .flap-flipper.is-bottom {
  animation: flipBottom 72ms ease-out forwards;
  opacity: 1;
}

@keyframes flipTop {
  from { transform: rotateX(0deg); }
  to { transform: rotateX(-92deg); }
}

@keyframes flipBottom {
  from { transform: rotateX(92deg); }
  to { transform: rotateX(0deg); }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 720px) {
  .display-shell {
    padding: 6px;
  }

  .vestaboard {
    width: 100vw;
    border-width: 4px;
    padding: 5px;
  }

  .flap {
    border-radius: 2px;
  }
}
