:root {
  --bg-light: #fff;
  --text-light: #1e1e1e;
  --bg-dark: #121212;
  --text-dark: #e0e0e0;
  --primary: #0078d4;
  --primary-dark: #3399ff;
  --btn-size: 56px;
  --btn-radius: 50%;
  --btn-shadow: 0 4px 12px rgba(0, 120, 212, 0.4);
  --notif-bg: #0078d4;
  --notif-text: #fff;
}

body,
html {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background: var(--bg-light);
  color: var(--text-light);
  transition: background 0.3s, color 0.3s;
  overflow: hidden;
}

@media (prefers-color-scheme: dark) {

  body,
  html {
    background: var(--bg-dark);
    color: var(--text-dark);
  }
}

#start-screen,
#loading-screen {
  position: fixed;
  top: 0;
  left: 50%;
  width: 100vw;
  max-width: 480px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  text-align: center;
  box-sizing: border-box;
  transform: translateX(-50%);
  background: var(--bg-light);
  color: var(--text-light);
  z-index: 1001;
}

@media (prefers-color-scheme: dark) {

  #start-screen,
  #loading-screen {
    background: var(--bg-dark);
    color: var(--text-dark);
  }
}

#loading-screen {
  display: none;
}

#start-screen p,
#loading-screen p {
  font-size: 1.25rem;
  margin-bottom: 2rem;
}

#start-button {
  padding: 0.75rem 2rem;
  font-size: 1.1rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: var(--btn-shadow);
  transition: background-color 0.3s;
}

#start-button:hover,
#start-button:focus {
  background: var(--primary-dark);
  outline: none;
}

#iframe-container {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-light);
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
}

@media (prefers-color-scheme: dark) {
  #iframe-container {
    background: var(--bg-dark);
  }
}

#iframe-container.visible {
  opacity: 1;
  transform: scale(1);
}

#output-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
}

.floating-button {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: var(--btn-size);
  height: var(--btn-size);
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--btn-radius);
  box-shadow: var(--btn-shadow);
  font-size: 28px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: background-color 0.3s;
}

.floating-button:hover,
.floating-button:focus {
  background: var(--primary-dark);
  outline: none;
}

@media (prefers-color-scheme: dark) {
  .floating-button {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(51, 153, 255, 0.7);
  }

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

#sponsor-notification {
  position: fixed;
  bottom: -200px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 90vw;
  width: 400px;
  background: var(--notif-bg);
  color: var(--notif-text);
  padding: 1rem 1.5rem;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
  font-size: 1rem;
  line-height: 1.4;
  box-sizing: border-box;
  opacity: 0;
  transition: opacity 0.4s ease, bottom 0.4s ease;
  z-index: 11000;
  display: flex;
  flex-direction: column;
}

#sponsor-notification.visible {
  bottom: 0;
  opacity: 1;
}

#sponsor-text {
  margin: 0 0 0.5rem 0;
  text-align: left;
}

#sponsor-notification button {
  align-self: flex-end;
  background: transparent;
  border: 1.5px solid var(--notif-text);
  border-radius: 4px;
  color: var(--notif-text);
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.3s, color 0.3s;
}

#sponsor-notification button:hover,
#sponsor-notification button:focus {
  background: var(--notif-text);
  color: var(--notif-bg);
  outline: none;
}

#sponsor-text a {
  color: #ffe;
  text-decoration: underline;
}

#sponsor-text a:hover,
#sponsor-text a:focus {
  color: #ccf;
}

#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 12000;
}

#modal-overlay.visible {
  display: flex;
}

#modal {
  background: var(--bg-light);
  color: var(--text-light);
  border-radius: 8px;
  padding: 1.5rem 1.75rem;
  max-width: 400px;
  width: 90vw;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

#modal label {
  margin-bottom: 0.5rem;
  font-weight: 600;
}

#modal textarea {
  font-size: 1rem;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  resize: none;
  width: 100%;
  box-sizing: border-box;
  white-space: normal;
  overflow-wrap: break-word;
  overflow-y: hidden;
  min-height: 1.5em;
  line-height: 1.2;
  background: inherit;
  color: inherit;
}

#modal-buttons {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

#modal button {
  padding: 0.5rem 1rem;
  font-size: 1rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

#modal-ok {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--btn-shadow);
  transition: background-color 0.3s;
}

#modal-ok:hover,
#modal-ok:focus {
  background: var(--primary-dark);
  outline: none;
}

#modal-cancel {
  background: #ccc;
  color: #333;
}

#modal-cancel:hover,
#modal-cancel:focus {
  background: #aaa;
  color: #fff;
  outline: none;
}

@media (prefers-color-scheme: dark) {
  #modal {
    background: var(--bg-dark);
    color: var(--text-dark);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
  }

  #modal textarea {
    background: #222;
    border: 1px solid #555;
    color: var(--text-dark);
  }

  #modal textarea::placeholder {
    color: #888;
  }

  #modal-ok {
    background: var(--primary-dark);
    color: #fff;
  }

  #modal-ok:hover,
  #modal-ok:focus {
    background: var(--primary);
  }

  #modal-cancel {
    background: #444;
    color: #ccc;
  }

  #modal-cancel:hover,
  #modal-cancel:focus {
    background: #666;
    color: #fff;
  }
}