* {
  box-sizing: border-box;
}

:root {
  --bg: #000;
  --fg: #fff;
  --muted: rgba(255, 255, 255, 0.54);
  --muted-strong: rgba(255, 255, 255, 0.8);
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.18);
  --button-bg: rgba(255, 255, 255, 0.04);
  --button-bg-hover: rgba(255, 255, 255, 0.09);
  --button-bg-active: rgba(255, 255, 255, 0.15);
  --button-on-bg: rgba(255, 255, 255, 0.94);
  --button-on-fg: #000;
  --panel-bg: rgba(6, 6, 6, 0.98);
  --menu-shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
  --slider-track:
    linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.08) 0%,
      rgba(255, 255, 255, 0.14) 22%,
      rgba(255, 255, 255, 0.30) 50%,
      rgba(255, 255, 255, 0.14) 78%,
      rgba(255, 255, 255, 0.08) 100%
    );
}

html,
body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.045), transparent 34%),
    #000;
  color: #fff;
  font-family: "IBM Plex Mono", monospace;
}

body {
  overflow: hidden;
}

button,
textarea,
input {
  font: inherit;
}

button,
#fontMenuBtn,
#toolsMenuBtn,
#downloadMenuBtn {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  outline: none;
  background: var(--button-bg);
  color: #fff;
  min-height: 32px;
  padding: 7px 11px;
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.04em;
  border-radius: 16px;
  cursor: pointer;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease,
    opacity 0.18s ease;
}

button:hover,
#fontMenuBtn:hover,
#toolsMenuBtn:hover,
#downloadMenuBtn:hover {
  background: var(--button-bg-hover);
}

button:focus-visible,
#fontMenuBtn:focus-visible,
#toolsMenuBtn:focus-visible,
#downloadMenuBtn:focus-visible,
#resSlider:focus-visible,
#scaleSlider:focus-visible,
#startBtn:focus-visible,
#introLangBtn:focus-visible,
#projectPopupLangBtn:focus-visible,
.dropdown-menu-item:focus-visible,
.export-name-input:focus-visible,
#projectPopupClose:focus-visible,
#projectPopupContinue:focus-visible {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.16),
    0 0 0 5px rgba(255, 255, 255, 0.05);
}

button:active,
#fontMenuBtn:active,
#toolsMenuBtn:active,
#downloadMenuBtn:active {
  background: var(--button-bg-active);
  transform: translateY(1px);
}

button.is-active,
#fontMenuBtn.is-active,
#toolsMenuBtn.is-active,
#downloadMenuBtn.is-active,
.dropdown-menu-item.is-active,
.toggle-item.is-active {
  background: #fff;
  color: #000;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.2);
}

.intro-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 10%, rgba(255,255,255,0.04), transparent 28%),
    #000;
  opacity: 1;
  transition: opacity 0.72s ease, visibility 0.72s ease;
}

.intro-screen.is-exiting {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro-inner {
  width: min(92vw, 980px);
  padding: 24px 20px;
  display: grid;
  justify-items: center;
  gap: 16px;
}

.intro-frame {
  width: min(92vw, 900px);
  padding: 8px 8px 2px;
  border-radius: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.intro-canvas {
  width: 100%;
  height: min(34vw, 210px);
  display: block;
  image-rendering: pixelated;
}

.intro-text-block {
  display: grid;
  gap: 4px;
  justify-items: center;
  max-width: 640px;
}

.intro-credit {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-align: center;
}

.intro-lang-btn {
  position: absolute;
  top: 18px;
  right: 18px;
}

.start-btn {
  min-width: 132px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.94);
  color: #000;
  border-radius: 16px;
}

.start-btn:hover {
  background: #fff;
}

.project-popup {
  position: fixed;
  inset: 0;
  z-index: 9800;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.84);
  backdrop-filter: blur(10px);
  transition: opacity 0.34s ease;
}

.project-popup[hidden] {
  display: none !important;
}

.project-popup-card {
  width: min(720px, calc(100vw - 32px));
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015)),
    rgba(0, 0, 0, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 22px;
  box-shadow:
    0 24px 80px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(255,255,255,0.04);
  padding: 24px;
  position: relative;
  display: grid;
  gap: 20px;
  transform: translateY(0);
  transition: transform 0.34s ease, opacity 0.34s ease;
}

.project-popup.is-closing .project-popup-card {
  transform: translateY(10px);
  opacity: 0;
}

.project-popup-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.project-popup-lang-btn,
.project-popup-close {
  min-width: 36px;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 16px;
}

.project-popup-copy {
  max-width: 590px;
}

.project-popup-text {
  margin: 0;
  color: rgba(255,255,255,0.9);
  font-size: 13px;
  line-height: 1.85;
  letter-spacing: 0.01em;
}

.project-popup-actions {
  display: flex;
  justify-content: flex-end;
}

.project-popup-btn {
  background: #fff;
  color: #000;
  padding: 10px 16px;
  justify-self: end;
  border-radius: 16px;
}

.help-panel {
  position: fixed;
  top: 58px;
  right: 16px;
  z-index: 6000;
  width: min(260px, calc(100vw - 32px));
}

.help-panel-inner,
.export-modal-card,
.dropdown-menu {
  background: var(--panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: var(--menu-shadow);
}

.help-panel-inner {
  border-radius: 16px;
  padding: 12px;
  display: grid;
  gap: 7px;
}

.help-title,
.export-modal-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fff;
}

.help-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 11px;
  color: var(--muted);
}

.export-modal {
  position: fixed;
  inset: 0;
  z-index: 7000;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.76);
  backdrop-filter: blur(6px);
}

.export-modal[hidden] {
  display: none !important;
}

.export-modal-card {
  width: min(420px, calc(100vw - 32px));
  border-radius: 18px;
  padding: 18px;
  display: grid;
  gap: 14px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01)),
    rgba(5,5,5,0.98);
}

.export-name-input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}

.export-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.app {
  display: grid;
  grid-template-rows: auto auto 1fr;
  height: 100vh;
  width: 100%;
  min-height: 0;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.app-hidden {
  opacity: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px 0;
  background: transparent;
}

.top-left {
  display: flex;
  align-items: center;
  min-height: 32px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.top-right {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  align-items: center;
}

.top-right > button,
.top-right > div > button {
  min-width: 80px;
  justify-content: center;
}

#helpBtn,
#langBtn {
  min-width: 32px;
  width: 32px;
  padding: 0;
  opacity: 0.72;
}

#helpBtn:hover,
#langBtn:hover {
  opacity: 1;
}

.font-menu-wrap,
.tools-menu-wrap,
.download-menu-wrap {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  min-width: 210px;
  padding: 8px;
  border-radius: 16px;
  display: grid;
  gap: 6px;
  z-index: 50;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01)),
    rgba(0,0,0,0.98);
}

.dropdown-menu[hidden] {
  display: none !important;
}

.dropdown-menu-item {
  width: 100%;
  border-radius: 12px;
  text-align: left;
  background: transparent;
  color: #fff;
  padding: 10px 12px;
  min-height: 0;
}

.dropdown-fonts .dropdown-menu-item {
  font-size: 12px;
}

.dropdown-tools .dropdown-menu-item {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
}

.dropdown-download .dropdown-menu-item {
  font-weight: 500;
}

.dropdown-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.dropdown-separator {
  height: 1px;
  background: rgba(255, 255, 255, 0.10);
  margin: 4px 2px;
}

.custom-font-option {
  font-style: italic;
}

.controls {
  padding: 8px 16px 8px;
  display: grid;
  gap: 10px;
  background: transparent;
  align-content: start;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.input-wrap {
  display: grid;
  gap: 4px;
}

#textInput {
  width: 100%;
  min-height: 92px;
  max-height: 180px;
  resize: none;
  overflow-y: auto;
  background: transparent;
  color: #fff;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.28);
  padding: 0 0 14px 0;
  font-size: 24px;
  line-height: 1.34;
  outline: none;
  transition: border-color 0.18s ease, opacity 0.18s ease;
}

#textInput::placeholder {
  color: rgba(255,255,255,0.42);
}

#textInput:focus {
  border-bottom-color: rgba(255,255,255,0.55);
}

.meta-row {
  display: flex;
  justify-content: flex-end;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.slider-wrap {
  display: grid;
  gap: 8px;
  margin-top: 0;
}

.slider-block {
  display: grid;
  gap: 4px;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.slider-value {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: -1px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.66);
}

.slider-single-value {
  justify-content: flex-end;
}

.slider-shell {
  position: relative;
  display: flex;
  align-items: center;
  height: 30px;
}

#resSlider,
#scaleSlider {
  --percent: 40%;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  margin: 0;
  height: 30px;
  cursor: pointer;
}

#resSlider:focus,
#scaleSlider:focus {
  outline: none;
}

#resSlider::-webkit-slider-runnable-track,
#scaleSlider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.9), rgba(255,255,255,0.9)) 0 50% / var(--percent) 100% no-repeat,
    var(--slider-track);
}

#resSlider::-moz-range-track,
#scaleSlider::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: var(--slider-track);
  border: none;
}

#resSlider::-moz-range-progress,
#scaleSlider::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
}

#resSlider::-webkit-slider-thumb,
#scaleSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: none;
  margin-top: -4px;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.08);
}

#resSlider::-moz-range-thumb,
#scaleSlider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.08);
}

.stage {
  height: 100%;
  min-height: 0;
  padding: 4px 16px 16px;
  background: transparent;
  overflow: hidden;
}

.stage-shell {
  height: 100%;
  min-height: 0;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0.01)),
    rgba(255,255,255,0.01);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.035),
    0 22px 50px rgba(0,0,0,0.34);
  overflow: hidden;
}

.stage-scroller {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 20px 20px 72px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.stage-scroller::-webkit-scrollbar {
  width: 10px;
}

.stage-scroller::-webkit-scrollbar-track {
  background: transparent;
}

.stage-scroller::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.18);
  border-radius: 999px;
}

#displayCanvas {
  width: 100%;
  display: block;
  border-radius: 14px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.04);
}

body.presentation-mode .topbar,
body.presentation-mode .controls {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
}

body.presentation-mode .stage {
  padding: 0;
}

body.presentation-mode .stage-shell {
  border-radius: 0;
  border: none;
  box-shadow: none;
  background: #000;
}

body.presentation-mode .stage-scroller {
  padding: 0 0 0;
}

body.presentation-mode #displayCanvas {
  border-radius: 0;
  box-shadow: none;
}

@media (max-width: 720px) {
  .topbar {
    padding: 12px 14px 0;
    flex-direction: column;
    align-items: stretch;
  }

  .top-right {
    justify-content: flex-start;
    gap: 6px;
  }

  .top-right > button,
  .top-right > div > button {
    min-width: 0;
  }

  .controls {
    padding: 8px 14px 8px;
    gap: 8px;
  }

  #textInput {
    font-size: 20px;
    min-height: 82px;
    max-height: 150px;
  }

  button,
  #fontMenuBtn,
  #toolsMenuBtn,
  #downloadMenuBtn {
    font-size: 11px;
    padding: 8px 10px;
  }

  .dropdown-menu {
    left: 0;
    right: auto;
  }

    .intro-lang-btn {
    top: 14px;
    right: 14px;
  }

  .intro-inner {
    width: min(94vw, 920px);
    padding: 18px 16px;
    gap: 14px;
  }

  .intro-frame {
    width: min(94vw, 860px);
    padding: 2px 0 0;
  }

  .intro-canvas {
    height: min(42vw, 180px);
  }

  .help-panel {
    right: 14px;
    top: 54px;
  }

  .project-popup-card {
    width: min(640px, calc(100vw - 20px));
    padding: 16px;
    border-radius: 18px;
  }

  .project-popup-text {
    font-size: 11px;
    line-height: 1.72;
  }

  .stage {
    padding: 4px 14px 14px;
  }

  .stage-scroller {
    padding: 16px 16px 58px;
  }
}
.export-email-input[hidden] {
  display: none !important;
}
