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

:root {
  --blue: #1a73e8; --blue-dark: #1558b0;
  --green: #0f9d58; --green-light: #e6f4ea;
  --red: #d93025; --orange: #e37400;
  --bg: #f5f7fa; --card: #ffffff;
  --border: #dde3ea; --text: #202124; --muted: #5f6368;
  --badge-bg: #e8f0fe; --badge-text: #1a73e8;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
}

header {
  background: var(--blue); color: #fff;
  padding: 14px 20px; position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
header h1 { font-size: 1.2rem; font-weight: 600; }
header p  { font-size: 0.82rem; opacity: 0.85; margin-top: 2px; }

#countdown {
  display: inline-block; background: rgba(255,255,255,0.2);
  border-radius: 4px; padding: 2px 8px;
  font-size: 0.82rem; font-weight: 600; margin-top: 4px;
}

.container { max-width: 900px; margin: 0 auto; padding: 16px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 12px; }
.filters input, .filters select {
  flex: 1; min-width: 180px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 0.95rem; background: var(--card); color: var(--text);
}
.filters input:focus, .filters select:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}

#selected-count { font-size: 0.88rem; color: var(--muted); margin-bottom: 8px; }

#species-list { display: flex; flex-direction: column; gap: 5px; }

.species-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px;
  display: flex; flex-direction: column; gap: 6px;
  cursor: default; transition: border-color 0.15s, box-shadow 0.15s;
}
.species-item:hover { border-color: var(--blue); }
.species-item.checked { border-color: var(--blue); background: #f0f6ff; }

.species-item input[type=checkbox] {
  width: 18px; height: 18px; accent-color: var(--blue);
  cursor: pointer; flex-shrink: 0;
}

/* Name block */
.name-block { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.species-name { font-size: 0.95rem; font-weight: 500; }
.species-sci  { font-size: 0.78rem; color: var(--muted); font-style: italic; }

/* Size badge */
.size-badge {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
  background: #fff3e0; color: #e65100;
  border: 1px solid #ffcc80;
  padding: 2px 7px; border-radius: 10px; flex-shrink: 0;
}

/* Price block */
.price-block {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0;
}
.price-preorder {
  font-size: 0.92rem; font-weight: 700; color: var(--green);
  background: var(--green-light); border-radius: 4px;
  padding: 2px 8px; white-space: nowrap;
}
.price-retail {
  font-size: 0.72rem; color: var(--muted); white-space: nowrap;
}

.price-bag-qty {
  font-size: 0.72rem; color: var(--blue); font-weight: 600; white-space: nowrap;
}

/* Interest badge */
.vote-badge {
  background: var(--badge-bg); color: var(--badge-text);
  font-size: 0.72rem; font-weight: 600;
  padding: 2px 8px; border-radius: 12px; white-space: nowrap; flex-shrink: 0;
}

.hidden { display: none !important; }

/* Sticky footer form */
#vote-form-wrapper {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card); border-top: 1px solid var(--border);
  padding: 12px 20px; box-shadow: 0 -2px 12px rgba(0,0,0,0.08); z-index: 100;
}
#vote-form {
  max-width: 900px; margin: 0 auto;
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
#vote-form input {
  flex: 1; min-width: 160px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 6px; font-size: 0.95rem;
}
#vote-form input:focus { outline: none; border-color: var(--blue); }
#submit-btn {
  padding: 9px 20px; background: var(--blue); color: #fff;
  border: none; border-radius: 6px; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
#submit-btn:hover   { background: var(--blue-dark); }
#submit-btn:disabled { background: #9aa0a6; cursor: not-allowed; }

.form-spacer { height: 80px; }

#status-msg {
  padding: 12px 16px; border-radius: 6px; font-size: 0.95rem; margin: 12px 0;
}
#status-msg.success { background: #e6f4ea; color: var(--green); border: 1px solid #a8d5b5; }
#status-msg.error   { background: #fce8e6; color: var(--red);   border: 1px solid #f5c6c2; }
#status-msg.info    { background: #e8f0fe; color: var(--blue);  border: 1px solid #c5d8fb; }

#closed-msg { text-align: center; padding: 60px 20px; color: var(--muted); }
#closed-msg h2 { font-size: 1.5rem; margin-bottom: 8px; }

/* Pricing legend */
.pricing-legend {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-size: 0.78rem; color: var(--muted);
  margin-bottom: 10px; padding: 8px 12px;
  background: var(--card); border-radius: 6px;
  border: 1px solid var(--border);
}
.pricing-legend span { display: flex; align-items: center; gap: 4px; }
.legend-dot {
  width: 10px; height: 10px; border-radius: 2px; display: inline-block;
}
.legend-preorder { background: var(--green); }
.legend-retail   { background: var(--muted); }

@media (max-width: 600px) {
  #vote-form { flex-direction: column; }
  #vote-form input, #submit-btn { width: 100%; }

  /* Species card: name full width, then meta row below */
  .species-item { padding: 10px 12px; gap: 6px; }
  .species-item .top-row { flex-wrap: wrap; gap: 6px; }
  .species-item .name-block { flex: 1 1 100%; }
  .species-item .price-block { flex-shrink: 0; }
  .species-item .size-badge { flex-shrink: 0; }
  .species-item .vote-badge { font-size: 0.72rem; }
  .species-item .hot-badge { font-size: 0.72rem; }

  /* Stepper: big tap targets on mobile */
  .qty-stepper button { width: 36px; height: 36px; font-size: 1.2rem; }
  .qty-stepper input[type=number] { width: 48px; height: 36px; font-size: 1rem; }

  /* Bag bar full width */
  .bag-fill-wrap { font-size: 0.75rem; }
}

/* Session picker */
#session-picker {
  background: #1a73e8;
  padding: 0 16px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#session-picker::-webkit-scrollbar { display: none; }

.session-tab {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  text-align: left;
}
.session-tab:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.session-tab.active {
  border-bottom-color: #fff;
  color: #fff;
}
.session-tab-title {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.2;
}
.session-tab-supplier {
  font-size: 0.72rem;
  opacity: 0.8;
}
.session-tab-count {
  font-size: 0.7rem;
  opacity: 0.7;
}

.legend-bag { background: var(--blue); }

.price-poa {
  font-size: 0.78rem; font-weight: 600; color: var(--muted);
  background: #f1f3f4; border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 8px; white-space: nowrap;
}

/* Header logo */
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header-text { flex: 1; min-width: 0; }
.header-logo {
  height: 68px;
  width: 68px;
  object-fit: contain;
  border-radius: 8px;
  background: #ffffff;
  padding: 6px;
  flex-shrink: 0;
}

/* Leaderboard */
#leaderboard {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px 10px;
  margin-bottom: 14px;
}
.lb-header {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.lb-title {
  font-size: 0.95rem; font-weight: 700; color: var(--text);
}
.lb-sub {
  font-size: 0.78rem; color: var(--muted);
}
.lb-row {
  display: grid;
  grid-template-columns: 28px 1fr 100px 80px;
  align-items: center; gap: 8px;
  padding: 5px 2px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
}
.lb-row:hover { background: #f0f6ff; }
.lb-rank {
  font-size: 0.78rem; font-weight: 700;
  color: var(--blue); text-align: right;
}
.lb-name {
  font-size: 0.88rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lb-bar-wrap {
  background: #e8f0fe; border-radius: 4px; height: 8px; overflow: hidden;
}
.lb-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), #4a90d9);
  border-radius: 4px;
  transition: width 0.6s ease;
}
.lb-count {
  font-size: 0.82rem; font-weight: 700; color: var(--blue);
  text-align: right; white-space: nowrap;
}
.lb-label { font-weight: 400; color: var(--muted); font-size: 0.72rem; }
.lb-more {
  font-size: 0.75rem; color: var(--muted);
  text-align: center; padding-top: 8px; margin-top: 4px;
  border-top: 1px dashed var(--border);
}

/* Hot badge */
.hot-badge {
  display: none;
  font-size: 0.7rem; font-weight: 700;
  background: #fff3e0; color: #e65100;
  border: 1px solid #ffcc80;
  padding: 2px 6px; border-radius: 10px;
  flex-shrink: 0; white-space: nowrap;
}

.species-category-heading {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text);
  padding: 14px 4px 4px;
  margin-top: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.species-category-heading:first-child { padding-top: 4px; margin-top: 0; }

/* T&C Overlay */
#tc-overlay{position:fixed;inset:0;z-index:9999;background:var(--bg);display:flex;align-items:flex-start;justify-content:center;overflow-y:auto}
#tc-box{width:100%;max-width:780px;background:var(--card);min-height:100vh;display:flex;flex-direction:column;box-shadow:0 0 40px rgba(0,0,0,.12)}
#tc-header{background:var(--blue);color:#fff;padding:24px 28px 20px;text-align:center;display:flex;flex-direction:column;align-items:center;gap:8px}
#tc-logo{width:80px;height:80px;object-fit:contain;border-radius:12px;background:#ffffff;padding:6px}
#tc-header h1{font-size:1.3rem;font-weight:700}
#tc-header p{font-size:.85rem;opacity:.85}
#tc-body{flex:1;padding:20px 28px;display:flex;flex-direction:column}
.tc-section{padding:14px 0;border-bottom:1px solid var(--border)}
.tc-section:last-child{border-bottom:none}
.tc-section h2{font-size:.88rem;font-weight:700;color:var(--blue);margin-bottom:6px;text-transform:uppercase;letter-spacing:.04em}
.tc-section p{font-size:.9rem;line-height:1.65;color:var(--text)}
#tc-footer{position:sticky;bottom:0;background:var(--card);border-top:2px solid var(--border);padding:16px 28px;display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap;box-shadow:0 -4px 16px rgba(0,0,0,.08)}
#tc-check-label{display:flex;align-items:center;gap:10px;font-size:.9rem;font-weight:500;cursor:pointer;flex:1}
#tc-checkbox{width:20px;height:20px;accent-color:var(--blue);cursor:pointer;flex-shrink:0}
#tc-continue-btn{padding:11px 28px;background:var(--blue);color:#fff;border:none;border-radius:8px;font-size:.95rem;font-weight:700;cursor:pointer;white-space:nowrap;transition:background .15s}
#tc-continue-btn:hover:not(:disabled){background:var(--blue-dark)}
#tc-continue-btn:disabled{background:#c5c5c5;cursor:not-allowed;opacity:.7}
@media(max-width:600px){#tc-body{padding:16px}#tc-header{padding:20px 16px 16px}#tc-footer{padding:14px 16px;flex-direction:column;align-items:stretch}#tc-continue-btn{width:100%;text-align:center}}

/* Voted filter toggle button */
#voted-filter-btn {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
#voted-filter-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}
#voted-filter-btn.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

/* Qty stepper */
.qty-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.qty-stepper button {
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  transition: background 0.12s, border-color 0.12s;
  flex-shrink: 0;
}
.qty-stepper button:hover { border-color: var(--blue); color: var(--blue); }
.qty-stepper input[type=number] {
  width: 44px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 2px;
  font-size: 0.95rem;
  font-weight: 600;
  background: var(--bg);
  color: var(--text);
  -moz-appearance: textfield;
}
.qty-stepper input[type=number]::-webkit-outer-spin-button,
.qty-stepper input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }

/* Bag fill bar */
.bag-fill-wrap {
  width: 100%;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}
.bag-fill-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
}
.bag-fill-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease, background 0.4s ease;
  background: var(--blue);
}
.bag-fill-bar.warn  { background: #f59e0b; }
.bag-fill-bar.full  { background: #16a34a; }
.bag-fill-label { white-space: nowrap; min-width: 60px; text-align: right; }

/* Selected species card highlight */
.species-item.selected {
  border-color: var(--blue);
  background: rgba(26,115,232,0.04);
}
