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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
  padding: 1rem;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem;
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
  color: #fff;
}

h2 {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
  color: #fff;
}

.subtitle {
  color: #888;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

/* Player info */
#player-info {
  margin-bottom: 1rem;
}

.text-input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: #16213e;
  border: 1px solid #444;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.text-input:focus {
  outline: none;
  border-color: #7c83ff;
}

#color-picker {
  display: flex;
  gap: 1rem;
}

.color-option {
  color: #ccc;
  font-size: 0.9rem;
  cursor: pointer;
}

.color-option input { margin-right: 0.3rem; }

/* Sessions list */
#sessions-section {
  margin-bottom: 1rem;
}

#sessions-list {
  margin-bottom: 1rem;
}

.session-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #16213e;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.session-item:hover {
  border-color: #7c83ff;
  background: #1a2547;
}

.session-players {
  font-weight: 600;
  color: #e0e0e0;
}

.session-meta {
  font-size: 0.8rem;
  color: #888;
}

.session-status {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.session-status.complete {
  background: #0a3d0a;
  color: #4caf50;
}

.session-status.in-progress {
  background: #3d2e0a;
  color: #ffaa00;
}

/* Upload area */
.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed #444;
  border-radius: 12px;
  padding: 2rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: #16213e;
}

.upload-area:hover, .upload-area:focus-within {
  border-color: #7c83ff;
  background: #1a2547;
}

.upload-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.upload-text { font-size: 1rem; color: #ccc; }
.upload-hint { font-size: 0.8rem; color: #666; margin-top: 0.25rem; }

#file-input { display: none; }

/* Preview */
#preview-container {
  margin-top: 1rem;
  text-align: center;
}

#preview-img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  border: 1px solid #333;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
  font-weight: 600;
}

.btn-primary {
  background: #7c83ff;
  color: #fff;
  width: 100%;
  margin-top: 1rem;
}

.btn-primary:hover { background: #6a70e0; }
.btn-primary:disabled { background: #444; cursor: not-allowed; }

.btn-secondary {
  background: #333;
  color: #ccc;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  padding: 0.4rem 1rem;
}

.btn-small {
  background: #333;
  color: #ccc;
  font-size: 0.8rem;
  padding: 0.3rem 0.8rem;
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

.btn-small:hover, .btn-secondary:hover { background: #444; }

.btn-candidate {
  display: block;
  width: 100%;
  background: #16213e;
  color: #e0e0e0;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  font-size: 1rem;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s, background 0.2s;
}

.btn-candidate:hover {
  border-color: #7c83ff;
  background: #1a2547;
}

.btn-candidate .san { font-weight: 700; font-size: 1.1rem; }
.btn-candidate .detail { color: #888; font-size: 0.85rem; }

/* PGN output */
.pgn-box {
  position: relative;
  background: #0f3460;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.5rem;
}

#pgn-output {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #e0e0e0;
}

#verified-count {
  font-size: 0.85rem;
  color: #888;
}

/* Interactive moves */
.moves-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  align-items: baseline;
}

.move-number {
  color: #888;
  font-size: 0.85rem;
  margin-right: 0.1rem;
  font-family: "SF Mono", "Fira Code", monospace;
}

.move-btn {
  background: none;
  border: 1px solid transparent;
  color: #e0e0e0;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.9rem;
  padding: 0.15rem 0.3rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s, border-color 0.15s;
}

.move-btn:hover {
  background: #1a2547;
  border-color: #7c83ff;
}

.move-btn.selected {
  background: #7c83ff;
  color: #fff;
}

/* Correction panel */
#correction-section {
  background: #1a2547;
  border: 1px solid #7c83ff;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
}

#correction-section h2 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.correction-input-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.correction-input-row .text-input {
  flex: 1;
  margin-bottom: 0;
}

.correction-candidates {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.correction-candidate {
  background: #16213e;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  color: #e0e0e0;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.correction-candidate:hover {
  border-color: #7c83ff;
  background: #1a2547;
}

.correction-dismiss {
  background: none;
  border: none;
  color: #888;
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 0.5rem;
  padding: 0.3rem 0;
}

.correction-dismiss:hover {
  color: #ccc;
}

/* Ambiguity */
#ambiguity-section {
  background: #2d1b00;
  border: 1px solid #664400;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
}

.ambiguity-info {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.ambiguity-info strong { color: #ffaa00; }

.legal-moves-hint {
  background: #1a1a2e;
  border-radius: 6px;
  padding: 0.75rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: #888;
  max-height: 100px;
  overflow-y: auto;
}

/* Loading */
#loading {
  text-align: center;
  padding: 2rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #333;
  border-top-color: #7c83ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Transcription */
#transcription-section {
  margin-top: 1rem;
}

details {
  background: #16213e;
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

summary {
  cursor: pointer;
  color: #888;
  font-size: 0.85rem;
}

#transcription-output {
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 0.8rem;
  margin-top: 0.5rem;
  color: #aaa;
  max-height: 300px;
  overflow-y: auto;
}

/* Utilities */
.hidden { display: none !important; }

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 0.5rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 100;
  animation: fadeOut 2s ease-in-out forwards;
}

@keyframes fadeOut {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}
