body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f6f7f9;
  color: #222;
}

.container {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 16px;
}

h1 {
  margin-bottom: 16px;
}

.title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.logout-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logout-link {
  display: inline-block;
  border: 1px solid #999;
  background: #fff;
  color: #222;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 3px;
}

.auth-links {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

@media (max-width: 960px) {
  .panel-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.stack {
  display: grid;
  gap: 8px;
}

.compact {
  margin-top: 12px;
}

.upload-form {
  margin-bottom: 10px;
}

label {
  font-weight: 600;
}

select,
input,
textarea,
button {
  font: inherit;
  padding: 8px;
}

textarea {
  width: 100%;
  box-sizing: border-box;
}

.inline-form {
  margin-top: 8px;
}

.script-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.button-link {
  display: inline-block;
  border: 1px solid #999;
  background: #f8f8f8;
  color: #222;
  text-decoration: none;
  border-radius: 3px;
  padding: 8px 10px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.feedback-input-wrap {
  position: relative;
  width: 100%;
}

.feedback-input {
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  color: transparent;
  caret-color: #222;
  position: relative;
  z-index: 2;
  resize: none;
  overflow: hidden;
  line-height: 1.4;
  min-height: 42px;
  white-space: pre-wrap;
  word-break: break-word;
}

.word-feedback-overlay {
  position: absolute;
  inset: 0;
  display: block;
  padding: 8px;
  color: #222;
  pointer-events: none;
  white-space: pre-wrap;
  line-height: 1.4;
  word-break: break-word;
  overflow: hidden;
  z-index: 1;
}

.word-feedback-word.is-correct {
  color: #1d8f3b;
}

.word-feedback-word.is-incorrect {
  color: #c7742a;
}

.word-feedback-word.is-prefix {
  color: #222;
}

.word-feedback-word.is-neutral {
  color: #222;
}

button {
  width: fit-content;
  cursor: pointer;
}

.result {
  margin-top: 12px;
  padding: 10px;
  border-radius: 6px;
}

.result.ok {
  background: #e6f7ea;
  border: 1px solid #9cd7a7;
}

.result.bad {
  background: #fce8e8;
  border: 1px solid #e8a4a4;
}

.muted {
  color: #666;
}

.error {
  background: #ffeaea;
  border: 1px solid #f2b2b2;
  padding: 10px;
  border-radius: 6px;
}

.success {
  color: #136d2d;
  font-weight: 700;
}

.badge-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.badges-threshold-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
}

.threshold-form {
  min-width: 260px;
}

.threshold-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.threshold-controls input[type="range"] {
  width: 170px;
}

#threshold_value {
  min-width: 36px;
  font-weight: 700;
}

.threshold-ticks {
  display: flex;
  justify-content: space-between;
  color: #666;
  font-size: 12px;
  margin-top: 4px;
}

.badge {
  border: 1px solid #999;
  border-radius: 4px;
  padding: 4px 8px;
  min-width: 48px;
  text-align: center;
  font-weight: 700;
}

.scoreboard-wrap {
  overflow: auto;
  max-height: 280px;
  border: 1px solid #ddd;
}

.scoreboard {
  width: 100%;
  border-collapse: collapse;
}

.scoreboard th,
.scoreboard td {
  border: 1px solid #bbb;
  padding: 4px 8px;
  text-align: center;
}

.scoreboard th {
  background: #f3f3f3;
}

.scene-link {
  border: none;
  background: transparent;
  text-decoration: underline;
  color: #0b57d0;
  padding: 0;
}

.selected-row td {
  box-shadow: inset 0 0 0 2px #1e90ff;
}

.end-scene-animation-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.theatre-particle {
  position: absolute;
  border-radius: 2px;
  opacity: 0;
  animation-name: theatre-confetti-fall;
  animation-timing-function: cubic-bezier(0.25, 0.85, 0.35, 1);
  animation-fill-mode: forwards;
}

.theatre-particle.soft {
  filter: saturate(0.8);
}

.theatre-particle.gold {
  box-shadow: 0 0 8px rgba(255, 214, 110, 0.55);
}

.theatre-spotlight-sweep {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 38%,
    rgba(255, 245, 204, 0.12) 45%,
    rgba(255, 252, 224, 0.26) 50%,
    rgba(255, 245, 204, 0.12) 55%,
    transparent 62%
  );
  transform: translateX(-120%);
  animation: theatre-spotlight 1300ms ease-in-out forwards;
}

[data-final-score] {
  display: inline-block;
  transform-origin: center center;
}

[data-final-score].score-pop {
  animation: theatre-score-pop 700ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes theatre-confetti-fall {
  0% {
    opacity: 0;
    transform: translate3d(0, -4vh, 0) rotate(0deg);
  }
  8% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--particle-drift), 110vh, 0) rotate(470deg);
  }
}

@keyframes theatre-spotlight {
  0% {
    opacity: 0;
    transform: translateX(-120%);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(120%);
  }
}

@keyframes theatre-score-pop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .theatre-particle,
  .theatre-spotlight-sweep,
  [data-final-score].score-pop {
    animation: none !important;
  }
}


.edit-line-panel {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #d8be54;
  background: #fff9d9;
  border-radius: 6px;
}

.edit-line-title {
  margin: 0 0 8px;
  font-weight: 700;
}

.edit-line-status {
  margin-top: 10px;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #d8be54;
  background: #fff9d9;
}

.edit-line-status.is-success {
  border-color: #81c995;
  background: #e9f8ed;
}

.edit-line-status.is-error {
  border-color: #e0a3a3;
  background: #fdecec;
}

.edit-script-table-wrap {
  overflow: auto;
  border: 1px solid #ddd;
}

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

.edit-script-table th,
.edit-script-table td {
  border: 1px solid #bbb;
  padding: 6px;
}

.edit-script-table input {
  width: 100%;
  box-sizing: border-box;
}
