*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: transparent;
  font-family: system-ui, -apple-system, sans-serif;
}

#wheel-canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  width: min(520px, 90vw);
  max-height: 85vh;
  background: #1e1e2e;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #e0e0e0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}

.btn-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: #999;
  font-size: 22px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.btn-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.setting-group {
  margin-bottom: 20px;
}

.setting-group:last-child {
  margin-bottom: 0;
}

.setting-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888;
  margin-bottom: 6px;
}

.setting-description {
  font-size: 11px;
  color: #666;
  margin-top: 4px;
}

select, input[type="text"], input[type="number"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: #13131f;
  color: #e0e0e0;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s;
}

select:focus, input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.3);
}

input[type="range"] {
  width: 100%;
  margin-top: 6px;
  accent-color: #7c6ff7;
}

input[type="checkbox"] {
  accent-color: #7c6ff7;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-row input[type="range"] {
  flex: 1;
}

.range-value {
  min-width: 40px;
  text-align: right;
  font-size: 13px;
  color: #aaa;
  font-variant-numeric: tabular-nums;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.checkbox-row label {
  font-size: 13px;
  cursor: pointer;
}

.btn {
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #7c6ff7;
  color: #fff;
}

.btn-primary:hover {
  background: #6a5dd6;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: #ccc;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
  background: rgba(220, 53, 69, 0.2);
  color: #f87171;
  border: 1px solid rgba(220, 53, 69, 0.3);
}

.btn-danger:hover {
  background: rgba(220, 53, 69, 0.35);
}

.btn-small {
  padding: 4px 10px;
  font-size: 11px;
}

.accordion {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  user-select: none;
  transition: background 0.15s;
}

.accordion-header:hover {
  background: rgba(255, 255, 255, 0.06);
}

.accordion-arrow {
  font-size: 10px;
  transition: transform 0.2s;
  color: #777;
}

.accordion.open .accordion-arrow {
  transform: rotate(180deg);
}

.accordion-body {
  display: none;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.accordion.open .accordion-body {
  display: block;
}

.segment-table {
  width: 100%;
  border-collapse: collapse;
}

.segment-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
  font-weight: 600;
  padding-bottom: 8px;
  text-align: left;
}

.segment-table th:last-child {
  width: 32px;
}

.segment-table td {
  padding: 4px 0;
}

.segment-table input {
  width: 100%;
  padding: 6px 10px;
}

.segment-table input[type="number"] {
  width: 80px;
}

.segment-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.segment-row input[type="text"] {
  flex: 1;
}

.segment-row input[type="number"] {
  width: 70px;
  flex: none;
}

.segment-row .btn-danger {
  flex: none;
  font-size: 11px;
  padding: 4px 8px;
  min-width: 28px;
}

.add-segment-row {
  margin-top: 8px;
}

.side-panel {
  position: fixed;
  top: 12px;
  left: 12px;
  bottom: 12px;
  width: 23vw;
  max-width: 340px;
  min-width: 200px;
  background: rgba(20, 20, 30, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 50;
  backdrop-filter: blur(6px);
}

.panel-section {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-section-last {
  flex: 1;
  min-height: 0;
}

.panel-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.panel-header {
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  color: #bbb;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.panel-subtitle {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: #888;
  text-transform: none;
  letter-spacing: 0;
  margin-top: 1px;
}

.panel-body {
  padding: 6px 9px 7px;
  font-size: 12px;
  color: #ccc;
  line-height: 1.6;
  flex-shrink: 0;
}

.panel-body::before {
  content: '';
  display: block;
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 0 0 6px 0;
}

.panel-body-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 2px 0;
}

.panel-body-scroll::before {
  display: none;
}

.btn-caos {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px 8px;
  border: none;
  border-radius: 6px;
  background-image: url('https://cdn.7tv.app/emote/01G2R1H6H00004JR3T5PESPGBA/4x.avif');
  background-size: cover;
  background-position: center calc(50% - 20px);
  color: #fff;
  font-size: 19px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 2px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8), 0 0 8px rgba(0,0,0,0.6);
  transition: transform 0.1s, box-shadow 0.15s;
  min-height: 80px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.btn-caos > * {
  position: relative;
  z-index: 1;
}

.btn-caos::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  transition: background 0.3s;
  z-index: 0;
}

.btn-caos.active::after {
  background: rgba(0, 0, 0, 0);
}

.btn-caos:hover {
  transform: scale(1.03);
  box-shadow: 0 0 20px rgba(255,106,0,0.6);
}

.btn-caos:active {
  transform: scale(0.97);
}

.caos-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  background: #000;
}

.caos-overlay.show {
  opacity: 1;
}

.spin-locked {
  pointer-events: none;
  opacity: 0.4;
}

.panel-body-scroll::-webkit-scrollbar {
  width: 4px;
}

.panel-body-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.panel-body-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
}

.rule-line {
  display: block;
}

.log-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 6px 12px;
  font-size: 13px;
  color: #ccc;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  animation: logFadeIn 0.2s ease;
}

.log-item:last-child {
  border-bottom: none;
}

.log-item-content {
  flex: 1;
  min-width: 0;
}

.log-item-label {
  display: block;
  word-break: break-word;
  line-height: 1.4;
}

.log-item-time {
  display: block;
  font-size: 10px;
  color: #888;
  margin-top: 2px;
}

.log-item-dismiss {
  border: none;
  background: none;
  color: #666;
  font-size: 16px;
  cursor: pointer;
  padding: 0 0 0 10px;
  line-height: 1;
  transition: color 0.15s;
  flex-shrink: 0;
}

.log-item-dismiss:hover {
  color: #f55;
}

.log-empty {
  text-align: center;
  color: #555;
  font-size: 12px;
  padding: 16px 10px;
}

@keyframes logFadeIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}
