/* Modern normalize */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  line-height: 1.15;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Atkinson Hyperlegible Next', sans-serif;
  font-optical-sizing: auto;
  background-color: #ffffff;
  color: #121212;
  line-height: 1.6;
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  overflow-x: hidden;
  box-sizing: border-box;
}

body.page-center-content {
    justify-content: center;
    padding-top: 0;
    padding-bottom: 0;
}


h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  line-height: 1.2;
  font-weight: 700;
}

h1 {
  font-size: 3rem;
  margin-bottom: 24px;
}

hr {
  height: 0;
  overflow: visible;
}

pre, code, kbd, samp {
  font-family: monospace, monospace;
  font-size: 1em;
}

a {
  background-color: transparent;
}

abbr[title] {
  border-bottom: none;
  text-decoration: underline;
  text-decoration: underline dotted;
}

b, strong {
  font-weight: bolder;
}

small {
  font-size: 80%;
}

sub, sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sub {
  bottom: -0.25em;
}

sup {
  top: -0.5em;
}

img {
  border-style: none;
  max-width: 100%;
  height: auto;
}

button, input, optgroup, select, textarea {
  font-family: inherit;
  font-size: 100%;
  line-height: 1.15;
  margin: 0;
}

button, input {
  overflow: visible;
}

button, select {
  text-transform: none;
}

button, [type="button"], [type="reset"], [type="submit"] {
  -webkit-appearance: button;
  appearance: button;
}

button::-moz-focus-inner, [type="button"]::-moz-focus-inner, [type="reset"]::-moz-focus-inner, [type="submit"]::-moz-focus-inner {
  border-style: none;
  padding: 0;
}

fieldset {
  padding: 0.35em 0.75em 0.625em;
}

legend {
  padding: 0;
}

progress {
  vertical-align: baseline;
}

[type="checkbox"], [type="radio"] {
  padding: 0;
}

[type="number"]::-webkit-inner-spin-button, [type="number"]::-webkit-outer-spin-button {
  height: auto;
}

[type="search"] {
  -webkit-appearance: textfield;
  appearance: textfield;
  outline-offset: -2px;
}

[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}

::-webkit-file-upload-button {
  -webkit-appearance: button;
  font: inherit;
}

summary {
  display: list-item;
}


/* Variables */
:root {
  /* Typography */
  --font-primary: 'Atkinson Hyperlegible Next', sans-serif;
  --font-mascot: 'Cabin Condensed', sans-serif;
  --font-carousel: var(--font-mascot);
  
  /* Colors - Light Mode Default */
  --color-background: #ffffff;
  --color-text: #121212;
  --color-secondary: #eeeeee;
  --color-border: #333333;
  --color-card-bg: #f5f5f5;
  --color-active-light: #eaeaea;
  --color-active-dark: #333333;
  
  /* Spacing */
  --spacing-unit: 8px;
  --spacing-small: var(--spacing-unit);
  --spacing-medium: calc(var(--spacing-unit) * 3);
  --spacing-large: calc(var(--spacing-unit) * 8);
  
  /* Typography Scale */
  --font-size-huge: 5rem;
  --font-size-large: 3rem;
  --font-size-medium: 1.5rem;
  --font-size-regular: 1rem;
  --font-size-small: 0.875rem;
  
  /* Shadow and Transform Variables */
  --shadow-size-default: 4px;
  --shadow-size-hover: 6px;
  --shadow-size-card: 8px;
  --shadow-opacity-light: 0.6;
  --hover-transform: translate(-2px, -2px);
  --active-transform: translate(2px, 2px);
}

/* Canvas Background */
#staticCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  display: block;
  pointer-events: none;
}

/* Base Styles & Typography */
p {
    line-height: 1.6;
    margin-bottom: 24px;
    font-size: 1rem;
}

/* Link and Button Styles */
a {
  text-decoration: none;
}

a.button, button.button {
    background-color: white;
    color: #121212;
    border: 2px solid #121212;
    position: relative;
    box-shadow: 4px 4px 0 #121212;
    transition: all 0.2s ease;
    padding: 6px 12px;
    display: inline-block;
    font-weight: 600;
    margin: 8px 0;
    cursor: pointer;
    text-decoration: none;
}

a.button:hover,
a.button:focus,
button.button:hover,
button.button:focus {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 1px rgba(0, 0, 0, 0.6);
    text-decoration: none;
}

a.button:active,
button.button:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 #121212;
    background-color: #eaeaea;
}

button.button:disabled,
a.button:disabled {
    cursor: wait;
    background-color: #eeeeee;
    box-shadow: 1px 1px 0 #333333;
    color: #888888;
    transform: translate(1px, 1px);
}

.twitch-login {
    background-color: #9146FF;
    color: white;
    border-color: #772CE8;
    box-shadow: 4px 4px 0 #772CE8;
}

.twitch-login:hover,
.twitch-login:focus {
    box-shadow: 6px 6px 1px rgba(0, 0, 0, 0.4);
}

.twitch-login:active {
    background-color: #5c16c5;
    box-shadow: 1px 1px 0 #772CE8;
}

/* Links not styled as buttons */
a:not(.button) {
    background-color: transparent;
    color: var(--color-text);
    border: none;
    box-shadow: none;
    text-decoration: underline;
    padding: 0;
    font-weight: normal;
}

a:not(.button):hover,
a:not(.button):focus {
    color: #666666;
    transform: none;
    box-shadow: none;
}

a:not(.button):active {
    color: #999999;
    transform: none;
    box-shadow: none;
    background: none;
}

/* Button Group Layout */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 24px 0;
    align-items: center;
}

.button-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
}

.tooltip-wrapper {
    position: absolute;
    left: calc(50% + 120px);
    top: 50%;
    transform: translateY(-50%);
}

.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #666;
    color: white;
    font-size: 12px;
    font-weight: bold;
    cursor: help;
    position: relative;
    border: 1px solid #888;
}

.help-icon:hover {
    background-color: #444;
}

.help-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    padding: 8px 12px;
    background-color: #333;
    color: white;
    border-radius: 4px;
    font-size: 13px;
    font-weight: normal;
    white-space: nowrap;
    max-width: 200px;
    white-space: normal;
    width: max-content;
    max-width: 240px;
    text-align: center;
    line-height: 1.4;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.help-icon::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 2px;
    border: 4px solid transparent;
    border-top-color: #333;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
}

.help-icon:hover::after,
.help-icon:hover::before {
    opacity: 1;
    visibility: visible;
}

.viewer-prefs {
    background-color: #4CAF50;
    color: white;
    border-color: #45a049;
    box-shadow: 4px 4px 0 #45a049;
}

.viewer-prefs:hover,
.viewer-prefs:focus {
    box-shadow: 6px 6px 1px rgba(0, 0, 0, 0.4);
}

.viewer-prefs:active {
    background-color: #3e8e41;
    box-shadow: 1px 1px 0 #45a049;
}


/* Main Layout Components */
.container {
    background-color: #fff;
    padding: 25px;
    border-radius: 8px;
    border: 2px solid var(--color-border);
    box-shadow: 8px 8px 0 var(--color-border);
    text-align: center;
    max-width: 550px;
    width: 90%;
    position: relative;
    z-index: 1;
    margin: 0 0 40px 0;
}

.container h1 {
    font-size: 2.8rem;
    margin-bottom: 20px;
}

.container > p {
    margin-bottom: 15px;
}

header {
  margin-bottom: var(--spacing-large);
  border-bottom: 4px solid var(--color-border);
  padding-bottom: var(--spacing-large);
  display: grid;
  grid-template-columns: 1fr 560px;
  grid-template-areas: "content mascot-area";
  gap: var(--spacing-medium);
  align-items: center;
}

header h1 {
  font-size: var(--font-size-huge);
  margin-bottom: 0;
  line-height: 1;
  letter-spacing: -1px;
}

header .role {
  font-size: var(--font-size-medium);
  margin-top: var(--spacing-unit);
  background-color: rgba(255, 255, 255, 0.66);
  padding: 4px 8px;
  display: inline-block;
  border-radius: 4px;
}

header .tagline {
  font-size: var(--font-size-regular);
  margin-top: var(--spacing-medium);
  max-width: 65%;
  line-height: 1.8;
  background-color: rgba(255, 255, 255, 0.66);
  padding: 8px 12px;
  border-radius: 4px;
}

.header-content {
  grid-area: content;
  padding-right: var(--spacing-medium);
}

.header-mascot-area {
  grid-area: mascot-area;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--spacing-unit);
  width: 560px;
  margin-top: var(--spacing-small);
}

.mascot-container {
  width: 400px;
  height: auto;
  min-height: 250px;
  max-height: 500px;
  position: relative;
  background: none;
  border: none;
  box-shadow: none;
  transition: height 0.5s ease;
  box-sizing: border-box;
  overflow: visible;
}

.mascot {
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.mascot-card {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background-color: white;
}

.mascot-ai-description {
  width: 100%;
  margin-top: var(--spacing-unit);
  padding: var(--spacing-unit);
  background-color: var(--color-card-bg);
  border: 2px solid var(--color-border);
  box-shadow: 4px 4px 0 var(--color-text);
  font-size: var(--font-size-small);
  line-height: 1.4;
  max-height: 200px;
  overflow-y: auto;
  box-sizing: border-box;
  transition: opacity 0.3s ease, transform 0.3s ease;
  opacity: 0;
  transform: translateY(10px);
}

.mascot-ai-description.visible {
  opacity: 1;
  transform: translateY(0);
  display: block;
}

/* Dashboard & Settings Styles */

#bot-status-container {
    margin-top: 15px;
    margin-bottom: 15px;
    padding: 20px;
}

#bot-status-container p {
    margin-bottom: 8px;
}

#bot-status-container strong {
    font-weight: 700;
}

.status-active {
    color: #4caf50; /* Green */
}

.status-inactive {
    color: #f44336; /* Red */
}

#action-message {
    margin-top: 15px;
    margin-bottom: 20px;
    min-height: 18px;
    font-size: 0.875rem;
}

.tab-container {
  margin: var(--spacing-large) 0;
}

.tab-nav {
  display: flex;
  width: 100%;
  border-bottom: 4px solid var(--color-border);
  margin-bottom: 0;
  background: none;
  position: relative;
}

.tab-button {
  flex: 1 1 0;
  background: #f5f5f5;
  border: 4px solid var(--color-border);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  padding: 18px 0 14px 0;
  font-family: var(--font-primary);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  cursor: pointer;
  margin: 0 8px 0 0;
  position: relative;
  z-index: 1;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s, border-color 0.18s;
}

.tab-button:last-child {
  margin-right: 0;
}

.tab-button:hover,
.tab-button:focus {
  background: #ececec;
  z-index: 2;
}

.tab-button.active {
  background: #fff;
  color: var(--color-primary, #3498db);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  box-shadow: 4px 4px 0 var(--color-border);
  z-index: 2;
}

.tab-content {
  display: none;
  background: var(--color-card-bg);
  border: 3px solid var(--color-border);
  border-top: none;
  padding: var(--spacing-large);
  min-height: 400px;
  position: relative;
}

.tab-content.active {
  display: block;
}

/* Hidden class for content wrapper */
.hidden {
    display: none;
}

/* Loading Overlay */
.loading-overlay {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 80px 0;
    width: 100%;
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 15px;
    font-weight: 600;
    color: #333;
}

.settings-section {
  margin-bottom: var(--spacing-large);
  padding: var(--spacing-medium);
  background: var(--color-bg);
  border-bottom: 2px solid var(--color-border);
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-section h3 {
  color: var(--color-primary);
  margin-bottom: var(--spacing-medium);
  font-family: var(--font-mascot);
  font-size: 1.3rem;
  font-weight: 600;
}

.setting-item {
  margin-bottom: var(--spacing-medium);
  display: flex;
  align-items: center;
  gap: 12px;
}

.setting-item label {
  font-weight: 500;
  color: var(--color-text);
  min-width: 180px;
}

.setting-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-right: var(--spacing-small);
}

.setting-item input[type="number"],
.setting-item select {
  padding: 8px 12px;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-primary);
  max-width: 200px;
}

.setting-item input[type="number"] {
  max-width: 120px;
}

.setting-item input[type="number"]:focus,
.setting-item select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(var(--color-primary-rgb), 0.2);
}

/* Range slider styling */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 220px;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  outline: none;
  margin: 0 8px;
  transition: background 0.3s;
  position: relative;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #222;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  cursor: pointer;
  margin-top: -4px;
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #222;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  cursor: pointer;
  margin-top: 0;
}

.settings-section span[id$="-value"] {
  min-width: 32px;
  text-align: left;
  font-weight: 500;
  font-size: 1.1em;
  margin-left: 8px;
  padding: 2px 6px;
  border: 2px solid #000;
  border-radius: 4px;
  background: #ffffff;
}

/* Ignore list styles */
.ignore-section {
  margin-bottom: var(--spacing-medium);
}

.ignore-section h4 {
  margin-bottom: var(--spacing-small);
  color: var(--color-text);
  font-weight: 600;
}

.add-user-form {
  display: flex;
  gap: var(--spacing-small);
  margin-bottom: var(--spacing-small);
}

.add-user-form input {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-primary);
}

.ignore-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 150px;
  overflow-y: auto;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
}

.ignore-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
}

.ignore-list li:last-child {
  border-bottom: none;
}

.ignore-list .remove-btn {
  background: var(--color-danger, #e74c3c);
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

.ignore-list .remove-btn:hover {
  background: var(--color-danger-hover, #c0392b);
}

/* OBS Setup Styles */
#obs-setup-instructions {
    text-align: left;
    margin-top: 0;
    padding: 15px;
    border: 3px solid var(--color-border);
    border-top: none;
    background: var(--color-card-bg);
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 2px 2px 0px 2px black;
  }

.tts-url-container {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

#tts-url-field {
    flex-grow: 1;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-right: 10px;
    font-size: 0.9em;
}

#copy-tts-url-btn {
    padding: 8px 12px;
}

#copy-status-message {
    font-size: 0.8em;
    height: 1em;
    margin-bottom: 15px;
}

/* Footer */
footer {
  margin-top: var(--spacing-large);
  padding-top: var(--spacing-large);
  border-top: 4px solid var(--color-border);
  font-size: var(--font-size-small);
}

footer a {
  text-decoration: underline;
  padding: 0;
  font-weight: bold;
  display: inline;
}

/* Invite-only notice styles */
.invite-notice {
  background: #fff3cd;
  border: 1px solid #ffeaa7;
  padding: 10px;
  border-radius: 5px;
  margin-bottom: 20px;
  font-size: 0.9em;
}

.invite-notice a {
  color: #007bff;
  text-decoration: underline;
}

/* Dark Mode Styles */
@media (prefers-color-scheme: dark) {
  :root {
    --color-background: #121212;
    --color-text: #ffffff;
    --color-secondary: #333333;
    --color-card-bg: #1e1e1e;
    --color-border: #ffffff;
    --shadow-color: rgba(255, 255, 255, 0.33);
  }

  body {
    background-color: var(--color-background);
    color: var(--color-text);
  }

  .container {
    background-color: var(--color-card-bg);
    border-color: var(--color-border);
    box-shadow: 8px 8px 0 var(--shadow-color);
  }
  
  a, a.button, button.button {
    background-color: #ffffff;
    color: #000000;
    border: 2px solid #555555;
    box-shadow: 4px 4px 0 var(--shadow-color);
  }
  
  a:hover, a:focus, a.button:hover, a.button:focus, button.button:hover, button.button:focus {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 1px rgb(255, 255, 255, 0.1);
    background-color: #ffffff;
    color: #000000;
  }
  
  a:active, a.button:active, button.button:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 var(--shadow-color);
    background-color: #333333;
    color: #ffffff;
  }

  .twitch-login {
    background-color: #9146FF;
    color: white;
    border-color: #772CE8;
    box-shadow: 4px 4px 0 #5c16c5;
  }

  .twitch-login:hover, .twitch-login:focus {
    box-shadow: 6px 6px 1px rgba(255, 255, 255, 0.2);
  }

  .twitch-login:active {
    background-color: #5c16c5;
    box-shadow: 1px 1px 0 #772CE8;
  }

  button.button:disabled, a.button:disabled {
    background-color: #444444;
    border-color: #666666;
    color: #888888;
    box-shadow: 1px 1px 0 rgba(255, 255, 255, 0.33);
  }

  .mascot-ai-description {
    background-color: #333333;
    border-color: #555555;
    box-shadow: 4px 4px 0 var(--shadow-color);
  }
  
  header .role, header .tagline {
    background-color: rgba(0, 0, 0, 0.25);
  }

  .tab-nav {
    border-bottom: 4px solid #fff;
  }
  .tab-button {
    background: #222;
    color: #eee;
    border: 4px solid #fff;
    border-bottom: none;
  }
  .tab-button.active {
    background: #111;
    color: #4aa3f7;
    box-shadow: 4px 4px 0 #fff;
  }
  .tab-button:hover, .tab-button:focus {
    background: #333;
    color: #fff;
  }

  footer a {
    background-color: transparent;
    color: #ffffff;
    border: none;
    box-shadow: none;
    padding: 0;
  }

  footer a:hover, footer a:focus {
    color: #cccccc;
    transform: none;
    box-shadow: none;
  }

  footer a:active {
    color: #999999;
    transform: none;
    box-shadow: none;
    background: none;
  }

  a:not(.button) {
      color: #ffffff;
  }

  a:not(.button):hover, a:not(.button):focus {
      color: #bbbbbb;
  }
  
  a:not(.button):active {
      color: #999999;
  }

  .viewer-prefs {
    background-color: #4CAF50;
    color: white;
    border-color: #45a049;
    box-shadow: 4px 4px 0 #2e7d32;
  }

  .viewer-prefs:hover, .viewer-prefs:focus {
    box-shadow: 6px 6px 1px rgba(255, 255, 255, 0.2);
  }

  .viewer-prefs:active {
    background-color: #2e7d32;
    box-shadow: 1px 1px 0 #45a049;
  }

  .help-icon {
    background-color: #888;
    border-color: #aaa;
  }

  .help-icon:hover {
    background-color: #666;
  }

  .help-icon::after {
    background-color: #555;
    color: #fff;
  }

  .help-icon::before {
    border-top-color: #555;
  }

  #obs-setup-instructions {
      background-color: #2a2a2a;
      border-color: #555;
      color: #e0e0e0;
  }
  #obs-setup-instructions h2, #obs-setup-instructions h4 {
      color: #ffffff;
  }
  #obs-setup-instructions p, #obs-setup-instructions li {
      color: #c0c0c0;
  }
  #obs-setup-instructions strong {
      color: #e0e0e0;
  }
  #obs-setup-instructions code {
      background-color: #333;
      color: lightcyan;
      padding: 2px 4px;
      border-radius: 3px;
  }
  #tts-url-field {
      background-color: #333333;
      border-color: #555555;
      color: #ffffff;
  }
  #tts-url-field::placeholder {
      color: #888888;
  }
  .settings-section span[id$="-value"] {
    border-color: #fff;
    background: #333;
  }

  .loading-overlay {
    background: transparent;
    color: #fff;
  }

  .loading-overlay p {
    color: #fff;
  }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  :root {
    --font-size-huge: 2.5rem;
    --font-size-large: 1.8rem;
    --font-size-medium: 1.2rem;
    --spacing-unit: 6px;
  }
  
  body {
    padding: var(--spacing-small);
    max-width: 100%;
  }
  
  .container {
    max-width: 95%;
    padding: 15px;
    margin-bottom: 20px;
  }
    
  .container h1 {
      font-size: 2rem;
  }

  header {
    grid-template-columns: 1fr 350px;
  }
  
  .header-mascot-area {
     width: 350px;
  }
  
  .tab-button {
    font-size: 1rem;
    padding: 12px 8px 10px 8px;
  }
  
  .settings-section {
    padding: var(--spacing-small);
    margin-bottom: var(--spacing-medium);
  }
  
  .setting-item {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .setting-item label {
    min-width: auto;
    width: 100%;
  }
  
  .setting-item input[type="number"],
  .setting-item select,
  .setting-item input[type="range"] {
    max-width: 100%;
    width: 100%;
  }
  
  .setting-item .reset-btn {
    align-self: center;
    margin: 8px 0 0 0;
  }
  
  .add-user-form {
    flex-direction: column;
    align-items: center;
  }
  
  .add-user-form input {
    width: 100%;
  }
  
  .add-user-form .button {
    width: 60%;
    max-width: 120px;
  }
  
  .ignore-list {
    max-height: 120px;
  }

  .tts-url-container {
      flex-direction: column;
      gap: 10px;
  }
  
  #tts-url-field {
      margin-right: 0;
      width: 100%;
      box-sizing: border-box;
  }
  
  #copy-tts-url-btn {
      width: 80%;
      max-width: 200px;
      margin: 0 auto;
  }
  
  #obs-setup-instructions {
      padding: 10px;
      max-height: 300px;
  }

  /* Ensure setting items with tooltips stay in a single row */
  .setting-item:has(.help-icon) {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .setting-item:has(.help-icon) label {
    width: auto;
    min-width: unset;
  }

  .setting-item:has(.help-icon) .help-icon {
    margin-left: 4px;
  }
}

@media (max-width: 575px) {
  :root {
    --font-size-huge: 2rem;
    --font-size-large: 1.5rem;
    --font-size-medium: 1.1rem;
    --spacing-unit: 4px;
  }
  
  body {
    padding: var(--spacing-small);
    font-size: 0.9rem;
  }
  
  header {
    grid-template-columns: 1fr;
    grid-template-areas: "content" "mascot-area";
  }
  
  .header-mascot-area {
    width: 100%;
    max-width: 300px;
    align-items: center;
    margin: var(--spacing-medium) auto 0 auto;
  }
  
  .mascot-ai-description {
    width: 100%;
    max-width: 280px;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
    background: none;
    color: #999999;
  }
  
  header h1 {
    font-size: 2rem;
    text-align: center;
  }
  
  header .tagline {
    max-width: 100%;
    text-align: center;
  }
  
  .container {
    padding: var(--spacing-small);
    width: 100%;
  }
  
  .container h1 {
    font-size: 1.6rem;
    margin-bottom: 15px;
  }
  
  p {
      font-size: 0.9rem;
      margin-bottom: 16px;
  }

  .tab-content {
    padding: var(--spacing-small);
    min-height: auto;
  }
  
  .settings-section h3 {
    font-size: 1.1rem;
  }
  
  a.button, button.button {
    padding: 8px 12px;
    font-size: 0.9rem;
    width: 80%;
    max-width: 300px;
    margin: 8px auto;
  }

  .button-group {
    gap: 8px;
    margin: 16px 0;
  }

  .button-wrapper {
    justify-content: center;
  }
  
  .tooltip-wrapper {
    left: calc(50% + 160px);
  }

  .help-icon::after {
    max-width: 180px;
    font-size: 12px;
  }
  
  #obs-setup-instructions {
    font-size: 0.85rem;
  }
  
  #obs-setup-instructions h2 {
    font-size: 1.3rem;
  }
  
  #obs-setup-instructions h4 {
    font-size: 1rem;
  }
  
  #tts-url-field {
    font-size: 0.8rem;
  }
}

/* Simplified layout for slider settings - tablet style for all screens */
.setting-item:has(input[type="range"]) {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  padding: 8px 0;
}

.setting-item:has(input[type="range"]) label {
  text-align: center;
  margin-bottom: 4px;
}

.setting-item:has(input[type="range"]) input[type="range"] {
  width: 100%;
  margin: 0;
}

.setting-item:has(input[type="range"]) .reset-btn {
  align-self: center;
  margin: 8px 0 0 0;
}

/* Fallback for browsers that don't support :has() */
@supports not (selector(:has(*))) {
  .setting-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    padding: 8px 0;
  }
  
  .setting-item label {
    text-align: center;
    margin-bottom: 4px;
  }
  
  .setting-item input[type="range"] {
    width: 100%;
    margin: 0;
  }
  
  .setting-item .reset-btn {
    align-self: center;
    margin: 8px 0 0 0;
  }
}

/* Voice test layout - stack vertically like range inputs */
.voice-test-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  padding: 8px 0;
}

.voice-test-item label {
  text-align: center;
  margin-bottom: 4px;
  min-width: unset;
}

.voice-test-item input[type="text"] {
  width: 100%;
  margin: 0;
  max-width: unset;
  padding: 8px 12px;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-primary);
}

.voice-test-item .reset-btn {
  align-self: center;
  margin: 8px 0 0 0;
}

/* Reset buttons for sliders */
.reset-btn {
  font-size: 0.8rem;
  padding: 4px 12px;
  background: #f0f0f0;
  border: 1px solid #ccc;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: none;
}

.reset-btn:hover {
  background: #e0e0e0;
  border-color: #999;
  color: #333;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transform: none;
}

.reset-btn:active {
  background: #d0d0d0;
  transform: translateY(1px);
  box-shadow: none;
}

@media (prefers-color-scheme: dark) {
  .reset-btn {
    background: #333;
    border-color: #555;
    color: #ccc;
  }
  
  .reset-btn:hover {
    background: #444;
    border-color: #777;
    color: #fff;
  }
  
  .reset-btn:active {
    background: #222;
  }
}

/* Dark mode for invite notice */
@media (prefers-color-scheme: dark) {
  .invite-notice {
    background: #2a2a1a;
    border: 1px solid #544c3a;
    color: #e0e0e0;
  }
  
  .invite-notice a {
    color: #66b3ff;
  }
}

/* Mobile adjustments for reset buttons */
@media (max-width: 600px) {
  .reset-btn {
    font-size: 0.75rem;
    padding: 3px 8px;
  }
}

@media all {
  /* Ensure bordered current-value badge appears in viewer page too */
  .setting-section span[id$="-value"] {
    min-width: 32px;
    display: inline-block;
    text-align: center;
    font-weight: 500;
    font-size: 1.1em;
    margin-left: 8px;
    padding: 2px 6px;
    border: 2px solid #000;
    border-radius: 4px;
    background: #ffffff;
  }
  @media (prefers-color-scheme: dark) {
    .setting-section span[id$="-value"] {
      border-color: #fff;
      background: #333;
    }
  }
}