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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #1a1a1a;
  color: #eee;
}

#ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 2rem;
}

.timer-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 3rem;
  font-weight: bold;
}

.timer-container input {
  width: 100px;
  font-size: 3rem;
  text-align: center;
  background: #2a2a2a;
  color: #eee;
  border: 2px solid #555;
  border-radius: 8px;
  padding: 0.5rem;
  font-weight: bold;
}

.timer-container input:focus {
  outline: none;
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.timer-container input:disabled {
  background: #333;
  color: #666;
  cursor: not-allowed;
  border-color: #444;
}

.checkbox-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
}

.checkbox-container input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.checkbox-container label {
  cursor: pointer;
}

.button-row {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.action-btn {
  padding: 1rem 2rem;
  font-size: 1.2rem;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.2s;
}

#display-same-btn {
  background: #0066cc;
}

#display-same-btn:disabled {
  background: #aaa;
  cursor: not-allowed;
}

#display-same-btn:hover {
  background: #0052a3;
}

#display-same-btn:active {
  background: #003d7a;
}

#display-random-btn {
  background: #2e7d32;
}

#display-random-btn:hover {
  background: #1b5e20;
}

#display-random-btn:active {
  background: #145214;
}

.action-btn:disabled {
  background: #aaa;
  cursor: not-allowed;
}

.link {
  color: #4da6ff;
  text-decoration: none;
  font-size: 1rem;
}

.link:hover {
  text-decoration: underline;
}

.logout-form {
  margin: 0;
  padding: 0;
  display: inline;
}

.logout-form button {
  background: none;
  border: none;
  color: #4da6ff;
  text-decoration: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
  font: inherit;
}

.logout-form button:hover {
  text-decoration: underline;
}

#viewer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#viewer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#countdown {
  position: fixed;
  top: 20px;
  left: 20px;
  font-size: 3rem;
  font-weight: bold;
  color: white;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  font-family: monospace;
}

#countdown.hidden {
  display: none;
}

#viewer img {
  cursor: pointer;
}

/* Selection page styles */
#selection-ui {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 1rem;
}

.selection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.selection-header h1 {
  margin: 0;
}

.selection-header a {
  color: #4da6ff;
  text-decoration: none;
}

.selection-header a:hover {
  text-decoration: underline;
}

.selection-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  margin-bottom: 2rem;
  padding: 1rem;
  background: #2a2a2a;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  flex-wrap: wrap;
}

.sort-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.sort-controls span {
  font-weight: 500;
}

.sort-btn,
.page-actions button {
  padding: 0.6rem 0.8rem;
  border: 1px solid #555;
  background: #2a2a2a;
  color: #eee;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: background 0.2s, border-color 0.2s;
}

.sort-btn:hover,
.page-actions button:hover {
  background: #333;
}

.sort-btn.active,
.page-actions button.active {
  background: #0066cc;
  color: white;
  border-color: #0066cc;
}

.page-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.image-card-label {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  background: #2a2a2a;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.image-card-label:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.image-card-label.selected {
  background: #1a2e3a;
  box-shadow: 0 2px 8px rgba(77, 166, 255, 0.3);
  border: 2px solid #4da6ff;
}

.image-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.image-card img {
  width: 100%;
  height: 200px;
  object-fit: contain;
  background: #111;
  padding: 10px;
}

.image-name {
  display: block;
  padding: 0.8rem;
  font-size: 0.9rem;
  word-break: break-all;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.pagination button,
.pagination span {
  padding: 0.6rem 0.8rem;
  border: 1px solid #555;
  background: #2a2a2a;
  color: #eee;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.9rem;
}

.pagination button:hover {
  background: #333;
}

.pagination button.active {
  background: #0066cc;
  color: white;
  border-color: #0066cc;
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Collection picker (user draw mode) ───────────── */

.collection-picker {
  margin-bottom: 1.2rem;
}

.collection-picker label {
  display: block;
  font-size: 0.9rem;
  color: #aaa;
  margin-bottom: 0.4rem;
}

.collection-picker select {
  background: #2a2a2a;
  color: #eee;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 0.35rem 0.6rem;
  font-size: 0.9rem;
  min-width: 200px;
}

/* ── Collection label (public draw mode) ──────────── */

.collection-label {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #aaa;
}

.collection-label strong {
  color: #eee;
}
