:root {
  color-scheme: light;
  --ios-blue: #007AFF;
  --ios-red: #FF3B30;
  --ios-green: #34C759;
  --ios-orange: #FF9500;
  --ios-purple: #AF52DE;
  --ios-pink: #FF2D55;

  --ios-background: #F2F2F7;
  --ios-background-secondary: #FFFFFF;
  --ios-background-grouped: #E5E5EA;

  --ios-label: #000000;
  --ios-secondary-label: #3C3C43;
  --ios-tertiary-label: #8E8E93;
  --ios-quaternary-label: #AEAEB2;

  --ios-separator: #C6C6C8;
  --ios-opaque-separator: #D1D1D6;

  --ios-fill: #767680;
  --ios-secondary-fill: #EBEBF0;
  --ios-tertiary-fill: #F5F5F8;

  --ios-shadow: rgba(0, 0, 0, 0.1);
  --ios-shadow-strong: rgba(0, 0, 0, 0.2);

  --ios-chrome-bg: rgba(242, 242, 247, 0.92);

  --ios-font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', sans-serif;
  --ios-font-weight-regular: 400;
  --ios-font-weight-medium: 500;
  --ios-font-weight-semibold: 600;
  --ios-font-weight-bold: 700;

  --ios-spacing-xs: 4px;
  --ios-spacing-s: 8px;
  --ios-spacing-m: 16px;
  --ios-spacing-l: 20px;
  --ios-spacing-xl: 24px;
  --ios-spacing-xxl: 32px;

  --ios-radius-s: 8px;
  --ios-radius-m: 12px;
  --ios-radius-l: 16px;
  --ios-radius-xl: 20px;
  --ios-radius-circle: 50%;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ios-background: #000000;
  --ios-background-secondary: #1C1C1E;
  --ios-background-grouped: #2C2C2E;

  --ios-label: #FFFFFF;
  --ios-secondary-label: #AEAEB2;
  --ios-tertiary-label: #8E8E93;
  --ios-quaternary-label: #636366;

  --ios-separator: #38383A;
  --ios-opaque-separator: #38383A;

  --ios-fill: #787880;
  --ios-secondary-fill: #2C2C2E;
  --ios-tertiary-fill: #3A3A3C;

  --ios-shadow: rgba(0, 0, 0, 0.6);
  --ios-shadow-strong: rgba(0, 0, 0, 0.85);

  --ios-chrome-bg: rgba(28, 28, 30, 0.85);
}

.theme-toggle-btn {
  position: fixed;
  bottom: 100px;
  right: 16px;
  z-index: 1500;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--ios-separator);
  background: var(--ios-background-secondary);
  box-shadow: 0 2px 8px var(--ios-shadow);
  font-size: 19px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle-btn:active { opacity: 0.7; transform: scale(0.95); }
body:not(.has-tabbar) .theme-toggle-btn { bottom: 20px; }

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--ios-font);
  background: var(--ios-background);
  color: var(--ios-label);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}

body.has-navbar { padding-top: 44px; }
body.has-tabbar { padding-bottom: 83px; }

a { color: inherit; text-decoration: none; }

.nav-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 44px;
  background: var(--ios-chrome-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--ios-separator);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--ios-spacing-m);
  z-index: 1000;
}
.nav-bar-title { font-size: 17px; font-weight: var(--ios-font-weight-semibold); letter-spacing: -0.41px; }
.nav-bar-action { font-size: 17px; color: var(--ios-blue); background: none; border: none; cursor: pointer; }

.large-title {
  padding: var(--ios-spacing-l) var(--ios-spacing-m) var(--ios-spacing-s);
  font-size: 34px;
  font-weight: var(--ios-font-weight-bold);
  letter-spacing: 0.37px;
}
.large-title-subtitle {
  padding: 0 var(--ios-spacing-m) var(--ios-spacing-m);
  color: var(--ios-secondary-label);
  font-size: 15px;
}

.tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 83px;
  background: var(--ios-chrome-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--ios-separator);
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  padding-top: 8px;
  z-index: 1000;
}
.tab-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; cursor: pointer;
  padding: 0 12px;
  color: var(--ios-tertiary-label);
  transition: color 0.2s;
}
.tab-item.active { color: var(--ios-blue); }
.tab-item svg { width: 26px; height: 26px; }
.tab-item span { font-size: 10px; font-weight: var(--ios-font-weight-medium); letter-spacing: 0.24px; }

.ios-card {
  background: var(--ios-background-secondary);
  border-radius: var(--ios-radius-l);
  box-shadow: 0 2px 8px var(--ios-shadow);
  margin: var(--ios-spacing-m);
  padding: var(--ios-spacing-l);
  transition: transform 0.15s;
}
.ios-card:active { transform: scale(0.98); }
.ios-card h3 { font-size: 17px; font-weight: var(--ios-font-weight-semibold); margin-bottom: 4px; }
.ios-card p { color: var(--ios-secondary-label); font-size: 14px; }

.ios-button {
  background: var(--ios-blue);
  color: white;
  border: none;
  border-radius: var(--ios-radius-m);
  padding: 12px 24px;
  font-size: 17px;
  font-weight: var(--ios-font-weight-semibold);
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  display: block;
  text-align: center;
}
.ios-button:active { opacity: 0.7; transform: scale(0.97); }
.ios-button.danger { background: var(--ios-red); }
.ios-button.success { background: var(--ios-green); }
.ios-button.small { padding: 8px 16px; font-size: 15px; width: auto; display: inline-block; margin: 0; }
.ios-button.outline { background: transparent; color: var(--ios-blue); border: 2px solid var(--ios-blue); }
.ios-button:disabled { opacity: 0.4; cursor: not-allowed; }

.ios-input, select.ios-input, textarea.ios-input {
  background: var(--ios-background-secondary);
  color: var(--ios-label);
  border: 1px solid var(--ios-separator);
  border-radius: var(--ios-radius-m);
  padding: 12px 16px;
  font-size: 17px;
  font-family: var(--ios-font);
  width: 100%;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.ios-input:focus { outline: none; border-color: var(--ios-blue); }
.ios-input::placeholder { color: var(--ios-tertiary-label); opacity: 1; }
select.ios-input option { background: var(--ios-background-secondary); color: var(--ios-label); }
.ios-form-group { margin-bottom: var(--ios-spacing-m); }
.ios-form-group label { display: block; font-size: 13px; color: var(--ios-secondary-label); margin-bottom: 6px; }

.ios-toggle { position: relative; display: inline-block; width: 51px; height: 31px; }
.ios-toggle input { opacity: 0; width: 0; height: 0; }
.ios-toggle-slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--ios-tertiary-label); transition: 0.3s; border-radius: 31px;
}
.ios-toggle-slider:before {
  position: absolute; content: ""; height: 27px; width: 27px; left: 2px; bottom: 2px;
  background: white; transition: 0.3s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.ios-toggle input:checked + .ios-toggle-slider { background: var(--ios-green); }
.ios-toggle input:checked + .ios-toggle-slider:before { transform: translateX(20px); }

.ios-badge {
  display: inline-block; padding: 3px 10px; border-radius: 100px;
  font-size: 12px; font-weight: var(--ios-font-weight-semibold);
  background: var(--ios-secondary-fill); color: var(--ios-secondary-label);
}
.ios-badge.online { background: rgba(52,199,89,0.15); color: var(--ios-green); }
.ios-badge.offline { background: rgba(142,142,147,0.15); color: var(--ios-tertiary-label); }

.ios-list { background: var(--ios-background-secondary); border-radius: var(--ios-radius-l); margin: var(--ios-spacing-m); overflow: hidden; }
.ios-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px var(--ios-spacing-l);
  border-bottom: 1px solid var(--ios-separator);
}
.ios-list-item:last-child { border-bottom: none; }

.ios-alert {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.4); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: var(--ios-radius-xl); padding: var(--ios-spacing-xl);
  max-width: 320px; width: 90%; z-index: 2000; animation: iosAlertIn 0.25s ease;
}
.ios-alert-content { background: var(--ios-background-secondary); color: var(--ios-label); border-radius: var(--ios-radius-m); padding: var(--ios-spacing-l); text-align: center; }
.ios-alert-title { font-size: 17px; font-weight: var(--ios-font-weight-bold); margin-bottom: var(--ios-spacing-xs); }
.ios-alert-message { font-size: 13px; color: var(--ios-secondary-label); margin-bottom: var(--ios-spacing-l); }
.ios-alert-actions { display: flex; gap: 8px; justify-content: center; }
.ios-alert-actions button { flex: 1; padding: 8px 16px; border: none; border-radius: var(--ios-radius-s); font-size: 17px; font-weight: var(--ios-font-weight-semibold); cursor: pointer; }
.ios-alert-actions .cancel { background: var(--ios-background); color: var(--ios-blue); }
.ios-alert-actions .confirm { background: var(--ios-blue); color: white; }
@keyframes iosAlertIn { from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.85); color: white; padding: 10px 20px; border-radius: 100px;
  font-size: 14px; z-index: 3000; animation: toastIn 0.2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.connection-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ios-tertiary-label); display: inline-block; margin-right: 6px; }
.connection-dot.connected { background: var(--ios-green); }
.connection-dot.disconnected { background: var(--ios-red); }

.empty-state { text-align: center; padding: var(--ios-spacing-xxl) var(--ios-spacing-l); color: var(--ios-tertiary-label); }

/* Ruleta — rueda giratoria real */
.wheel-outer {
  position: relative;
  width: 260px;
  height: 260px;
  margin: 0 auto;
}
.wheel-outer.wheel-large { width: 380px; height: 380px; }
.wheel-pointer {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 30px;
  line-height: 1;
  color: #1C1C1E;
  z-index: 10;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5));
}
.wheel-disc {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  position: relative;
  box-shadow: 0 4px 24px rgba(0,0,0,0.35);
  border: 6px solid #fff;
}
.wheel-hub {
  position: absolute;
  top: 50%; left: 50%;
  width: 34px; height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.wheel-label {
  position: absolute;
  top: 50%; left: 50%;
  width: 50%;
  height: 0;
  transform-origin: 0 0;
  pointer-events: none;
}
.wheel-label span {
  position: absolute;
  left: 16%;
  top: -8px;
  display: inline-block;
  max-width: 40%;
  font-size: 10px;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wheel-outer.wheel-large .wheel-label span { font-size: 13px; max-width: 42%; }
.wheel-empty { text-align: center; color: var(--ios-tertiary-label); padding: var(--ios-spacing-xl); }
