:root {
  --panel-bg: rgba(16, 18, 24, 0.82);
  --panel-border: rgba(255, 255, 255, 0.18);
  --field-bg: rgba(255, 255, 255, 0.1);
  --field-border: rgba(255, 255, 255, 0.2);
  --text: #f7f7f7;
  --muted: rgba(255, 255, 255, 0.66);
  --gold: #ffcc00;
  --danger: #ff5a3c;
  --slot-card-width: 180px;
  --slot-card-height: 120px;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: transparent;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: transparent;
  perspective: none;
}

#slot-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
}

.slot-card {
  position: relative;
  overflow: hidden;
  width: var(--slot-card-width);
  height: var(--slot-card-height);
  border-radius: 18px;
  background:
    linear-gradient(
      135deg,
      rgb(114 115 255 / 33%),
      rgb(209 217 255 / 46%)
    );
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  text-align: center;
  font-weight: bold;
  box-shadow:
    0 0 20px rgba(255, 255, 255, 0.08),
    inset 0 0 15px rgba(255, 255, 255, 0.05);
  transition:
    opacity 0.15s linear,
    visibility 0.15s linear;
  user-select: none;
  backface-visibility: hidden;
  will-change: transform;
}

.slot-card::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background-image: var(--slot-bg-image);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  transition: opacity 0.15s linear;
}

.slot-card.has-image::before {
  opacity: 1;
}

.slot-card.active {
  border-color: #ffe082;
  box-shadow:
    0 0 30px rgba(255, 215, 0, 0.6),
    inset 0 0 20px rgba(255, 255, 255, 0.15);
}

.slot-card.has-image {
  background:
    linear-gradient(
      135deg,
      #5069ff73,
      #8805ff33
    );
}

.slot-label {
  position: relative;
  z-index: 1;
  display: block;
  max-width: 100%;
  padding: 0 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow:
    0 2px 8px rgba(0, 0, 0, 0.82),
    0 0 14px rgba(0, 0, 0, 0.5);
}

.fade-mask {
  position: absolute;
  left: 0;
  width: 100%;
  height: 28%;
  z-index: 10;
  pointer-events: none;
  background: transparent;
}

.fade-mask.top {
  top: 0;
}

.fade-mask.bottom {
  bottom: 0;
}

.settings-panel {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  padding: 5px 0 5px 0;
  z-index: 30;
  width: 330px;
  max-width: calc(100vw - 78px);
  color: var(--text);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 0 8px 8px 0;
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.26);
  transition: transform 0.22s ease;
}

.settings-panel.collapsed {
  transform: translateX(calc(-100% - 10px));
}

.settings-resize {
  position: absolute;
  top: 0;
  right: -5px;
  bottom: 0;
  width: 10px;
  cursor: ew-resize;
}

.settings-panel.collapsed .settings-resize {
  display: none;
}

body.is-resizing-settings {
  user-select: none;
  cursor: ew-resize;
}

.settings-toggle {
  position: absolute;
  right: -62px;
  top: 18px;
  width: 54px;
  height: 38px;
  border-radius: 8px;
  color: #151515;
  background: var(--gold);
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
}

.settings-content {
  height: 100%;
  overflow: auto;
  padding: 16px;
  scrollbar-width: none;
}

.settings-content::-webkit-scrollbar {
  display: none;
}

.settings-section {
  display: grid;
  gap: 10px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

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

.settings-section h2 {
  font-size: 13px;
  color: var(--muted);
}

.section-header,
.item-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.mode-switch label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.mode-switch input {
  accent-color: var(--gold);
}

.item-list {
  display: grid;
  gap: 10px;
}

.content-switch-wrap {
  display: grid;
  gap: 8px;
}

.content-set-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
  gap: 6px;
}

.content-set-btn {
  height: 30px;
  min-width: 30px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
}

.content-set-btn.active {
  color: #121212;
  background: var(--gold);
  border-color: transparent;
}

.item-row {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.item-row:not(.expanded) {
  gap: 0;
}

.item-toggle {
  display: flex;
  align-items: center;
  min-height: 30px;
  flex: 1;
  padding: 0;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.item-row-title {
  color: var(--text);
  font-size: 12px;
  font-weight: bold;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-row-body {
  display: none;
  gap: 8px;
}

.item-row.expanded .item-row-body {
  display: grid;
}

.item-field,
.setting-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.reel-content-map {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
}

.reel-map-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
}

.reel-map-field input {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  padding: 7px 8px;
  color: var(--text);
  background: var(--field-bg);
  outline: none;
}

.config-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.config-actions .panel-button {
  width: 100%;
}

#load-config-file {
  display: none;
}

.item-field input,
.setting-field input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--field-bg);
  outline: none;
}

.image-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.image-upload {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  color: #111;
  background: var(--gold);
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
}

.image-file {
  display: none;
}

.item-field input:focus,
.setting-field input:focus {
  border-color: rgba(255, 204, 0, 0.72);
}

.probability-field {
  display: none;
}

html[data-spin-mode="probability"] .probability-field {
  display: grid;
}

.panel-button,
.item-remove {
  border-radius: 8px;
  color: #111;
  background: var(--gold);
  cursor: pointer;
  font-weight: bold;
}

.panel-button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.item-remove {
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.18);
  color: var(--text);
}

.item-remove:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.controls {
  position: absolute;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
}

.controls button {
  outline: none;
  padding: 14px 30px;
  border-radius: 999px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  background: var(--gold);
  color: black;
  transition: 0.2s;
}

.controls button:hover {
  transform: scale(1.05);
}

.controls button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.controls button.is-stop {
  background: var(--danger);
  color: #150500;
}

@media (max-width: 720px) {
  .settings-panel {
    top: 0;
    bottom: 0;
    left: 0;
    width: min(330px, calc(100vw - 70px));
  }

  .controls {
    gap: 10px;
    bottom: 24px;
    flex-wrap: wrap;
    justify-content: center;
    width: min(92vw, 520px);
  }

  .controls button {
    font-size: 16px;
    padding: 12px 20px;
  }
}
