:root {
  --vn-stage-bg: #0a0d18;
  --vn-dialog-bg: rgba(0, 0, 0, 0.78);
  --vn-dialog-border: rgba(255, 255, 255, 0.18);
  --vn-text: #ffffff;
  --vn-speaker: #f0997b;
  --vn-hint: rgba(255, 255, 255, 0.42);
  --vn-accent: #f0997b;
  --vn-accent-hover: rgba(80, 25, 25, 0.9);
  --vn-modal-bg: rgba(0, 0, 0, 0.85);
  --vn-modal-panel: #1a1d28;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #050610;
  color: var(--vn-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Sarabun", "Noto Sans Thai", system-ui, sans-serif;
  min-height: 100vh;
}

.vn-app {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px;
}

.vn-topbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  align-items: center;
}

.vn-title {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  margin-right: auto;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.vn-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 0.5px solid rgba(255, 255, 255, 0.18);
  color: var(--vn-text);
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.vn-btn:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.3); }
.vn-btn:active { transform: scale(0.97); }
.vn-btn.active { background: rgba(240, 153, 123, 0.2); border-color: var(--vn-accent); color: var(--vn-accent); }

.vn-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  overflow: hidden;
  background: var(--vn-stage-bg);
  cursor: pointer;
  user-select: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

#vn-bg {
  position: absolute;
  inset: 0;
  transition: background 0.8s ease;
}

#vn-rain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: repeating-linear-gradient(105deg, transparent 0 7px, rgba(180, 200, 255, 0.18) 7px 8px, transparent 8px 14px);
  animation: vn-rain 0.55s linear infinite;
  transition: opacity 1s;
}

@keyframes vn-rain {
  from { background-position: 0 0; }
  to { background-position: -100px 240px; }
}

#vn-flicker {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: #000;
  opacity: 0;
  mix-blend-mode: multiply;
}

.flicker-on { animation: vn-flicker 4s steps(1) infinite; }

@keyframes vn-flicker {
  0%, 100% { opacity: 0; }
  92%, 92.5% { opacity: 0.6; }
  93%, 93.5% { opacity: 0; }
  94%, 94.5% { opacity: 0.5; }
  95% { opacity: 0; }
}

.vn-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.7);
}

#vn-char {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 130px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.6s ease;
  pointer-events: none;
}

#vn-char img, #vn-char svg {
  height: clamp(220px, 50%, 360px);
  width: auto;
  display: block;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.6));
}

.vn-char-label {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.55);
  padding: 3px 10px;
  border-radius: 4px;
  white-space: nowrap;
}

.vn-status {
  position: absolute;
  top: 10px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  pointer-events: none;
}

.vn-dialog {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  background: var(--vn-dialog-bg);
  border: 0.5px solid var(--vn-dialog-border);
  border-radius: 8px;
  padding: 14px 18px;
  color: var(--vn-text);
  min-height: 96px;
}

.vn-speaker {
  font-size: 13px;
  font-weight: 500;
  color: var(--vn-speaker);
  margin-bottom: 6px;
  min-height: 15px;
  letter-spacing: 0.3px;
}

.vn-text {
  font-size: 14px;
  line-height: 1.7;
  min-height: 44px;
}

.vn-hint {
  font-size: 11px;
  color: var(--vn-hint);
  text-align: right;
  margin-top: 4px;
}

.vn-choices {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: none;
  flex-direction: column;
  gap: 8px;
}

.vn-choice {
  background: var(--vn-dialog-bg);
  border: 0.5px solid rgba(240, 153, 123, 0.55);
  color: var(--vn-text);
  padding: 12px 16px;
  border-radius: 6px;
  text-align: left;
  font-size: 13.5px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.5;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.vn-choice:hover {
  background: var(--vn-accent-hover);
  border-color: var(--vn-accent);
}

.vn-choice:active { transform: scale(0.99); }

.vn-modal {
  position: fixed;
  inset: 0;
  background: var(--vn-modal-bg);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.vn-modal.open { display: flex; }

.vn-modal-panel {
  background: var(--vn-modal-panel);
  border: 0.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 20px;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

.vn-modal-title {
  font-size: 16px;
  font-weight: 500;
  margin: 0 0 12px;
  color: var(--vn-accent);
}

.vn-modal-close {
  float: right;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}

.vn-slots {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}

.vn-slot {
  background: rgba(255, 255, 255, 0.04);
  border: 0.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.vn-slot-info {
  flex: 1;
  font-size: 12.5px;
  min-width: 0;
}

.vn-slot-label {
  font-weight: 500;
  margin-bottom: 2px;
}

.vn-slot-meta {
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
}

.vn-slot-empty { color: rgba(255, 255, 255, 0.35); font-style: italic; }

.vn-slot-actions { display: flex; gap: 6px; flex-shrink: 0; }

.vn-history-line {
  padding: 8px 0;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  line-height: 1.6;
}

.vn-history-line:last-child { border-bottom: none; }

.vn-history-speaker {
  color: var(--vn-accent);
  font-size: 11px;
  font-weight: 500;
  margin-bottom: 2px;
}

.vn-settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.08);
  gap: 12px;
}

.vn-settings-row:last-child { border-bottom: none; }

.vn-settings-label { font-size: 13px; }

.vn-settings-row input[type="range"] {
  width: 160px;
  accent-color: var(--vn-accent);
}

.vn-footer {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
}

.vn-footer a { color: var(--vn-accent); text-decoration: none; }
.vn-footer a:hover { text-decoration: underline; }

@media (max-width: 600px) {
  .vn-app { padding: 8px; }
  .vn-text { font-size: 13px; }
  .vn-choice { font-size: 13px; }
  #vn-char { bottom: 120px; }
  #vn-char img, #vn-char svg { height: clamp(180px, 45%, 280px); }
}
