:root {
  --bg: #f3f5f1;
  --bg-elev: #ffffff;
  --ink: #12151a;
  --muted: #5a6570;
  --line: #d8ded6;
  --accent: #0b9f8a;
  --accent-deep: #087a6a;
  --accent-soft: rgba(11, 159, 138, 0.12);
  --warn: #c45c26;
  --ball-ink: #101418;
  --shadow: 0 10px 30px rgba(18, 21, 26, 0.06);
  --radius: 18px;
  --font-display: "Syne", "Segoe UI", sans-serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(11, 159, 138, 0.12), transparent 55%),
    radial-gradient(900px 400px at 100% 0%, rgba(18, 21, 26, 0.05), transparent 50%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  cursor: pointer;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 18px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-mark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.7rem;
  letter-spacing: -0.04em;
  line-height: 1;
}

.brand-mark em,
.home-title em {
  font-style: normal;
  color: var(--accent);
}

.brand-sub {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav a {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
}

.nav a:hover,
.nav a.is-active {
  color: var(--ink);
}

/* Home */
.home {
  min-height: calc(100vh - 120px);
  display: grid;
  align-content: center;
  padding: 24px 0 64px;
}

.home-kicker {
  color: var(--accent-deep);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.78rem;
  margin-bottom: 18px;
}

.home-title {
  font-family: var(--font-display);
  font-size: clamp(3.4rem, 10vw, 6.4rem);
  font-weight: 800;
  letter-spacing: -0.06em;
  line-height: 0.92;
  margin: 0 0 22px;
}

.home-title em {
  font-style: normal;
  color: var(--accent);
}

.home-lead {
  max-width: 34rem;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
  margin: 0 0 28px;
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--ink);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  font-weight: 700;
  transition: transform 0.2s ease, background 0.2s ease;
}

.cta:hover {
  background: var(--accent-deep);
  transform: translateY(-2px);
}

.home-note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.86rem;
}

/* Hall */
.page-head {
  padding: 12px 0 18px;
}

.page-head-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-head h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.8rem);
  letter-spacing: -0.04em;
  margin: 0 0 8px;
}

.page-head p {
  margin: 0;
  color: var(--muted);
}

.lot-count {
  color: var(--muted);
  font-size: 0.95rem;
  white-space: nowrap;
}

.lot-count strong {
  color: var(--ink);
  font-size: 1.35rem;
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

.hall-tools {
  display: grid;
  gap: 12px;
  margin: 0 0 16px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}

.search-icon {
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
}

.search-box input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  color: var(--ink);
  min-width: 0;
}

.search-hint {
  color: var(--muted);
  font-size: 0.88rem;
}

.warn-text {
  color: var(--warn);
}

.sync-badge {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(196, 92, 38, 0.12);
  color: var(--warn);
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
}

.countdown.is-fail {
  color: var(--warn);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-count {
  margin-left: 4px;
  opacity: 0.7;
  font-size: 0.82em;
}

.tab {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 650;
}

.tab.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.board {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: visible;
}

.board-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.2fr) auto;
  grid-template-areas:
    "name count"
    "period period"
    "balls balls";
  gap: 8px 14px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  transition: background 0.2s ease;
}

.board-row .lot {
  grid-area: name;
}
.board-row .period {
  grid-area: period;
}
.board-row .balls-wrap {
  grid-area: balls;
}
.board-row .countdown {
  grid-area: count;
  text-align: right;
  justify-self: end;
}

.board-row:last-child {
  border-bottom: 0;
}

.board-row:hover {
  background: rgba(11, 159, 138, 0.04);
}

.board-row.is-fresh {
  animation: flashRow 1.1s ease;
}

@keyframes flashRow {
  0% {
    background: var(--accent-soft);
  }
  100% {
    background: transparent;
  }
}

.lot-name {
  font-weight: 750;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.flag-img {
  display: inline-block;
  width: 24px;
  height: 18px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(18, 21, 26, 0.12);
  flex: 0 0 auto;
}

.lot-meta {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 2px;
}

.pill {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 0.72rem;
  font-weight: 700;
}

.period {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.92rem;
}

.balls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ball {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--ball-ink);
  background: linear-gradient(160deg, #fff 0%, #e8eeea 100%);
  border: 1px solid #cfd8d3;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.ball.is-ca {
  border-color: rgba(200, 16, 46, 0.45);
  background: linear-gradient(145deg, #fff 0%, #ffe4e4 100%);
}

.ball.is-cn {
  border-color: rgba(11, 159, 138, 0.5);
  background: linear-gradient(145deg, #fff 0%, #d9f5ef 100%);
}

.ball.is-special {
  border-color: rgba(196, 92, 38, 0.55);
  background: linear-gradient(145deg, #fff7f1 0%, #ffd7bf 100%);
  color: #8a3a12;
}

.countdown {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--accent-deep);
  letter-spacing: 0.02em;
}

.countdown.is-due {
  color: var(--warn);
}

.muted {
  color: var(--muted);
}

/* Detail */
.detail-wrap {
  padding-bottom: 48px;
}

.back {
  display: inline-flex;
  margin: 8px 0 18px;
  color: var(--muted);
  font-weight: 650;
}

.detail-panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
}

.detail-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.detail-title {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: -0.04em;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-sub {
  color: var(--muted);
  margin: 0;
}

.clock-box {
  min-width: 140px;
  text-align: right;
}

.clock-label {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.clock-value {
  font-family: var(--font-display);
  font-size: 2.4rem;
  letter-spacing: -0.03em;
  color: var(--accent-deep);
  font-variant-numeric: tabular-nums;
}

.detail-balls .ball {
  width: 52px;
  height: 52px;
  font-size: 1.25rem;
}

.history {
  margin-top: 28px;
  width: 100%;
  border-collapse: collapse;
}

.history th,
.history td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 0.94rem;
}

.history th {
  color: var(--muted);
  font-weight: 650;
}

.foot {
  padding: 28px 0 40px;
  color: var(--muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--line);
  margin-top: 36px;
}

@media (max-width: 820px) {
  .clock-box {
    text-align: left;
  }
}
