:root {
  --bg: #0b0b0b;
  --surface: #171717;
  --surface-2: #222;
  --text: #f5f5f5;
  --muted: #9a9a9a;
  --accent: #ff4b2b;
  --radius: 12px;
  --prompter-text: #ffffff;
  --prompter-bg: #000000;
  --prompter-font-size: 64px;
  --prompter-width: 90%;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body { overflow: hidden; }

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
}

.screen.is-active { display: flex; }

/* ---------- Editor ---------- */

#editor-screen {
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  overflow-y: auto;
  gap: 16px;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
}

.editor-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.room-code {
  background: var(--surface);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  letter-spacing: 0.15em;
  color: var(--accent);
}

.primary-button {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 12px 22px;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  touch-action: manipulation;
}

.primary-button:active { transform: scale(0.98); }

.primary-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.script-input {
  width: 100%;
  min-height: 40vh;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 16px;
  line-height: 1.5;
  font-family: inherit;
}

.script-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

.settings {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.setting {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.setting output { color: var(--text); font-weight: 600; }

.setting input[type="range"] { width: 100%; accent-color: var(--accent); }

.setting-row {
  flex-direction: row;
  gap: 16px;
}

.color-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.color-label input[type="color"] {
  width: 36px;
  height: 36px;
  border: 0;
  padding: 0;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
}

.setting-toggle {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.setting-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

.editor-footer { padding-bottom: 24px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 0; }
kbd {
  background: var(--surface-2);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
}

@media (hover: none) and (max-width: 720px) {
  .hint { display: none; }
}

/* ---------- Prompter ---------- */

.prompter {
  background: var(--prompter-bg);
  color: var(--prompter-text);
  overflow: hidden;
}

.prompter-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  justify-content: center;
}

.prompter-content {
  width: var(--prompter-width);
  max-width: 100%;
  padding: 50vh 0;
  font-size: var(--prompter-font-size);
  line-height: 1.35;
  font-weight: 600;
  white-space: pre-wrap;
  word-wrap: break-word;
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

.prompter.is-mirrored .prompter-content { transform: scaleX(-1) translate3d(0, 0, 0); }

.reading-line {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255, 75, 43, 0.35);
  pointer-events: none;
}

.exit-button {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  right: 12px;
  z-index: 10;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  touch-action: manipulation;
}

.countdown {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 30vh;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 4px 40px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 5;
}

.countdown.is-visible { display: flex; }

.status-indicator {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 18px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: #fff;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.status-indicator.is-visible { opacity: 1; }

/* Fallback "quase tela cheia" para iOS */
.prompter.fs-fallback {
  position: fixed;
  inset: 0;
  z-index: 9999;
}
