/* Theme: Midnight (default) */
:root[data-theme="midnight"],
:root {
  --bg: #0f131a;
  --bg-gradient-start: #162238;
  --panel: #19202b;
  --panel-gradient: #1c2533;
  --text: #e9eef9;
  --muted: #9db0cc;
  --accent: #66d4ff;
  --accent-hover: #7fddff;
  --accent-active: #4dc9ff;
  --warn: #ffbd6b;
  --error: #ff8f8f;
  --success: #8ef0bf;
  --border: #2e3f56;
  --input-bg: #0f1724;
  --link: #66d4ff;
  --link-hover: #8fe4ff;
  --link-visited: #a8b8ff;
}

/* Theme: Twitch */
:root[data-theme="twitch"] {
  --bg: #0e0e10;
  --bg-gradient-start: #18181b;
  --panel: #18181b;
  --panel-gradient: #1f1f23;
  --text: #efeff1;
  --muted: #adadb8;
  --accent: #9147ff;
  --accent-hover: #a970ff;
  --accent-active: #772ce8;
  --warn: #f1c40f;
  --error: #ec4646;
  --success: #00f593;
  --border: #464649;
  --input-bg: #0e0e10;
  --link: #bf94ff;
  --link-hover: #d4b5ff;
  --link-visited: #a87dff;
}

/* Theme: Red */
:root[data-theme="red"] {
  --bg: #1a0f0f;
  --bg-gradient-start: #2b1515;
  --panel: #2b1919;
  --panel-gradient: #331f1f;
  --text: #f9e9e9;
  --muted: #ccb0b0;
  --accent: #ff4466;
  --accent-hover: #ff6682;
  --accent-active: #e6334d;
  --warn: #ffaa44;
  --error: #ff6666;
  --success: #66ff99;
  --border: #4d2e2e;
  --input-bg: #1f0f0f;
  --link: #ff6680;
  --link-hover: #ff8fa3;
  --link-visited: #ff99aa;
}

/* Theme: Forest */
:root[data-theme="forest"] {
  --bg: #0f1a0f;
  --bg-gradient-start: #1a2b1a;
  --panel: #1a2b1a;
  --panel-gradient: #1f331f;
  --text: #e9f9e9;
  --muted: #b0ccb0;
  --accent: #44ff66;
  --accent-hover: #66ff82;
  --accent-active: #33e64d;
  --warn: #ffcc44;
  --error: #ff6666;
  --success: #66ff99;
  --border: #2e4d2e;
  --input-bg: #0f1f0f;
  --link: #66ff80;
  --link-hover: #8fffa3;
  --link-visited: #99ffaa;
}

/* Theme: Ocean */
:root[data-theme="ocean"] {
  --bg: #0a0f14;
  --bg-gradient-start: #0f1a24;
  --panel: #0f1a26;
  --panel-gradient: #14202e;
  --text: #e0f2ff;
  --muted: #99c2d9;
  --accent: #00b4d8;
  --accent-hover: #33c5e3;
  --accent-active: #0096b8;
  --warn: #f4a261;
  --error: #e76f51;
  --success: #2a9d8f;
  --border: #1e3a52;
  --input-bg: #0a141f;
  --link: #48cae4;
  --link-hover: #90e0ef;
  --link-visited: #ade8f4;
}

/* Theme: Sunset */
:root[data-theme="sunset"] {
  --bg: #1a0f14;
  --bg-gradient-start: #2b1524;
  --panel: #2b1a26;
  --panel-gradient: #33202e;
  --text: #ffe9f2;
  --muted: #d9b3cc;
  --accent: #ff6b9d;
  --accent-hover: #ff8fb3;
  --accent-active: #e64d7f;
  --warn: #ffb347;
  --error: #ff6b6b;
  --success: #6bffb3;
  --border: #4d2e3a;
  --input-bg: #1f0f1a;
  --link: #ff80b3;
  --link-hover: #ffb3d1;
  --link-visited: #ffc7e0;
}

* {
  box-sizing: border-box;
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices */
  button:hover,
  a:hover,
  summary:hover {
    /* Use active state instead on touch */
  }

  /* Larger tap targets on touch devices */
  button,
  select,
  input {
    min-height: 48px;
  }

  /* Prevent text selection on buttons */
  button,
  .state-badge,
  .user-menu-btn {
    -webkit-user-select: none;
    user-select: none;
  }

  /* Smooth scrolling on touch */
  html {
    -webkit-overflow-scrolling: touch;
  }
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% 0%, var(--bg-gradient-start), var(--bg) 45%);
  color: var(--text);
  transition: background 0.3s ease, color 0.3s ease;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

a:visited {
  color: var(--link-visited);
}

a:active {
  color: var(--accent-active);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.site-header h1 {
  margin: 0;
  font-size: 1.35rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}

/* User menu dropdown */
.user-menu {
  position: relative;
}

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  list-style: none;
}

.user-menu-btn::-webkit-details-marker {
  display: none;
}

.user-menu-btn:hover {
  background: var(--panel-gradient);
  border-color: var(--accent);
}

.username-display {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.menu-arrow {
  font-size: 0.7rem;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.user-menu[open] .menu-arrow {
  transform: rotate(180deg);
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 280px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
}

.user-menu-section {
  padding: 0.65rem;
  margin-bottom: 0.5rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.15);
}

.user-menu-section:last-child {
  margin-bottom: 0;
  background: rgba(0, 0, 0, 0.2);
}

.user-menu-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 0.4rem 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.user-menu-username {
  font-size: 1rem;
  color: var(--text);
  margin: 0;
  font-weight: 600;
}

.user-menu-warning {
  background: rgba(255, 193, 7, 0.15);
  border-left: 3px solid var(--warn);
  padding: 0.5rem;
  margin: 0.5rem 0;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--warn);
}

.user-menu-theme-select {
  width: 100%;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}

.user-menu-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.user-menu-form input {
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  width: 100%;
}

.user-menu-form button {
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

.logout-btn {
  width: 100%;
  background: var(--error);
  color: var(--text);
  padding: 0.5rem;
  font-size: 0.85rem;
}

.logout-btn:hover {
  background: #ff6666;
}

main {
  padding: 0.75rem;
}

.grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.span-2 {
  grid-column: span 2;
}

.span-3 {
  grid-column: span 3;
}

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-6 {
  grid-column: span 6;
}

.span-7 {
  grid-column: span 7;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: span 12;
}

.row-span-2 {
  grid-row: span 2;
}

.card {
  background: linear-gradient(165deg, var(--panel-gradient), var(--panel));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.card h2 {
  margin: 0 0 0.65rem 0;
  font-size: 1.15rem;
  color: var(--text);
}

.card h3 {
  margin: 0.85rem 0 0.5rem 0;
  font-size: 1rem;
  color: var(--text);
  padding: 0.65rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
}

.card.narrow {
  max-width: 440px;
  margin: 2rem auto;
}

.form-grid {
  display: grid;
  gap: 0.6rem;
}

.form-grid label {
  display: block;
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

.form-grid input,
.form-grid select {
  margin-top: 0.25rem;
}

.button-row {
  display: grid;
  gap: 0.4rem;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 0.65rem;
}

input,
button,
select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  transition: border-color 0.2s ease, background 0.2s ease;
}

input,
select {
  background: var(--input-bg);
  color: var(--text);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  background: var(--accent);
  color: #071420;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-hover);
}

button:active {
  background: var(--accent-active);
}

dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 0.65rem;
  margin: 0.5rem 0;
  font-size: 0.9rem;
}

dt {
  color: var(--muted);
  font-weight: 500;
}

dd {
  margin: 0;
}

ul {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
}

li {
  margin: 0.2rem 0;
  font-size: 0.9rem;
}

li a {
  margin-left: 0.4rem;
}

.path-value {
  overflow-wrap: anywhere;
  color: #bed1f5;
  font-size: 0.85rem;
  font-family: "Courier New", monospace;
}

.state-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-weight: 700;
  font-size: 0.8rem;
}

.state-badge-large {
  padding: 0.4rem 1rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.state-badge.ok {
  background: rgba(40, 170, 95, 0.2);
  color: #9ef4be;
  border: 1px solid rgba(78, 208, 129, 0.45);
}

.state-badge.bad {
  background: rgba(200, 52, 52, 0.22);
  color: #ffb3b3;
  border: 1px solid rgba(255, 132, 132, 0.55);
}

.state-badge.warn {
  background: rgba(196, 146, 42, 0.22);
  color: #ffd694;
  border: 1px solid rgba(247, 189, 70, 0.55);
}

.state-badge.unknown {
  background: rgba(117, 117, 117, 0.25);
  color: #d8d8d8;
  border: 1px solid rgba(160, 160, 160, 0.45);
}

.world-list {
  list-style: none;
  margin: 0.4rem 0;
  padding: 0;
}

.world-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0.5rem 0;
  padding: 0.65rem;
  background: rgba(11, 16, 25, 0.35);
  transition: background 0.2s ease;
}

.world-item:hover {
  background: rgba(11, 16, 25, 0.5);
}

.world-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.file-pair {
  margin-top: 0.4rem;
  display: grid;
  gap: 0.2rem;
  font-size: 0.85rem;
}

.label {
  display: inline-block;
  min-width: 2.5rem;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.75rem;
}

.map-placeholder {
  margin-top: 0.6rem;
  min-height: 220px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.7rem;
  background: rgba(20, 28, 39, 0.45);
}

details {
  margin-top: 0.5rem;
}

summary {
  cursor: pointer;
  color: var(--link);
  font-size: 0.9rem;
  padding: 0.3rem 0;
  transition: color 0.2s ease;
}

summary:hover {
  color: var(--link-hover);
}

details[open] summary {
  margin-bottom: 0.4rem;
}

details ul {
  margin-top: 0.3rem;
  font-size: 0.85rem;
}

/* Tablet breakpoint */
@media (max-width: 1100px) {
  .span-2,
  .span-3,
  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8,
  .span-12 {
    grid-column: span 12;
  }

  .button-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-header {
    flex-direction: row;
    align-items: center;
  }

  .site-header h1 {
    font-size: 1.1rem;
  }

  .user-menu-dropdown {
    right: 0;
    min-width: 260px;
  }

  .world-upload-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile breakpoint */
@media (max-width: 768px) {
  /* Larger touch targets */
  button,
  input,
  select {
    min-height: 44px;
    padding: 0.65rem 0.75rem;
    font-size: 1rem;
  }

  /* Larger tap areas for links */
  a {
    padding: 0.25rem;
    margin: -0.25rem;
  }

  /* Stack service buttons vertically */
  .service-button-grid {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  /* Better mobile header */
  .site-header {
    padding: 0.5rem 0.75rem;
  }

  .site-header h1 {
    font-size: 1rem;
  }

  /* Mobile-friendly user menu */
  .user-menu-dropdown {
    position: fixed;
    top: auto;
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
    min-width: auto;
    max-height: 80vh;
    overflow-y: auto;
  }

  /* Larger cards spacing for easier scrolling */
  main {
    padding: 0.5rem;
  }

  .grid {
    gap: 0.6rem;
  }

  .card {
    padding: 0.75rem;
  }

  /* Mobile-optimized modifiers */
  .modifier-row {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }

  .modifier-row label {
    font-weight: 600;
  }

  /* Better mobile forms */
  .form-grid {
    gap: 0.75rem;
  }

  /* Larger join code on mobile */
  .join-code-value {
    font-size: 2.5rem;
    letter-spacing: 4px;
  }

  /* Mobile-friendly dl */
  dl {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  dt {
    font-weight: 600;
    margin-top: 0.5rem;
  }

  dt:first-child {
    margin-top: 0;
  }
}

/* Small mobile breakpoint */
@media (max-width: 480px) {
  /* Even larger touch targets */
  button {
    min-height: 48px;
    font-size: 1.05rem;
  }

  /* Compact header for small screens */
  .site-header h1 {
    font-size: 0.9rem;
  }

  /* Full-width user menu on tiny screens */
  .user-menu-dropdown {
    left: 0;
    right: 0;
    border-radius: 0;
  }

  /* Larger text for readability */
  body {
    font-size: 16px;
  }

  .card h2 {
    font-size: 1.1rem;
  }

  /* Stack world upload grid */
  .world-upload-grid {
    gap: 1rem;
  }
}

.muted {
  color: var(--muted);
}

.warn {
  color: var(--warn);
}

.flash-stack {
  padding: 0 0.75rem;
}

.flash {
  margin-top: 0.5rem;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.flash.error {
  color: var(--error);
  background: rgba(255, 100, 100, 0.1);
}

.flash.success {
  color: var(--success);
  background: rgba(100, 255, 150, 0.1);
}

.flash.warning {
  color: var(--warn);
  background: rgba(255, 180, 100, 0.1);
}

/* Checkbox alignment fixes */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0;
}

.checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.checkbox-row label {
  margin: 0;
  cursor: pointer;
  font-weight: normal;
  color: var(--text);
  font-size: 0.9rem;
}

/* Compact modifiers section */
.modifiers-grid {
  display: grid;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.modifier-row {
  display: grid;
  grid-template-columns: 35% 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
}

.modifier-row label {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

.modifier-row select {
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}

/* Restart warning banner */
.restart-warning {
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.15), rgba(255, 152, 0, 0.1));
  border-left: 4px solid var(--warn);
  padding: 0.65rem;
  margin: 0.5rem 0;
  border-radius: 6px;
  font-size: 0.85rem;
}

.restart-warning strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

/* Compact backups list */
details ul li {
  padding: 0.15rem 0;
}

details ul li .path-value {
  font-size: 0.8rem;
}

details ul li .muted {
  font-size: 0.75rem;
}

/* Loading states */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: button-spin 0.6s linear infinite;
  color: var(--text);
}

@keyframes button-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Page loading overlay */
.page-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.page-loading .spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spinner-spin 0.8s linear infinite;
}

@keyframes spinner-spin {
  to {
    transform: rotate(360deg);
  }
}

.page-loading .loading-text {
  position: absolute;
  margin-top: 80px;
  color: var(--text);
  font-size: 0.9rem;
}

/* Skeleton loading for cards */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--panel) 0%,
    var(--panel-gradient) 50%,
    var(--panel) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-text {
  height: 1em;
  margin: 0.5em 0;
}

.skeleton-title {
  height: 1.5em;
  width: 60%;
  margin-bottom: 1em;
}

.skeleton-button {
  height: 2.5em;
  width: 120px;
}

/* World action sections */
.world-upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.world-action-section {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 8px;
  border-left-width: 3px;
}

.world-upload-grid .world-action-section {
  margin-top: 0;
}

.world-action-section .section-title {
  margin: 0 0 0.3rem 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.world-action-section .section-desc {
  margin: 0 0 0.6rem 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}

.world-action-section.world-action-create {
  border-left-color: var(--success);
  background: rgba(100, 255, 150, 0.05);
}

.world-action-section.world-action-upload-zip {
  border-left-color: var(--accent);
  background: rgba(100, 180, 255, 0.05);
}

.world-action-section.world-action-upload-raw {
  border-left-color: var(--warn);
  background: rgba(255, 180, 100, 0.05);
}

.required {
  color: var(--error);
  font-weight: bold;
}

/* Random seed toggle */
.seed-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: end;
}

.seed-input-row label {
  margin: 0;
}

.seed-random-btn {
  padding: 0.5rem 0.75rem;
  white-space: nowrap;
  font-size: 0.85rem;
}

/* Compact path settings */
.compact-dl {
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.compact-dl dt {
  font-size: 0.8rem;
}

.compact-dl dd {
  font-size: 0.8rem;
  margin-bottom: 0.15rem;
}

.path-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.path-edit-toggle summary {
  display: inline-block;
  padding: 0.5rem 0.65rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s ease;
}

.path-edit-toggle summary:hover {
  background: var(--panel-gradient);
  border-color: var(--accent);
}

.path-edit-toggle[open] summary {
  margin-bottom: 0.75rem;
  background: var(--panel-gradient);
}

/* Service section redesign */
.service-status-display {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 0;
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.service-status-main {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.25);
}

.service-status-secondary {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.15);
}

.service-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.join-code-display {
  background: linear-gradient(135deg, rgba(100, 255, 150, 0.15), rgba(100, 200, 255, 0.1));
  border: 2px solid var(--success);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.join-code-display:hover {
  background: linear-gradient(135deg, rgba(100, 255, 150, 0.25), rgba(100, 200, 255, 0.2));
  border-color: #9ef4be;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(100, 255, 150, 0.3);
}

.join-code-display:active {
  transform: translateY(0);
}

.join-code-display.copied {
  background: linear-gradient(135deg, rgba(100, 255, 150, 0.3), rgba(100, 200, 255, 0.25));
  border-color: var(--success);
}

.join-code-label {
  margin-bottom: 0.5rem;
}

.join-code-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--success);
  letter-spacing: 3px;
  font-family: 'Courier New', monospace;
  margin: 0.25rem 0;
}

.join-code-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.service-info-box {
  background: rgba(100, 255, 150, 0.1);
  border: 1px solid var(--success);
  border-radius: 6px;
  padding: 0.6rem;
  margin-bottom: 0.75rem;
}

.service-controls {
  margin-top: 0.5rem;
}

.service-name {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.25rem 0;
  font-family: 'Courier New', monospace;
}

.service-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.75rem 0;
  font-style: italic;
}

.service-control-group {
  padding: 0.65rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.15);
  margin-bottom: 0.65rem;
}

.service-control-group:last-child {
  margin-bottom: 0;
  background: rgba(0, 0, 0, 0.2);
}

.control-group-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.service-button-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.service-button-grid button {
  padding: 0.5rem 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.btn-start {
  background: var(--success);
  color: #0a3a1f;
}

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

.btn-stop {
  background: var(--error);
  color: #2a0a0a;
}

.btn-stop:hover {
  background: #ffb3b3;
}

.btn-restart {
  background: var(--warn);
  color: #3a2a0a;
}

.btn-restart:hover {
  background: #ffd699;
}

.btn-enable,
.btn-disable {
  background: var(--accent);
  color: #071420;
}

.btn-enable:hover,
.btn-disable:hover {
  background: var(--accent-hover);
}

/* Active World Controls */
.active-world-form {
  margin-bottom: 1rem;
}

.active-world-controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 1rem;
  align-items: end;
}

.active-world-controls .control-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.active-world-controls .control-row label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.active-world-controls select,
.active-world-controls input {
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
}

.world-select-row {
  display: flex;
  gap: 0.5rem;
}

.world-select-row select {
  flex: 1;
}

.btn-new-world {
  padding: 0.6rem 0.75rem;
  white-space: nowrap;
  background: var(--panel);
  color: var(--accent);
  border: 1px solid var(--accent);
  font-weight: 600;
  width: auto;
}

.btn-new-world:hover {
  background: var(--accent);
  color: var(--bg);
}

.new-world-inline {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  align-items: center;
}

.new-world-inline input {
  flex: 1;
  padding: 0.5rem 0.75rem;
}

.new-world-inline button {
  width: auto;
  padding: 0.5rem 0.75rem;
  white-space: nowrap;
}

.btn-random {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-random:hover {
  color: var(--text);
  border-color: var(--accent);
}

.btn-create-world {
  background: var(--success);
  color: #0a2a1a;
}

.btn-create-world:hover {
  background: #a8f5cb;
}

.btn-cancel {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-cancel:hover {
  color: var(--error);
  border-color: var(--error);
}

.btn-apply {
  padding: 0.6rem 1.25rem;
  white-space: nowrap;
  background: var(--success);
  color: #0a2a1a;
  font-weight: 700;
}

.btn-apply:hover {
  background: #a8f5cb;
}

/* World details sections */
.world-details-section {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.world-details-section summary {
  font-weight: 500;
}

.world-list-compact {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

.world-list-compact li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  margin: 0;
}

.world-list-compact li:nth-child(odd) {
  background: rgba(0, 0, 0, 0.15);
}

.world-list-compact .world-name {
  font-weight: 500;
}

.world-list-compact .active-badge {
  font-size: 0.7rem;
  background: var(--success);
  color: #0a2a1a;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-left: 0.5rem;
  font-weight: 700;
  text-transform: uppercase;
}

.world-list-compact .download-link {
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
}

.world-list-compact .download-link:hover {
  text-decoration: underline;
}

/* World table */
.world-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.world-table th:nth-child(1),
.world-table td:nth-child(1) {
  width: 50%;
}

.world-table th:nth-child(2),
.world-table td:nth-child(2) {
  width: 15%;
}

.world-table th:nth-child(3),
.world-table td:nth-child(3) {
  width: 35%;
}

.world-table th,
.world-table td {
  padding: 0.4rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.world-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.world-table tbody tr:hover {
  background: rgba(0, 0, 0, 0.15);
}

.world-table .world-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.world-table .backup-count {
  text-align: center;
  color: var(--muted);
}

.world-table .world-actions {
  text-align: right;
}

.btn-small {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 4px;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--accent);
  cursor: pointer;
  margin-left: 0.2rem;
  width: auto;
}

.btn-small:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.btn-small.btn-danger {
  color: var(--error);
  border-color: var(--error);
  background: transparent;
}

.btn-small.btn-danger:hover {
  background: var(--error);
  color: #2a0a0a;
}

/* Compact Service Card */
.service-status-compact {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.status-badge {
  display: block;
  text-align: center;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-badge.ok {
  background: rgba(40, 170, 95, 0.2);
  color: #9ef4be;
  border: 1px solid rgba(78, 208, 129, 0.45);
}

.status-badge.bad {
  background: rgba(200, 52, 52, 0.22);
  color: #ffb3b3;
  border: 1px solid rgba(255, 132, 132, 0.55);
}

.status-badge.warn {
  background: rgba(196, 146, 42, 0.22);
  color: #ffd694;
  border: 1px solid rgba(247, 189, 70, 0.55);
}

.status-badge.unknown {
  background: rgba(117, 117, 117, 0.25);
  color: #d8d8d8;
  border: 1px solid rgba(160, 160, 160, 0.45);
}

.join-code-box {
  position: relative;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  padding: 0.6rem 0.5rem 0.4rem;
  border-radius: 4px;
  margin-bottom: 0.75rem;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s;
}

.join-code-box:hover {
  border-color: var(--accent);
}

.join-code-box .join-code-label {
  position: absolute;
  top: 0.2rem;
  left: 0.4rem;
  font-size: 0.6rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.join-code-box .join-code-value {
  display: block;
  font-family: monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: 0.2rem;
}

.join-code-box .join-code-hint {
  display: block;
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.service-buttons-compact {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.service-buttons-compact button {
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
}

/* Compact World Settings */
.modifiers-compact {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.modifier-row-compact {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modifier-row-compact label {
  width: 50px;
  font-size: 0.8rem;
  color: var(--muted);
}

.modifier-row-compact select {
  flex: 1;
  padding: 0.3rem 0.4rem;
  font-size: 0.85rem;
}

.modifier-checkboxes {
  display: flex;
  gap: 1rem;
  margin: 0.25rem 0;
}

.modifier-checkboxes label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
}

.modifier-checkboxes input {
  width: auto;
}

.modifiers-compact button {
  margin-top: 0.25rem;
  padding: 0.4rem;
  font-size: 0.85rem;
}

/* Compact Mods */
.mods-install-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mod-install-form {
  display: flex;
  gap: 0.4rem;
}

.mod-install-form input {
  flex: 1;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}

.mod-install-form button {
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  white-space: nowrap;
  width: auto;
}

.mods-list {
  font-size: 0.8rem;
  max-height: 150px;
  overflow-y: auto;
}

.mods-compact-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.mods-compact-form input {
  font-size: 0.8rem;
  padding: 0.3rem;
}

.mods-compact-form button {
  font-size: 0.8rem;
  padding: 0.35rem;
}

@media (max-width: 768px) {
  .active-world-controls {
    grid-template-columns: 1fr;
  }

  .btn-apply {
    width: 100%;
  }
}
