@font-face {
  font-family: "Josefin Sans";
  src: url("fonts/JosefinSans-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Mulish";
  src: url("fonts/Mulish-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Mulish";
  src: url("fonts/Mulish-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("fonts/Montserrat-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --cream: #f9f6f0;
  --brown-700: #6a5548;
  --brown-600: #8c715e;
  --taupe-400: #b8a290;
  --taupe-300: #d4c6ba;
  --taupe-200: #e5dcd6;
  --gold: #b38f52;
  --ink: #2c2c2c;
  --board: #171b1c;
  --board-raised: #202526;
  --board-line: #343a3b;
  --board-muted: #919998;
  --white: #ffffff;
  --display: "Josefin Sans", "Trebuchet MS", sans-serif;
  --body: "Mulish", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --tag: "Montserrat", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--cream);
  color: var(--cream);
  cursor: none;
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.display-shell {
  position: relative;
  display: grid;
  width: 100vw;
  height: 100vh;
  min-height: 100svh;
  place-items: center;
  padding: clamp(18px, 2.2vw, 88px);
  background: var(--cream);
}

.board {
  position: relative;
  display: grid;
  grid-template-rows: auto 2px 1fr auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: clamp(22px, 2.25vw, 88px) clamp(26px, 3.25vw, 128px) clamp(24px, 2.2vw, 84px);
  border: clamp(4px, 0.34vw, 14px) solid var(--brown-700);
  background: var(--board);
  box-shadow:
    0 0 0 clamp(6px, 0.55vw, 22px) var(--ink),
    0 clamp(18px, 2vw, 72px) clamp(42px, 5vw, 190px) rgba(106, 85, 72, 0.34);
  isolation: isolate;
}

.board::before,
.board::after {
  position: absolute;
  z-index: 3;
  top: 50%;
  width: clamp(8px, 0.55vw, 22px);
  height: clamp(40px, 5vw, 190px);
  border: 2px solid rgba(179, 143, 82, 0.55);
  background: var(--ink);
  content: "";
  transform: translateY(-50%);
}

.board::before {
  left: 0;
  border-left: 0;
}

.board::after {
  right: 0;
  border-right: 0;
}

.board-watermark {
  position: absolute;
  z-index: 0;
  right: clamp(36px, 4vw, 154px);
  bottom: clamp(32px, 3.8vh, 84px);
  width: min(20vw, 43vh);
  max-height: 72%;
  opacity: 0.042;
  object-fit: contain;
  pointer-events: none;
}

.board-header,
.board-footer {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.board-header {
  gap: 4vw;
  padding-bottom: clamp(14px, 1.25vw, 48px);
}

.brand-lockup {
  display: block;
  width: clamp(180px, 16vw, 640px);
  height: auto;
  flex: 0 0 auto;
}

.clock-block {
  display: flex;
  align-items: baseline;
  gap: clamp(16px, 2vw, 78px);
  color: var(--taupe-300);
  font-family: var(--tag);
  font-size: clamp(10px, 0.72vw, 28px);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
}

.clock-block time {
  color: var(--gold);
  font-size: clamp(14px, 1.15vw, 46px);
  letter-spacing: 0.12em;
}

.header-rule {
  width: 100%;
  height: 2px;
  background: var(--gold);
  opacity: 0.82;
}

.message-stage {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 0;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  padding: clamp(18px, 1.8vh, 38px) 0;
  text-align: center;
}

.eyebrow,
.board-footer,
.editor-kicker {
  font-family: var(--tag);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 clamp(14px, 1.4vh, 38px);
  color: var(--gold);
  font-size: clamp(11px, 0.85vw, 34px);
}

.eyebrow::before,
.eyebrow::after {
  display: inline-block;
  width: clamp(24px, 2.4vw, 92px);
  height: 1px;
  margin: 0 clamp(10px, 1vw, 40px);
  background: currentColor;
  content: "";
  vertical-align: middle;
}

.flap-display {
  display: flex;
  width: 100%;
  min-height: 0;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  gap: clamp(8px, 0.8vh, 22px);
}

.flap-row {
  --board-columns: 28;
  --flap-gap: clamp(3px, 0.22vw, 9px);
  display: grid;
  width: min(88vw, 3400px);
  max-width: 100%;
  grid-template-columns: repeat(var(--board-columns), minmax(0, 1fr));
  gap: var(--flap-gap);
}

.flap-char {
  position: relative;
  min-width: 0;
  aspect-ratio: 0.68;
  overflow: hidden;
  border: 1px solid var(--board-line);
  background: var(--board-raised);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.035),
    0 1px 1px rgba(0, 0, 0, 0.48);
  perspective: 1000px;
}

.flap-char::before,
.flap-char::after {
  position: absolute;
  z-index: 8;
  top: 50%;
  width: clamp(2px, 0.18vw, 7px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #0d1011;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.035);
  content: "";
  transform: translateY(-50%);
}

.flap-char::before {
  left: clamp(1px, 0.1vw, 4px);
}

.flap-char::after {
  right: clamp(1px, 0.1vw, 4px);
}

.flap-half,
.flap-face {
  position: absolute;
  left: 0;
  width: 100%;
  height: 50%;
  overflow: hidden;
  background: var(--board-raised);
  color: var(--cream);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flap-upper {
  top: 0;
  border-bottom: 1px solid #0b0d0e;
}

.flap-lower {
  bottom: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.035);
}

.flap-glyph {
  position: absolute;
  left: 0;
  display: grid;
  width: 100%;
  height: 200%;
  place-items: center;
  color: var(--cream);
  font-family: var(--display);
  font-size: max(24px, min(3vw, calc(76vw / var(--board-columns)), 112px));
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  white-space: pre;
}

.flap-upper .flap-glyph,
.flap-front .flap-glyph {
  top: 0;
}

.flap-lower .flap-glyph,
.flap-back .flap-glyph {
  bottom: 0;
}

.flap-card {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  width: 100%;
  height: 50%;
  transform-origin: center bottom;
  transform-style: preserve-3d;
  will-change: transform;
}

.flap-face {
  inset: 0;
  height: 100%;
}

.flap-front {
  border-bottom: 1px solid #0b0d0e;
}

.flap-back {
  border-top: 1px solid rgba(255, 255, 255, 0.035);
  transform: rotateX(180deg);
}

.flap-char.is-flipping .flap-card {
  animation: flap-turn 74ms linear both;
}

.subheading {
  max-width: min(72vw, 2600px);
  margin: clamp(14px, 1.6vh, 42px) 0 0;
  color: var(--taupe-300);
  font-size: clamp(15px, 1.35vw, 54px);
  font-weight: 400;
  line-height: 1.3;
}

.board-footer {
  gap: 3vw;
  padding-top: clamp(12px, 1.2vw, 46px);
  border-top: 1px solid rgba(212, 198, 186, 0.2);
  color: var(--board-muted);
  font-size: clamp(9px, 0.62vw, 24px);
}

.board-footer p {
  margin: 0;
  text-align: right;
}

.location-block {
  display: flex;
  align-items: center;
  gap: clamp(9px, 0.7vw, 28px);
}

.location-block img {
  width: clamp(11px, 0.8vw, 32px);
  height: clamp(14px, 1.05vw, 42px);
}

.edit-trigger {
  position: fixed;
  z-index: 10;
  top: clamp(20px, 2.5vw, 72px);
  right: clamp(20px, 2.5vw, 72px);
  padding: 10px 14px;
  border: 1px solid rgba(179, 143, 82, 0.4);
  border-radius: 0;
  background: rgba(23, 27, 28, 0.82);
  color: var(--taupe-300);
  font-family: var(--tag);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  opacity: 0.22;
  text-transform: uppercase;
  transition: opacity 200ms ease-out, background 200ms ease-out;
}

.edit-trigger:hover,
.edit-trigger:focus-visible,
body.controls-visible .edit-trigger {
  background: var(--board);
  opacity: 1;
}

body.is-idle {
  cursor: none;
}

body.is-idle .edit-trigger {
  opacity: 0;
  pointer-events: none;
}

.sound-gate {
  position: fixed;
  z-index: 30;
  display: grid;
  inset: 0;
  place-items: center;
  padding: 24px;
  background: rgba(23, 27, 28, 0.88);
}

.sound-gate[hidden] {
  display: none;
}

.sound-gate-card {
  width: min(880px, 100%);
  padding: clamp(34px, 4vw, 92px);
  border-top: 2px solid var(--gold);
  background: var(--cream);
  box-shadow: 0 30px 120px rgba(0, 0, 0, 0.42);
  color: var(--brown-700);
  text-align: center;
}

.sound-gate-card > img {
  width: min(360px, 64%);
  height: auto;
  margin-bottom: 30px;
}

.sound-gate-kicker {
  margin: 0 0 12px;
  color: var(--gold);
  font-family: var(--tag);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.sound-gate-card h2 {
  margin: 0;
  color: var(--brown-600);
  font-family: var(--display);
  font-size: clamp(30px, 4vw, 52px);
  letter-spacing: 0.1em;
  line-height: 1.05;
  text-transform: uppercase;
}

.sound-gate-copy {
  max-width: 620px;
  margin: 22px auto 30px;
  color: var(--brown-700);
  font-size: clamp(16px, 0.82vw, 28px);
  line-height: 1.55;
}

.sound-gate-status {
  min-height: 1.5em;
  margin: -10px auto 24px;
  color: var(--brown-600);
  font-size: clamp(13px, 0.68vw, 22px);
  line-height: 1.45;
}

.sound-gate-actions {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 13px;
}

.sound-gate-actions .primary-button {
  min-height: clamp(54px, 3.5vw, 82px);
  padding: 0 clamp(24px, 2vw, 42px);
  font-size: clamp(11px, 0.68vw, 22px);
}

.sound-gate-actions .secondary-button {
  min-height: clamp(50px, 3.1vw, 72px);
  padding: 0 clamp(22px, 1.8vw, 38px);
  font-size: clamp(10px, 0.62vw, 20px);
}

.sound-gate-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.sound-gate-silent {
  color: var(--brown-600);
  font-size: clamp(10px, 0.58vw, 18px);
}

.editor-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  background: rgba(23, 27, 28, 0.68);
}

.editor-panel {
  position: fixed;
  z-index: 21;
  top: 0;
  right: 0;
  width: min(600px, 100vw);
  height: 100%;
  overflow: auto;
  padding: clamp(24px, 3.4vw, 52px);
  background: var(--cream);
  box-shadow: -24px 0 90px rgba(23, 27, 28, 0.26);
  color: var(--brown-700);
}

.editor-panel[hidden],
.editor-backdrop[hidden] {
  display: none;
}

.editor-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.editor-kicker {
  margin: 0 0 9px;
  color: var(--gold);
  font-size: 10px;
}

.editor-heading h2 {
  margin: 0;
  color: var(--brown-600);
  font-family: var(--display);
  font-size: clamp(28px, 3vw, 42px);
  letter-spacing: 0.1em;
  line-height: 1.08;
  text-transform: uppercase;
}

.editor-note {
  margin: 28px 0 30px;
  padding: 17px 0 17px 18px;
  border-left: 2px solid var(--gold);
  color: var(--brown-600);
  line-height: 1.5;
}

.close-button,
.text-button {
  border: 0;
  background: transparent;
  color: var(--brown-600);
  font-family: var(--tag);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.close-button {
  padding: 8px 0 8px 12px;
}

.editor-panel form {
  display: grid;
  gap: 21px;
}

.editor-panel label {
  display: grid;
  gap: 8px;
  color: var(--brown-700);
  font-size: 13px;
  font-weight: 600;
}

.editor-panel input,
.editor-panel textarea {
  width: 100%;
  border: 1px solid var(--taupe-300);
  border-radius: 0;
  outline: 0;
  background: var(--white);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
  padding: 13px 14px;
  resize: vertical;
}

.editor-panel input:focus,
.editor-panel textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(179, 143, 82, 0.15);
}

.field-help {
  color: var(--brown-600);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
}

.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-status {
  min-height: 1.4em;
  margin: -3px 0;
  color: var(--brown-600);
  font-size: 13px;
}

.editor-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 11px;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  border-radius: 0;
  padding: 0 17px;
  font-family: var(--tag);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.primary-button {
  border: 1px solid var(--brown-700);
  background: var(--brown-700);
  color: var(--cream);
}

.secondary-button {
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--brown-700);
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--ink);
}

.secondary-button:hover,
.secondary-button:focus-visible {
  background: var(--taupe-200);
}

.text-button {
  min-height: 42px;
  padding: 0 4px;
}

.shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  margin-top: 42px;
  padding-top: 20px;
  border-top: 1px solid var(--taupe-300);
  color: var(--brown-600);
  font-size: 12px;
}

kbd {
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  margin-right: 6px;
  place-items: center;
  border: 1px solid var(--taupe-300);
  background: var(--white);
  color: var(--brown-700);
  font-family: var(--tag);
  font-size: 10px;
}

.screen-reader-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

noscript {
  position: fixed;
  z-index: 100;
  right: 16px;
  bottom: 16px;
  left: 16px;
  padding: 16px;
  background: var(--brown-700);
  color: var(--cream);
  text-align: center;
}

.display-control {
  position: fixed;
  z-index: 12;
  right: 22px;
  bottom: 20px;
  padding: 10px 13px;
  border: 1px solid rgba(179, 143, 82, 0.45);
  background: rgba(23, 27, 28, 0.88);
  color: var(--taupe-300);
  font-family: var(--tag);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.13em;
  opacity: 0.18;
  text-transform: uppercase;
  transition: opacity 180ms ease-out;
}

.display-control:hover,
.display-control:focus-visible {
  opacity: 1;
}

.display-control-panel {
  position: fixed;
  z-index: 13;
  right: 22px;
  bottom: 68px;
  display: flex;
  width: min(360px, calc(100vw - 44px));
  align-items: stretch;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border-top: 2px solid var(--gold);
  background: var(--cream);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.34);
  color: var(--brown-700);
}

.display-control-panel[hidden] {
  display: none;
}

.display-control-panel p {
  margin: 0 0 6px;
  font-size: 13px;
  line-height: 1.45;
}

body.is-idle .display-control {
  opacity: 0;
  pointer-events: none;
}

@keyframes flap-turn {
  0% {
    transform: rotateX(0deg);
  }
  100% {
    transform: rotateX(-180deg);
  }
}

@media (max-width: 760px), (max-aspect-ratio: 4 / 5) {
  .display-shell {
    padding: 10px;
  }

  .board {
    padding: 22px 20px;
    border-width: 4px;
  }

  .board-header {
    align-items: flex-start;
  }

  .brand-lockup {
    width: min(42vw, 220px);
  }

  .clock-block {
    align-items: flex-end;
    flex-direction: column;
    gap: 4px;
  }

  .flap-glyph {
    font-size: clamp(14px, 3.4vw, 32px);
  }

  .board-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .board-footer p {
    text-align: left;
  }

  .field-pair {
    grid-template-columns: 1fr;
  }
}

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