:root {
  --bg: #0f1222;
  --panel: #1b2038;
  --panel-2: #242b4a;
  --text: #e8ebff;
  --text-dim: #9aa3c7;
  --accent: #6c5ce7;
  --accent-2: #00cec9;
  --danger: #fd79a8;
  --success: #00b894;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

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

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: radial-gradient(1200px 800px at 20% 10%, #1b2142 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 30px 16px;
}

.app {
  width: 100%;
  max-width: 820px;
}

.header {
  text-align: center;
  margin-bottom: 24px;
}

.header h1 {
  font-size: 30px;
  background: linear-gradient(90deg, var(--accent-2), #a29bfe, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  margin-top: 6px;
  color: var(--text-dim);
  font-size: 14px;
}

.tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.tab {
  padding: 9px 18px;
  border: none;
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.tab:hover {
  background: var(--panel-2);
  color: var(--text);
}

.tab.active {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.4);
}

.panel {
  display: none;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.panel.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- 转盘 ---- */
.wheel-title-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.wheel-title {
  width: 100%;
  max-width: 340px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 2px dashed var(--panel-2);
  background: var(--panel-2);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.wheel-title:hover {
  border-color: var(--accent);
}

.wheel-title:focus {
  border-color: var(--accent-2);
  background: #1e2542;
}

.wheel-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.wheel-area {
  position: relative;
  width: 300px;
  height: 300px;
}

#wheelCanvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: var(--shadow);
}

.pointer {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-top: 30px solid #fff;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
  z-index: 5;
}

.wheel-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
}

.spin-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(108, 92, 231, 0.5);
  transition: transform 0.15s, box-shadow 0.15s;
}

.spin-btn:hover {
  transform: scale(1.06);
}

.spin-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: scale(1);
}

.result-box {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 16px;
  text-align: center;
  word-break: break-all;
}

.result-box.big {
  font-size: 26px;
  font-weight: 700;
  margin-top: 14px;
  min-height: 64px;
}

.result-box.highlight {
  background: linear-gradient(90deg, rgba(108,92,231,0.5), rgba(0,206,201,0.5));
  animation: pop 0.4s ease;
}

@keyframes pop {
  0% { transform: scale(0.9); }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ---- 控件 ---- */
.control-panel h3 {
  margin-bottom: 12px;
  color: var(--text-dim);
  font-size: 15px;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  max-height: 280px;
  overflow-y: auto;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--panel-2);
}

.option-row .opt-color {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}

.option-row .opt-name {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(0,0,0,0.2);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.option-row .opt-name:focus {
  border-color: var(--accent);
}

.option-row .opt-weight {
  width: 62px;
  flex-shrink: 0;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(0,0,0,0.2);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  outline: none;
}

.option-row .opt-prob {
  width: 86px;
  flex-shrink: 0;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px dashed rgba(108,92,231,0.5);
  background: rgba(108,92,231,0.12);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  outline: none;
}

.option-row .opt-prob::placeholder {
  color: var(--text-dim);
  font-size: 11px;
}

.option-row .opt-prob:focus {
  border-color: var(--accent);
  background: rgba(108,92,231,0.22);
}

.option-row .opt-weight:focus {
  border-color: var(--accent);
}

.option-row .remove-opt {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.option-row .remove-opt:hover {
  color: var(--danger);
}

.option-add {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.option-add input,
.form-grid input[type="number"],
.form-grid select,
.option-add input[type="number"] {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-2);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.option-add #newOptionWeight {
  flex: 0 0 70px;
  text-align: center;
}

.option-add input:focus,
.form-grid input:focus,
.form-grid select:focus {
  border-color: var(--accent);
}

textarea#weightedInput {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-2);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  outline: none;
}

textarea#weightedInput:focus {
  border-color: var(--accent);
}

.hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.result-detail {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 400;
  margin-top: 8px;
  word-break: break-all;
  line-height: 1.6;
  max-height: 120px;
  overflow-y: auto;
}

.dice-actions input[type="number"] {
  width: 90px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-2);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  outline: none;
  text-align: center;
}

.dice-actions input[type="number"]:focus {
  border-color: var(--accent);
}

.option-actions {
  display: flex;
  gap: 8px;
}

.btn {
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.15s, opacity 0.15s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.ghost {
  background: var(--panel-2);
  color: var(--text);
}

.btn.big {
  width: 100%;
  padding: 13px;
  font-size: 16px;
  font-weight: 600;
  margin-top: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.form-grid label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  padding-top: 8px;
}

/* ---- 硬币 ---- */
.fun-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.coin {
  position: relative;
  width: 150px;
  height: 150px;
  transform-style: preserve-3d;
  transition: transform 0.6s ease;
}

.coin.spinning {
  animation: coinFlip 1.6s ease-in-out;
}

.coin.show-heads { transform: rotateY(0deg); }
.coin.show-tails { transform: rotateY(180deg); }

@keyframes coinFlip {
  0% { transform: rotateY(0); }
  50% { transform: rotateY(720deg); }
  100% { transform: rotateY(180deg); }
}

.coin-face {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 700;
  backface-visibility: hidden;
  background: radial-gradient(circle at 30% 30%, #ffe29a, #f5b53c);
  color: #7a4e00;
  border: 6px solid #d99a1f;
  box-shadow: var(--shadow);
}

.coin-face.back {
  transform: rotateY(180deg);
  background: radial-gradient(circle at 30% 30%, #e2e8f0, #94a3b8);
  color: #334155;
  border-color: #64748b;
}

/* ---- 骰子 ---- */
.dice {
  width: 110px;
  height: 110px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 54px;
  font-weight: 800;
  background: linear-gradient(135deg, #fff, #dbeafe);
  color: #1e3a8a;
  box-shadow: var(--shadow);
}

.dice.rolling {
  animation: diceShake 0.5s ease;
}

@keyframes diceShake {
  0%, 100% { transform: rotate(0) translateX(0); }
  25% { transform: rotate(-12deg) translateX(-6px); }
  75% { transform: rotate(12deg) translateX(6px); }
}

.dice-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dice-actions label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.dice-actions select {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-2);
  background: var(--panel-2);
  color: var(--text);
}

/* ---- 颜色 ---- */
.color-box {
  width: 220px;
  height: 220px;
  border-radius: 24px;
  background: #000;
  box-shadow: var(--shadow);
  transition: background 0.3s ease;
}

.color-info {
  display: flex;
  gap: 12px;
  font-family: "Consolas", monospace;
  font-size: 16px;
  color: var(--text-dim);
}

@media (max-width: 520px) {
  .wheel-area {
    width: 260px;
    height: 260px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .option-row .opt-prob {
    width: 72px;
  }
  .option-row .opt-weight {
    width: 56px;
  }
}
