:root {
  --accent: #0b6e2c;
  --accent-hover: #095a23;
  --accent-bg: #e8f5ec;
  --text: #1a1a1a;
  --muted: #666;
  --bg: #fafafa;
  --card-bg: #ffffff;
  --border: #e0e0e0;
  --error: #c0392b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue",
               "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 16px;
  line-height: 1.4;
}

header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 1rem;
  text-align: center;
}

header h1 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--accent);
  font-weight: 700;
}

#freshness {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  min-height: 1em;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0.75rem;
}

details {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0.75rem 0;
  overflow: hidden;
}

details > summary {
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-weight: 600;
  user-select: none;
  list-style: none;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: "▸ ";
  color: var(--accent);
  display: inline-block;
  transition: transform 0.15s;
}
details[open] > summary::before {
  content: "▾ ";
}

details > *:not(summary) {
  padding: 0 1rem;
}
details > *:last-child:not(summary) {
  padding-bottom: 1rem;
}

details fieldset {
  border: none;
  margin: 0;
  padding: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}
details fieldset label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

details label {
  display: inline-block;
  margin: 0.4rem 0;
}
details p label {
  margin-right: 1rem;
}

details input[type="number"] {
  width: 4em;
  padding: 0.3rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

details input[type="date"] {
  padding: 0.35rem 0.5rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-left: 0.5rem;
}

#courts {
  max-height: 320px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}

.court {
  display: block;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f0f0f0;
}
.court:last-child { border-bottom: none; }

.court input { margin-right: 0.5rem; vertical-align: middle; }

.court-name {
  font-weight: 500;
}

.court-loc {
  color: var(--muted);
  font-size: 0.85rem;
  margin-left: 0.5rem;
}

#run {
  display: block;
  width: 100%;
  margin: 1rem 0 0.5rem;
  padding: 0.85rem 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
#run:hover:not(:disabled) { background: var(--accent-hover); }
#run:disabled { opacity: 0.55; cursor: not-allowed; }

#refresh-courts {
  background: #f0f0f0;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
}
#refresh-courts:hover:not(:disabled) {
  background: #e6e6e6;
}
#refresh-courts:disabled { opacity: 0.55; cursor: not-allowed; }

#progress {
  text-align: center;
  color: var(--muted);
  margin: 0.5rem 0;
  min-height: 1.2em;
  font-size: 0.95rem;
}

#results {
  margin-top: 0.5rem;
}

.court-result {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin: 0.75rem 0;
}

.court-result h2 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  color: var(--accent);
  font-weight: 700;
}

.court-meta {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
}

.day-row {
  margin: 0.5rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.5rem;
  align-items: center;
  border-bottom: 1px dashed #f0f0f0;
  padding-bottom: 0.4rem;
}
.day-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.day-row strong {
  min-width: 5em;
  color: var(--text);
  font-weight: 600;
}

.slot {
  display: inline-block;
  background: var(--accent-bg);
  color: var(--accent);
  padding: 0.2rem 0.55rem;
  border-radius: 5px;
  font-size: 0.85rem;
  font-weight: 500;
  margin: 1px 0;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 480px) {
  main { padding: 0.5rem; }
  header h1 { font-size: 1.2rem; }
  #run { font-size: 1rem; padding: 0.75rem; }
}
