* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #1a1a2e;
  color: #eee;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  position: relative;
}
#header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 16px;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  background: #16213e;
}
#pattern-name {
  font-size: 16px;
  font-weight: bold;
  color: #eee;
  max-width: calc(100% - 60px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#pattern-indicator {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 0;
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  z-index: 50;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  transition: background 0.3s, transform 0.3s;
}
.dot.active {
  background: #ffd700;
  transform: scale(1.3);
}
.pattern-name-input {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: white;
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.3s;
}
.pattern-name-input:focus {
  border-color: #ffd700;
}
.pattern-name-input::placeholder {
  color: rgba(255,255,255,0.3);
}
#roulette-container {
  position: relative;
  width: min(80vw, 80vh, 500px);
  height: min(80vw, 80vh, 500px);
}
#roulette-canvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 0 40px rgba(255, 215, 0, 0.3);
}
#start-bg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #1a1a2e;
  z-index: 9;
}
#start-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: white;
  font-size: 16px;
  font-weight: bold;
  border: 3px solid #fff;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 10;
}
#start-btn:hover { transform: translate(-50%, -50%) scale(1.1); box-shadow: 0 6px 20px rgba(0,0,0,0.5); }
#start-btn:active { transform: translate(-50%, -50%) scale(0.95); }
#start-btn.disabled { opacity: 0.5; pointer-events: none; }
#settings-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  font-size: 22px;
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
#settings-btn:hover { background: rgba(255,255,255,0.2); }
#settings-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
#settings-overlay.open { display: flex; }
#settings-panel {
  background: #16213e;
  border-radius: 16px;
  padding: 24px;
  width: min(90vw, 400px);
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
#settings-panel h2 { margin-bottom: 20px; text-align: center; font-size: 20px; }
.settings-section { margin-bottom: 20px; }
.settings-section h3 { margin-bottom: 10px; font-size: 14px; color: #aaa; text-transform: uppercase; letter-spacing: 1px; }
.item-list { display: flex; flex-direction: column; gap: 8px; }
.item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.05);
  padding: 8px 12px;
  border-radius: 8px;
}
.item-row input[type="text"] {
  flex: 1;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 8px 10px;
  color: white;
  font-size: 14px;
}
.item-row input[type="color"] {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
}
.item-row input[type="number"] {
  width: 50px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 8px 6px;
  color: white;
  font-size: 14px;
  text-align: center;
}
.item-row .remove-btn {
  background: rgba(255,70,70,0.3);
  border: none;
  color: #ff6b6b;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
}
.item-row .remove-btn:hover { background: rgba(255,70,70,0.5); }
.item-row.marked .remove-btn {
  text-shadow:
    0 2px 2px rgba(0,0,0,0.9),
    0 0 5px rgba(255,255,255,0.35);
}
.add-btn {
  width: 100%;
  padding: 10px;
  background: rgba(70,130,255,0.2);
  border: 2px dashed rgba(70,130,255,0.4);
  border-radius: 8px;
  color: #6b9fff;
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
}
.add-btn:hover { background: rgba(70,130,255,0.3); }
.pattern-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 12px 0;
}
.pattern-action-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
}
.pattern-action-btn:active {
  transform: scale(0.9);
}
.add-pattern-btn {
  background: rgba(70,130,255,0.3);
  color: #6b9fff;
}
.add-pattern-btn:hover {
  background: rgba(70,130,255,0.5);
}
.delete-pattern-btn {
  background: rgba(255,70,70,0.3);
  color: #ff6b6b;
}
.delete-pattern-btn:hover {
  background: rgba(255,70,70,0.5);
}
.delete-pattern-btn.disabled {
  opacity: 0.3;
  pointer-events: none;
}
#pattern-indicator-settings {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 12px 0;
}
.close-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  margin-top: 10px;
}
.close-btn:hover { opacity: 0.9; }
#result-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  z-index: 300;
  align-items: center;
  justify-content: flex-end;
  flex-direction: column;
}
#result-overlay.open { display: flex; }
#result-text {
  font-size: 32px;
  font-weight: bold;
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255,215,0,0.8);
  text-align: center;
  padding: 20px;
  max-width: 85vw;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: pre-line;
  animation: popIn 0.5s ease-out;
}
@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}
#result-close-btn {
  margin-top: 30px;
  padding: 12px 40px;
  background: linear-gradient(135deg, #ffd700, #ffaa00);
  border: none;
  border-radius: 25px;
  color: #1a1a2e;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
}
#sparkle-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 301;
}
.empty-state {
  text-align: center;
  padding: 30px;
  color: #666;
  font-size: 14px;
}
.pointer {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
  border-top: 25px solid #ffd700;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
  z-index: 20;
}
#app-version {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(10px, env(safe-area-inset-bottom));
  text-align: center;
  color: rgba(255,255,255,0.45);
  font-size: 12px;
  letter-spacing: 0.04em;
  pointer-events: none;
  z-index: 50;
}
