/* ===== Colours and basics ===== */
:root {
  --bg: #111;
  --panel: #1c1c1e;
  --border: #333;
  --text: #eee;
  --muted: #999;
  --accent: #e8a33d;
  --danger: #d9534f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[hidden] { display: none !important; }

button {
  font: inherit;
  color: var(--text);
  background: #2a2a2d;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
}
button:hover { background: #38383c; }
button:disabled { opacity: 0.6; cursor: wait; }
button.primary { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger:hover { background: var(--danger); border-color: var(--danger); }

/* ===== Setup and summary screens ===== */
.screen {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.panel {
  width: 100%;
  max-width: 520px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
}

h1 { margin: 0 0 4px; font-size: 1.6rem; }
.intro { margin: 0 0 24px; color: var(--muted); }

.field { display: block; border: 0; margin: 0 0 20px; padding: 0; }
.label { display: block; margin-bottom: 8px; font-weight: 600; padding: 0; }

input[type="url"], input[type="number"] {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: #111;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Recent boards list under the URL box */
.recents { margin: -8px 0 20px; }
.recents-label { display: block; margin-bottom: 6px; font-size: 0.85rem; color: var(--muted); }
#recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}
#recent-list li { display: flex; gap: 6px; }
.recent-pick {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  padding: 8px 12px;
  background: #111;
}
.recent-pick.current { border-color: var(--accent); }
.recent-title, .recent-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-title { font-weight: 600; }
.recent-meta { font-size: 0.8rem; color: var(--muted); }
.recent-remove { padding: 0 14px; background: #111; color: var(--muted); font-size: 1.2rem; }
.recent-remove:hover { color: var(--text); }

/* Radio buttons shown as clickable "chips" */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
}
.chips input:checked + span { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 600; }
.chips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.custom-time { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.custom-time input { width: 110px; }

.error {
  background: rgba(217, 83, 79, 0.15);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 0 16px;
}

#start-btn { width: 100%; padding: 14px; font-size: 1.1rem; }

/* ===== Session screen ===== */
#session-screen { position: fixed; inset: 0; padding: 0; background: #000; }

#reference {
  width: 100%;
  height: 100%;
  object-fit: contain;   /* whole image visible, as large as possible */
  display: block;
}

.image-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--muted);
  text-align: center;
  margin: 0;
}

#time-bar { position: absolute; top: 0; left: 0; right: 0; height: 4px; background: rgba(255, 255, 255, 0.1); z-index: 2; }
#time-bar-fill { height: 100%; width: 100%; background: var(--accent); }
#session-screen.warning #time-bar-fill { background: var(--danger); }

.hud {
  position: absolute;
  top: 14px;
  right: 16px;
  display: flex;
  align-items: baseline;
  gap: 14px;
  background: rgba(0, 0, 0, 0.55);
  padding: 6px 14px;
  border-radius: 10px;
}
#progress { color: var(--muted); }
#countdown { font-size: 2.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
#session-screen.warning #countdown { color: var(--danger); }

.controls {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  background: rgba(0, 0, 0, 0.55);
  padding: 8px;
  border-radius: 12px;
  opacity: 0.35;
  transition: opacity 0.2s;
}
.controls:hover, .controls:focus-within { opacity: 1; }
.controls button { background: rgba(40, 40, 44, 0.9); }

#paused-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.7);
  padding: 12px 28px;
  border-radius: 12px;
  pointer-events: none;
}

/* ===== Summary screen ===== */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0; }
.stats div { background: #111; border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.stats dt { color: var(--muted); font-size: 0.85rem; }
.stats dd { margin: 4px 0 0; font-size: 1.4rem; font-weight: 700; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; margin-bottom: 20px; }
.thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }

.summary-actions { display: flex; gap: 10px; }
.summary-actions button { flex: 1; }

/* ===== Small screens ===== */
@media (max-width: 560px) {
  .panel { padding: 20px; }
  .stats { grid-template-columns: 1fr; }
  .controls { width: calc(100% - 32px); flex-wrap: wrap; justify-content: center; }
  .controls button { padding: 8px 10px; }
  #fullscreen-btn { display: none; }
  #countdown { font-size: 1.6rem; }
}
