*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f7;
  color: #1c1c1e;
  -webkit-font-smoothing: antialiased;
  /* Disable iOS Safari's double-tap-to-zoom on rapid taps. Pinch-zoom still
     works (accessibility) — this only kills the unintended zoom from quick
     button presses. */
  touch-action: manipulation;
}

.card {
  max-width: 420px;
  margin: 0 auto;
  padding: 32px 20px;
}

.card h1 {
  margin: 0 0 4px;
  font-size: 1.5rem;
  font-weight: 600;
}

.card .muted {
  margin: 0 0 24px;
  color: #6b6b70;
  font-size: 0.95rem;
}

label {
  display: block;
  margin-bottom: 16px;
  font-size: 0.9rem;
  font-weight: 500;
}

input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  font-size: 1rem;
  font-family: inherit;
  color: inherit;
  background: white;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  min-height: 44px;
}

input:focus {
  outline: none;
  border-color: #cc0000;
  box-shadow: 0 0 0 3px rgba(204, 0, 0, 0.15);
}

button {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  color: white;
  background: #cc0000;
  border: none;
  border-radius: 8px;
  min-height: 44px;
  cursor: pointer;
}

button:hover {
  background: #b00000;
}

button:disabled {
  background: #888;
  cursor: not-allowed;
}

.error {
  margin-top: 12px;
  padding: 10px 12px;
  background: #ffeaea;
  color: #b00000;
  border-radius: 8px;
  font-size: 0.9rem;
}

.warning {
  margin-top: 12px;
  padding: 10px 12px;
  background: #fff4e0;
  color: #8a5a00;
  border-radius: 8px;
  font-size: 0.9rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  font-size: 0.9rem;
}

.link-btn {
  display: inline;
  width: auto;
  padding: 0;
  margin: 0;
  background: none;
  color: #cc0000;
  font-size: 0.9rem;
  font-weight: 500;
  min-height: 0;
  text-decoration: underline;
}

.link-btn:hover {
  background: none;
  color: #b00000;
}

button.secondary {
  background: white;
  color: #1c1c1e;
  border: 1px solid #d2d2d7;
  margin-top: 8px;
}

button.secondary:hover {
  background: #f0f0f3;
}

button.secondary:disabled {
  background: #f5f5f7;
  color: #b0b0b5;
  border-color: #e8e8ec;
  cursor: not-allowed;
}

button.secondary:disabled:hover {
  background: #f5f5f7;
}

.big-number {
  font-size: 1.6rem;
  text-align: center;
  letter-spacing: 0.05em;
  padding: 16px;
}

.car-details {
  margin: 0 0 20px;
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 12px;
  row-gap: 8px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.car-details dt {
  color: #6b6b70;
  font-weight: 500;
}

.car-details dd {
  margin: 0;
  color: #1c1c1e;
  font-weight: 500;
}

/* --- Judging walkthrough --- */

.judging .topbar {
  margin-bottom: 16px;
}

.progress {
  margin-bottom: 16px;
}

.progress-bar {
  height: 6px;
  background: #e8e8ec;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}

.progress-fill {
  height: 100%;
  background: #cc0000;
  width: 0%;
  transition: width 0.2s ease;
}

.breadcrumb {
  margin: 0 0 4px;
  font-size: 0.8rem;
  color: #6b6b70;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.judging h1 {
  font-size: 1.4rem;
  margin: 0 0 4px;
  line-height: 1.25;
}

.max-pill {
  margin: 0 0 16px;
  font-size: 0.85rem;
}

.score-input {
  margin: 16px 0;
  padding: 20px 12px;
  background: white;
  border: 1px solid #e8e8ec;
  border-radius: 12px;
  text-align: center;
}

.input-label {
  margin: 0 0 16px;
  font-size: 0.9rem;
  color: #6b6b70;
  font-weight: 500;
}

.number-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-bottom: 16px;
}

.step-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  min-height: 56px;
  margin: 0;
  padding: 0;
  font-size: 1.6rem;
  font-weight: 600;
  border-radius: 50%;
  background: #cc0000;
  color: white;
  border: none;
  flex-shrink: 0;
}

.step-btn:hover {
  background: #b00000;
}

.step-btn:disabled {
  background: #888;
}

.big-value {
  font-size: 2.5rem;
  font-weight: 600;
  min-width: 80px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.quick-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
  padding: 0 12px;
}

.quick-btn {
  flex: 1;
  display: inline-block;
  width: auto;
  margin: 0;
  background: #f0f0f3;
  color: #1c1c1e;
  border: 1px solid #d2d2d7;
  font-size: 0.85rem;
  padding: 10px 8px;
  min-height: 40px;
  font-weight: 500;
}

.quick-btn:hover {
  background: #e0e0e6;
}

.score-readout {
  margin: 0;
  font-size: 0.9rem;
}

.notes {
  margin: 16px 0;
  border: 1px solid #e8e8ec;
  border-radius: 8px;
  padding: 12px;
  background: white;
}

.notes summary {
  cursor: pointer;
  font-size: 0.9rem;
  color: #6b6b70;
  font-weight: 500;
  user-select: none;
}

.notes textarea {
  display: block;
  width: 100%;
  min-height: 80px;
  margin-top: 12px;
  padding: 8px 10px;
  /* Stay at 16px+ to prevent iOS auto-zoom on focus. */
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  resize: vertical;
}

.save-status {
  margin: 8px 0;
  font-size: 0.85rem;
  text-align: right;
  min-height: 1.2em;
}

.save-status.saving { color: #6b6b70; }
.save-status.saved  { color: #2e7d32; }
.save-status.error  { color: #cc0000; }
.save-status.dirty  { color: #b07000; }

.nav-row {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.nav-row button {
  flex: 1;
  margin: 0;
  width: auto;
}

/* --- Photos --- */

.photos {
  margin: 16px 0;
  padding: 12px;
  background: white;
  border: 1px solid #e8e8ec;
  border-radius: 8px;
}

.photos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.photos-label {
  font-weight: 500;
  color: #6b6b70;
}

.photo-status {
  font-size: 0.85rem;
}

.photo-status.saving { color: #6b6b70; }
.photo-status.saved  { color: #2e7d32; }
.photo-status.error  { color: #cc0000; }

.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.photos-grid:empty {
  display: none;
}

.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 6px;
  background: #f0f0f3;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  min-height: 26px;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  color: white;
  font-size: 0.85rem;
  font-weight: bold;
  border-radius: 50%;
  border: none;
  width: auto;
  cursor: pointer;
}

.thumb-delete:hover {
  background: rgba(0, 0, 0, 0.85);
}

.add-photo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 0;
  padding: 12px;
  background: #f0f0f3;
  color: #1c1c1e;
  border: 1px dashed #b0b0b5;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  user-select: none;
}

.add-photo-btn:hover {
  background: #e0e0e6;
}

/* --- Review screen --- */

.review h1 {
  margin: 0 0 16px;
  font-size: 1.5rem;
}

.car-summary {
  margin-bottom: 16px;
  padding: 12px;
  background: white;
  border: 1px solid #e8e8ec;
  border-radius: 8px;
  font-size: 0.95rem;
}

.car-summary-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.car-photo-count {
  margin-top: 6px;
  font-size: 0.85rem;
}

.section-cards {
  margin-bottom: 16px;
}

.section-card {
  margin-bottom: 8px;
  background: white;
  border: 1px solid #e8e8ec;
  border-radius: 8px;
  overflow: hidden;
}

.section-card summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  font-size: 1rem;
}

.section-card summary::-webkit-details-marker {
  display: none;
}

.section-card[open] summary {
  border-bottom: 1px solid #e8e8ec;
}

.section-name {
  font-weight: 600;
}

.section-score {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.section-body {
  padding: 8px 16px 12px;
}

.sub-block {
  margin: 12px 0;
}

.sub-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 4px;
  padding: 4px 0;
  border-bottom: 1px dashed #e8e8ec;
}

.item-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.item-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  font-size: 0.9rem;
  gap: 8px;
}

.item-list .item-name {
  flex: 1;
}

.item-list .item-score {
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  color: #6b6b70;
}

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 0.75rem;
  background: #f0f0f3;
  border-radius: 10px;
  color: #6b6b70;
  white-space: nowrap;
}

.total-card {
  margin: 16px 0;
  padding: 20px 16px;
  background: #cc0000;
  color: white;
  border-radius: 12px;
  text-align: center;
}

.total-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.85;
  margin-bottom: 4px;
}

.total-value {
  font-size: 2.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.total-divider {
  margin: 0 8px;
  opacity: 0.7;
  font-weight: 400;
}

/* Done state */

.done-summary {
  text-align: center;
  margin: 24px 0;
}

.done-heading {
  margin: 0 0 16px;
  font-size: 1.6rem;
  color: #2e7d32;
}

.done-summary .total-card {
  margin: 16px 0;
  background: #2e7d32;
}

.done-summary p {
  margin: 8px 0;
  font-size: 0.9rem;
}

/* --- Subsection preview screen --- */

.preview-list {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
}

.preview-list li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid #e8e8ec;
}

.preview-list li:last-child {
  border-bottom: none;
}

.preview-list .num {
  color: #6b6b70;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 1.5em;
}

.preview-list .name {
  flex: 1;
  font-weight: 500;
}

.preview-list .pts {
  font-size: 0.85rem;
  flex-shrink: 0;
  white-space: nowrap;
}

/* --- Admin report tables --- */

.table-scroll {
  overflow-x: auto;
  margin: 8px 0 16px;
  border: 1px solid #e8e8ec;
  border-radius: 8px;
}

.table-scroll table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  white-space: nowrap;
}

.table-scroll th,
.table-scroll td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid #e8e8ec;
}

.table-scroll thead th {
  color: #6b6b70;
  font-weight: 500;
  background: #f5f5f7;
}

.table-scroll tbody tr:last-child td {
  border-bottom: none;
}
