html, body {
  margin: 0;
  padding: 0;
  background-color: black;
  color: white;
  font-family: 'arial-narrow', 'Arial Narrow', Arial, Helvetica, sans-serif;
  overflow: hidden;
  cursor: default;
}

/* Scene root — wraps everything for rotation */
#scene-root {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: center center;
}

#background-text-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  box-sizing: border-box;
  overflow: hidden;
  z-index: 0;
  -webkit-mask-image:
    linear-gradient(to bottom, transparent, black 15%, black 80%, transparent),
    linear-gradient(to right, transparent, black 10%, black 90%, transparent);
  -webkit-mask-composite: destination-in;
  mask-image:
    linear-gradient(to bottom, transparent, black 15%, black 80%, transparent),
    linear-gradient(to right, transparent, black 10%, black 90%, transparent);
  mask-composite: intersect;
}

#background-text {
  color: rgba(255, 255, 255, 0.3);
  font-family: "arial-narrow", "Arial Narrow", sans-serif;
  font-size: clamp(10px, 1.2vw, 14px);
  line-height: 1.2em;
  text-align: justify;
  text-align-last: justify;
  white-space: normal;
  width: 100%;
  height: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

canvas {
  position: relative;
  z-index: 1;
  display: block;
  cursor: default;
}

/* Widths for notch & corners are set dynamically */
#phone-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 0;
  background: #111;
  box-shadow:
    0 40px 80px rgba(0,0,0,0.5),
    0 0 80px rgba(255,255,255,0.05),
    inset 0 0 15px rgba(255,255,255,0.02);
  overflow: hidden;
  z-index: 2;
}

/* Canvas fills phone screen */
#phone-container canvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 0;
  box-shadow:
    inset 0 0 20px rgba(0,0,0,0.5),
    0 10px 20px rgba(0,0,0,0.2);
}

/* Notch */
.phone-notch {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: #111;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  z-index: 3;
}

/* Mobile: full-bleed canvas, no phone frame */
@media (max-width: 600px) {
  #phone-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    transform: none;
    border-radius: 0 !important;
    background: transparent;
    box-shadow: none;
  }

  #phone-container canvas {
    border-radius: 0 !important;
    box-shadow: none;
  }

  .phone-notch {
    display: none;
  }

  #background-text-container {
    display: none;
  }
}

/* Landscape on small devices */
@media (max-height: 500px) and (orientation: landscape) {
  #phone-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    transform: none;
    border-radius: 0 !important;
    background: transparent;
    box-shadow: none;
  }

  #phone-container canvas {
    border-radius: 0 !important;
    box-shadow: none;
  }

  .phone-notch {
    display: none;
  }

  #background-text-container {
    display: none;
  }
}

/* Force phone frame — overrides mobile media queries */
body.force-phone-frame #phone-container {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  border-radius: 0 !important; /* JS sets the real value */
  background: #111 !important;
  box-shadow:
    0 40px 80px rgba(0,0,0,0.5),
    0 0 80px rgba(255,255,255,0.05),
    inset 0 0 15px rgba(255,255,255,0.02) !important;
}

body.force-phone-frame .phone-notch {
  display: block !important;
}

body.force-phone-frame #phone-container canvas {
  box-shadow:
    inset 0 0 20px rgba(0,0,0,0.5),
    0 10px 20px rgba(0,0,0,0.2) !important;
}

body.force-phone-frame #background-text-container {
  display: block !important;
}

/* Settings overlay */
#settings-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

#settings-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.settings-panel {
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 28px 32px;
  width: 320px;
  max-height: 80vh;
  overflow-y: auto;
  font-family: 'arial-narrow', 'Arial Narrow', Arial, Helvetica, sans-serif;
}

.settings-panel h2 {
  margin: 0 0 20px 0;
  font-size: 18px;
  font-weight: normal;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 0.5px;
}

.preset-notice {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 16px;
  font-style: italic;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.setting-row label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

.setting-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.setting-control button {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.5);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: all 0.15s;
}

.setting-control button.active {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border-color: rgba(255, 255, 255, 0.3);
}

.setting-control button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.setting-control input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}

.setting-control input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transition: transform 0.2s, background 0.2s;
}

.setting-control input[type="checkbox"]:checked {
  background: rgba(255, 255, 255, 0.25);
}

.setting-control input[type="checkbox"]:checked::after {
  transform: translateX(16px);
  background: white;
}

.setting-control input[type="checkbox"]:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.setting-control input[type="range"] {
  width: 100px;
  accent-color: rgba(255, 255, 255, 0.5);
}

.setting-control input[type="range"]:disabled {
  opacity: 0.3;
}

#scroll-speed-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  min-width: 30px;
  text-align: right;
}

.settings-presets {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-presets label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  display: block;
  margin-bottom: 10px;
}

#preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#preset-buttons button {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.5);
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  transition: all 0.15s;
}

#preset-buttons button.active {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border-color: rgba(255, 255, 255, 0.3);
}

#preset-buttons button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.settings-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.settings-actions button {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.6);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: all 0.15s;
}

.settings-actions button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}
