:root {
  color-scheme: light;
  --bg: #f5f4ef;
  --panel: #ffffff;
  --ink: #151515;
  --muted: #5b5b5b;
  --line: #d7d5cc;
  --accent: #1b6f6a;
  --accent-ink: #ffffff;
  --stage-bg: #101010;
  --stage-ink: #ffffff;
  --radius: 8px;
  --text-size: 22vw;
  --scroll-duration: 16s;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

.app {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: minmax(42dvh, 1fr) auto;
  gap: 16px;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.stage {
  min-height: 42dvh;
  overflow: hidden;
  display: flex;
  align-items: center;
  background: var(--stage-bg);
  color: var(--stage-ink);
  border-radius: var(--radius);
  touch-action: manipulation;
  user-select: none;
}

.stage__track {
  width: 100%;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.stage__text {
  width: 100%;
  padding: 0 0.08em;
  text-align: center;
  font-size: var(--text-size);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.app[data-mode="scroll"] .stage__text {
  width: max-content;
  min-width: 100%;
  animation: scrollText var(--scroll-duration) linear infinite;
  will-change: transform;
}

.app[data-mode="static"] .stage__track {
  justify-content: center;
}

.app[data-mode="static"] .stage__text {
  white-space: normal;
}

.controls {
  display: grid;
  gap: 14px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / 8%);
}

.field {
  display: grid;
  gap: 8px;
}

.field label,
.field > span,
.segmented legend {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fffdfa;
}

textarea:focus,
input:focus-visible,
button:focus-visible {
  outline: 3px solid rgb(27 111 106 / 28%);
  outline-offset: 2px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented legend {
  grid-column: 1 / -1;
  padding: 0 0 8px;
}

.segmented label {
  min-height: 44px;
  display: grid;
  place-items: center;
  background: #fffdfa;
  cursor: pointer;
}

.segmented label + label {
  border-left: 1px solid var(--line);
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented input:checked + span {
  background: var(--accent);
  color: var(--accent-ink);
}

.segmented span {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.field--compact input {
  width: 100%;
  accent-color: var(--accent);
}

.switch {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 650;
}

.switch input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  cursor: pointer;
}

button + button {
  background: #252525;
}

.app[data-contrast="light"] {
  --stage-bg: #ffffff;
  --stage-ink: #101010;
}

.app[data-display-mode="show"] {
  grid-template-rows: 1fr;
  gap: 0;
  padding: 0;
  background: var(--stage-bg);
}

.app[data-display-mode="show"] .stage {
  min-height: 100dvh;
  border-radius: 0;
}

.app[data-display-mode="show"] .controls {
  display: none;
}

.stage:fullscreen {
  min-height: 100vh;
  border-radius: 0;
}

.stage:fullscreen .stage__track {
  min-height: 100vh;
}

@keyframes scrollText {
  from {
    transform: translateX(100vw);
  }

  to {
    transform: translateX(-100%);
  }
}

@media (orientation: landscape) {
  .app {
    grid-template-rows: minmax(48dvh, 1fr) auto;
  }

  .stage {
    min-height: 48dvh;
  }
}

@media (min-width: 760px) {
  .app {
    max-width: 1040px;
    margin: 0 auto;
    grid-template-rows: minmax(54dvh, 1fr) auto;
  }

  .controls {
    grid-template-columns: 1.3fr 1fr auto;
    align-items: end;
  }

  .actions {
    min-width: 220px;
  }
}

@media (max-width: 520px) {
  .control-grid,
  .actions {
    grid-template-columns: 1fr;
  }
}
