:root {
  --bg: #0a0e1c;
  --glass: rgba(22, 29, 52, 0.55);
  --glass-2: rgba(30, 39, 70, 0.5);
  --glass-brt: rgba(255, 255, 255, 0.08);
  --stroke: rgba(255, 255, 255, 0.09);
  --stroke-brt: rgba(255, 255, 255, 0.18);
  --text: #e8ecf6;
  --muted: #8b96b5;
  --accent: #e94f64;
  --accent-2: #f5b942;
  --hot: #ef476f;
  --cold: #4cc9f0;
  --good: #43d9a3;
  --chip: rgba(255, 255, 255, 0.05);
  --chip-hover: rgba(255, 255, 255, 0.11);
  --chart-grid: rgba(140, 150, 180, 0.12);
  --chart-tick: #8b96b5;
  --chart-legend: #c7cfe4;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

/* ---- light theme ---- */
:root[data-theme="light"] {
  --bg: #edf0f8;
  --glass: rgba(255, 255, 255, 0.6);
  --glass-2: rgba(255, 255, 255, 0.85);
  --glass-brt: rgba(15, 22, 40, 0.06);
  --stroke: rgba(15, 22, 40, 0.1);
  --stroke-brt: rgba(15, 22, 40, 0.22);
  --text: #1a2138;
  --muted: #5d6883;
  --chip: rgba(15, 22, 40, 0.05);
  --chip-hover: rgba(15, 22, 40, 0.11);
  --chart-grid: rgba(30, 40, 70, 0.1);
  --chart-tick: #5d6883;
  --chart-legend: #38445f;
  color-scheme: light;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 22px clamp(14px, 3vw, 44px) 130px;
  overflow-x: hidden;
  transition: background 0.45s var(--ease), color 0.45s var(--ease);
}

/* ---- ambient orbs the glass blurs over ---- */
.orbs { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  animation: drift 26s var(--ease) infinite alternate;
}
.o1 { width: 520px; height: 520px; background: #33234f; top: -140px; left: -80px; }
.o2 { width: 460px; height: 460px; background: #14355f; top: 30%; right: -140px; animation-delay: -8s; }
.o3 { width: 420px; height: 420px; background: #3d1c30; bottom: -160px; left: 30%; animation-delay: -16s; }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(60px, -40px) scale(1.15); }
}

/* ---- header ---- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 2.1rem; filter: drop-shadow(0 2px 10px rgba(233, 79, 100, 0.55)); }
h1 { font-size: 1.45rem; letter-spacing: 0.4px; }
.sub { color: var(--muted); font-size: 0.85rem; }
.meta { color: var(--muted); font-size: 0.78rem; text-align: right; }
.meta .stale { color: var(--accent-2); }

/* ---- layout: content + right section rail ---- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 218px;
  gap: 20px;
  align-items: start;
}
#content { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ---- glass primitives ---- */
.panel, .card, .side-nav, .island, .custom-pop, .error-banner {
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* ---- panels ---- */
.panel {
  padding: 18px 20px;
  scroll-margin-top: 16px;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease), border-color 0.35s var(--ease);
  animation: rise 0.55s var(--ease) both;
}
.panel:hover {
  transform: translateY(-2px);
  border-color: var(--stroke-brt);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
}
.panel h2 { font-size: 1rem; margin-bottom: 12px; font-weight: 600; }
.hint { font-size: 0.75rem; color: var(--muted); font-weight: 400; margin-left: 8px; }
.chart { position: relative; height: 260px; }
.chart.tall { height: 320px; }
.note { font-size: 0.75rem; color: var(--muted); margin-top: 8px; }
.panel[hidden] { display: none; }

.panel-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel-pair:not(:has(.panel:not([hidden]))) { display: none; }
@media (max-width: 900px) { .panel-pair { grid-template-columns: 1fr; } }

/* ---- stat cards ---- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px;
}
.card {
  padding: 14px 16px;
  border-radius: 16px;
  transition: transform 0.3s var(--ease), border-color 0.3s var(--ease);
}
.card:hover { transform: translateY(-2px); border-color: var(--stroke-brt); }
.card .k {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--muted);
  margin-bottom: 6px;
}
.card .v { font-size: 1.35rem; font-weight: 700; }
.card .d { font-size: 0.74rem; color: var(--muted); margin-top: 4px; }
.card .v.hot { color: var(--hot); text-shadow: 0 0 18px rgba(239, 71, 111, 0.5); }
.card .v.cold { color: var(--cold); text-shadow: 0 0 18px rgba(76, 201, 240, 0.45); }
.card .v.good { color: var(--good); text-shadow: 0 0 18px rgba(67, 217, 163, 0.4); }
.card .v.warn { color: var(--accent-2); text-shadow: 0 0 18px rgba(245, 185, 66, 0.45); }

/* ---- right section rail ---- */
.side-nav {
  position: sticky;
  top: 20px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.nav-label {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted);
  padding: 4px 10px 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 11px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.25s var(--ease);
  user-select: none;
}
.nav-item:hover { background: var(--glass-brt); transform: translateX(-2px); }
.nav-item.active {
  background: var(--glass-2);
  border-color: var(--stroke-brt);
}
.nav-item .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--c, var(--accent));
  box-shadow: 0 0 10px var(--c, var(--accent));
  transition: transform 0.25s var(--ease);
  flex: none;
}
.nav-item.active .dot { transform: scale(1.35); }
.nav-name { font-size: 0.85rem; flex: 1; transition: opacity 0.25s; }
.eye {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 7px;
  display: inline-flex;
  transition: color 0.2s, background 0.2s, opacity 0.25s;
}
.eye:hover { color: var(--text); background: var(--chip-hover); }
.nav-item.off .nav-name { opacity: 0.4; text-decoration: line-through; }
.nav-item.off .dot { background: var(--muted); box-shadow: none; }
.nav-item.off .eye { opacity: 0.35; }

/* ---- floating control island (bottom) ---- */
.island {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 22px;
  background: rgba(14, 19, 36, 0.72);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid var(--stroke-brt);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  max-width: calc(100vw - 24px);
  flex-wrap: wrap;
  justify-content: center;
}
.divider { width: 1px; align-self: stretch; background: var(--stroke); }

.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button, .isl-btn, .custom-pop button {
  background: var(--chip);
  border: 1px solid var(--stroke);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 13px;
  cursor: pointer;
  font-size: 0.84rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease),
    transform 0.15s var(--ease), box-shadow 0.25s var(--ease);
}
.seg button:hover, .isl-btn:hover, .custom-pop button:hover {
  background: var(--chip-hover);
  border-color: var(--stroke-brt);
}
.seg button:active, .isl-btn:active { transform: scale(0.94); }
.seg button.active {
  background: linear-gradient(135deg, rgba(233, 79, 100, 0.9), rgba(178, 40, 69, 0.9));
  border-color: rgba(255, 255, 255, 0.22);
  font-weight: 600;
  box-shadow: 0 4px 18px rgba(233, 79, 100, 0.45);
}
#timeSeg button.active {
  background: linear-gradient(135deg, rgba(65, 98, 200, 0.9), rgba(41, 64, 138, 0.9));
  box-shadow: 0 4px 18px rgba(65, 98, 200, 0.5);
}

/* custom date popover, anchored above the island */
.custom-pop {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 12px;
  border-radius: 17px;
  animation: pop 0.3s var(--ease) both;
  width: min(88vw, 420px);
}
.custom-pop[hidden] { display: none; }
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
}
.custom-pop input {
  background: var(--chip);
  border: 1px solid var(--stroke);
  color: var(--text);
  padding: 7px 9px;
  border-radius: 10px;
  color-scheme: dark;
  font-size: 0.82rem;
  transition: border-color 0.2s;
}
.custom-pop input:focus { outline: none; border-color: var(--accent); }
.custom-pop span { color: var(--muted); }
.custom-pop button {
  background: linear-gradient(135deg, var(--accent), #b02845);
  border-color: transparent;
}
:root[data-theme="light"] .custom-pop input { color-scheme: light; }

.tl-inputs { display: flex; align-items: center; gap: 7px; }

/* ---- draggable timeline range ---- */
.timeline-wrap { position: relative; height: 56px; }
.timeline-overlay { position: absolute; inset: 0; }
.tl-shade {
  position: absolute;
  top: 0; bottom: 0;
  background: rgba(233, 79, 100, 0.16);
  border-left: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  pointer-events: none;
  transition: background 0.15s;
}
.tl-handle {
  position: absolute;
  top: 0; bottom: 0;
  width: 14px;
  margin-left: -7px;
  cursor: ew-resize;
  touch-action: none;
}
.tl-handle::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 9px; height: 22px;
  transform: translate(-50%, -50%);
  border-radius: 5px;
  background: var(--accent);
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s var(--ease), background 0.15s;
}
.tl-handle:hover::after, .tl-handle:focus::after, .tl-handle.dragging::after {
  transform: translate(-50%, -50%) scaleY(1.15);
  background: #ff7186;
  outline: none;
}
.tl-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---- recent draws ---- */
.recent-grid { display: flex; flex-direction: column; gap: 8px; }
.draw-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--chip);
  border: 1px solid var(--stroke);
  border-radius: 13px;
  padding: 8px 12px;
  transition: background 0.25s var(--ease), transform 0.25s var(--ease);
}
.draw-row:hover { background: var(--chip-hover); transform: translateX(3px); }
.draw-date { width: 110px; color: var(--muted); font-size: 0.8rem; }
.ball {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  background: linear-gradient(160deg, #ffffff, #cfd6e6);
  color: #17203a;
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.28), 0 2px 6px rgba(0, 0, 0, 0.35);
}
.ball.special { background: linear-gradient(135deg, var(--accent), #b02845); color: #fff; }
.ball.special.mega { background: linear-gradient(135deg, var(--accent-2), #cf8f14); color: #241a02; }
.draw-mult { margin-left: auto; font-size: 0.75rem; color: var(--muted); }

/* ---- footer / errors ---- */
footer { color: var(--muted); font-size: 0.78rem; line-height: 1.6; padding: 0 4px; }
.disclaimer { color: var(--accent-2); }
.error-banner {
  background: rgba(59, 21, 34, 0.75);
  border-color: var(--hot);
  color: #ffd9e0;
  border-radius: 14px;
  padding: 12px 16px;
}

/* ---- header actions / theme toggle ---- */
.head-actions { display: flex; align-items: center; gap: 12px; }
.theme-btn { font-size: 1rem; padding: 8px 11px; border-radius: 12px; }

/* ---- play strategies ---- */
.regen-all {
  float: right;
  background: var(--chip);
  border: 1px solid var(--stroke);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 11px;
  cursor: pointer;
  font-size: 0.78rem;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.15s var(--ease);
}
.regen-all:hover { background: var(--chip-hover); border-color: var(--stroke-brt); }
.regen-all:active { transform: scale(0.94); }

.strat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 12px;
  margin-bottom: 10px;
}
.strat-card {
  background: var(--chip);
  border: 1px solid var(--stroke);
  border-radius: 15px;
  padding: 13px 15px;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.3s var(--ease);
}
.strat-card:hover { background: var(--chip-hover); border-color: var(--stroke-brt); transform: translateY(-2px); }
.strat-head { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; }
.s-ico { font-size: 1.15rem; }
.s-name { font-weight: 650; font-size: 0.92rem; flex: 1; }
.regen {
  background: var(--chip);
  border: 1px solid var(--stroke);
  color: var(--text);
  width: 30px; height: 30px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.25s var(--ease), transform 0.3s var(--ease), border-color 0.25s var(--ease);
}
.regen:hover { background: var(--chip-hover); border-color: var(--stroke-brt); transform: rotate(120deg); }
.regen:active { transform: rotate(300deg) scale(0.9); }
.s-desc { font-size: 0.76rem; color: var(--muted); line-height: 1.45; margin-bottom: 11px; min-height: 2.9em; }
.strat-balls { display: flex; gap: 7px; flex-wrap: wrap; }
.strat-balls .ball { animation: ballpop 0.45s var(--ease) both; }
@keyframes ballpop {
  from { opacity: 0; transform: scale(0.2) translateY(8px); }
  60% { transform: scale(1.12); }
}
.ball.s { width: 31px; height: 31px; font-size: 0.8rem; }

.del-strat {
  background: var(--chip);
  border: 1px solid var(--stroke);
  color: var(--muted);
  width: 26px; height: 26px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s var(--ease);
}
.del-strat:hover { background: rgba(239, 71, 111, 0.15); color: var(--hot); border-color: rgba(239, 71, 111, 0.4); }
.del-strat:active { transform: scale(0.9); }

/* ---- strategy builder ---- */
.builder {
  background: var(--chip);
  border: 1px solid var(--stroke);
  border-radius: 15px;
  padding: 16px 18px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.b-row { display: flex; flex-direction: column; gap: 8px; }
.b-name-label {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 320px;
}
.b-name-label input {
  background: var(--chip-hover);
  border: 1px solid var(--stroke);
  color: var(--text);
  padding: 9px 11px;
  border-radius: 10px;
  font-size: 0.9rem;
}
.b-pos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  flex-direction: row;
}
.b-pos label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  margin-bottom: 5px;
}
.b-pair { display: flex; align-items: center; gap: 5px; }
.b-pair span { color: var(--muted); }
.b-pair input, .b-mini, .b-mini2 {
  background: var(--chip-hover);
  border: 1px solid var(--stroke);
  color: var(--text);
  border-radius: 9px;
  padding: 7px 8px;
  font-size: 0.85rem;
  text-align: center;
  min-width: 0;
}
.b-pair input { width: 100%; }
.b-mini { width: 48px; margin: 0 4px; }
.b-mini2 { width: 70px; margin: 0 4px; }
.b-inline {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 20px;
}
.b-inline > label { font-size: 0.82rem; color: var(--muted); display: flex; align-items: center; }
.b-group-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  margin-bottom: 6px;
}

/* ---- customize your own stats ---- */
.cc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 900px) { .cc-grid { grid-template-columns: 1fr; } }
.cc-card {
  background: var(--chip);
  border: 1px solid var(--stroke);
  border-radius: 15px;
  padding: 13px 15px;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.3s var(--ease);
  animation: rise 0.45s var(--ease) both;
}
.cc-card:hover { border-color: var(--stroke-brt); transform: translateY(-2px); }
.cc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.cc-desc { min-height: 0; margin-bottom: 8px; }
.cc-chart { height: 230px; }
.cc-metric { width: auto; min-width: 220px; text-align: left; padding: 9px 10px; font-weight: 600; }
.cc-swatches { display: flex; gap: 6px; align-items: center; }
.swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s var(--ease), border-color 0.15s;
}
.swatch:hover { transform: scale(1.15); }
.swatch.active { border-color: var(--text); transform: scale(1.15); box-shadow: 0 0 8px var(--c); }
#ccType button:disabled { opacity: 0.3; cursor: not-allowed; }

/* ---- criteria challenge ---- */
.chal-idle { text-align: center; padding: 14px 0 6px; }
.chal-idle .s-desc { max-width: 560px; margin: 0 auto 14px; min-height: 0; }
.chal-btn {
  background: var(--chip);
  border: 1px solid var(--stroke);
  color: var(--text);
  padding: 9px 18px;
  border-radius: 13px;
  cursor: pointer;
  font-size: 0.87rem;
  font-weight: 600;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.15s var(--ease), box-shadow 0.25s var(--ease);
}
.chal-btn:hover:not(:disabled) { background: var(--chip-hover); border-color: var(--stroke-brt); }
.chal-btn:active:not(:disabled) { transform: scale(0.95); }
.chal-btn.primary {
  background: linear-gradient(135deg, rgba(233, 79, 100, 0.92), rgba(178, 40, 69, 0.92));
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
  box-shadow: 0 4px 18px rgba(233, 79, 100, 0.4);
}
.chal-btn.primary:hover:not(:disabled) { background: linear-gradient(135deg, rgba(240, 95, 115, 0.95), rgba(192, 50, 80, 0.95)); }
.chal-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.chal-meta { font-size: 0.83rem; color: var(--muted); margin-bottom: 10px; }
.chal-meta b { color: var(--text); }

.crit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.crit-chip {
  text-align: center;
  padding: 10px 6px;
  border-radius: 12px;
  border: 1.5px solid;
  font-size: 0.74rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: transform 0.25s var(--ease);
}
.crit-chip:hover { transform: translateY(-2px); }
.crit-chip b { font-size: 0.85rem; }
.crit-chip .tag { font-weight: 700; letter-spacing: 0.5px; font-size: 0.6rem; }
.crit-chip.hit { border-color: rgba(67, 217, 163, 0.55); background: rgba(67, 217, 163, 0.1); }
.crit-chip.hit .tag { color: var(--good); }
.crit-chip.miss { border-color: rgba(239, 71, 111, 0.5); background: rgba(239, 71, 111, 0.08); }
.crit-chip.miss .tag { color: var(--hot); }

.chal-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.sel-wrap label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 5px;
}
.sel-wrap label em { font-style: normal; font-weight: 700; }
.sel-wrap.hit label em { color: var(--good); }
.sel-wrap.miss label em { color: var(--hot); }
.chal-select {
  width: 100%;
  padding: 9px 6px;
  border-radius: 11px;
  border: 1.5px solid var(--stroke);
  background: var(--chip);
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.chal-select:focus { outline: none; border-color: var(--cold); }
.sel-wrap.hit .chal-select { border-color: rgba(67, 217, 163, 0.45); }
.sel-wrap.miss .chal-select { border-color: rgba(239, 71, 111, 0.4); }
.sel-wrap.sp .chal-select { border-color: rgba(245, 185, 66, 0.5); }
.sel-wrap.ok .chal-select { border-color: var(--good); background: rgba(67, 217, 163, 0.14); box-shadow: 0 0 14px rgba(67, 217, 163, 0.25); }
.sel-wrap.bad .chal-select { border-color: var(--hot); background: rgba(239, 71, 111, 0.14); box-shadow: 0 0 14px rgba(239, 71, 111, 0.25); }

.chal-warn {
  background: rgba(245, 185, 66, 0.12);
  border: 1px solid rgba(245, 185, 66, 0.5);
  color: var(--accent-2);
  border-radius: 11px;
  padding: 9px 13px;
  font-size: 0.82rem;
  margin-bottom: 12px;
  animation: pop 0.3s var(--ease) both;
}
.chal-result {
  border-radius: 11px;
  padding: 11px 14px;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
  animation: pop 0.35s var(--ease) both;
}
.chal-result.win { background: rgba(67, 217, 163, 0.13); border: 1px solid rgba(67, 217, 163, 0.55); color: var(--good); }
.chal-result.lose { background: rgba(239, 71, 111, 0.11); border: 1px solid rgba(239, 71, 111, 0.5); color: var(--hot); }

.chal-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.chal-history { margin-top: 16px; border-top: 1px solid var(--stroke); padding-top: 12px; }
.chal-hist-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-weight: 650;
  font-size: 0.88rem;
  margin-bottom: 9px;
}
.chal-hist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--chip);
  border: 1px solid var(--stroke);
  border-radius: 11px;
  padding: 7px 11px;
  margin-bottom: 6px;
  transition: background 0.25s var(--ease);
}
.chal-hist-row:hover { background: var(--chip-hover); }
.hist-line { font-family: Consolas, "Cascadia Mono", monospace; font-weight: 700; font-size: 0.83rem; }
.hist-meta { font-size: 0.72rem; color: var(--muted); flex: 1; }
.chal-hist-btns { display: flex; gap: 5px; }
.mini-btn {
  background: var(--chip);
  border: 1px solid var(--stroke);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.72rem;
  transition: background 0.2s, border-color 0.2s, transform 0.15s var(--ease);
}
.mini-btn:hover { background: var(--chip-hover); border-color: var(--stroke-brt); }
.mini-btn:active { transform: scale(0.92); }

/* ---- light theme fine-tuning ---- */
:root[data-theme="light"] .orbs { opacity: 0.9; }
:root[data-theme="light"] .o1 { background: #ffd3e0; }
:root[data-theme="light"] .o2 { background: #c9dcff; }
:root[data-theme="light"] .o3 { background: #ffe7c4; }
:root[data-theme="light"] .island {
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 18px 46px rgba(35, 48, 90, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
:root[data-theme="light"] .panel,
:root[data-theme="light"] .card,
:root[data-theme="light"] .side-nav {
  box-shadow: 0 10px 30px rgba(35, 48, 90, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
:root[data-theme="light"] .custom-pop input { color-scheme: light; }
:root[data-theme="light"] .seg button.active,
:root[data-theme="light"] #timeSeg button.active { color: #fff; }
:root[data-theme="light"] .error-banner { background: rgba(255, 226, 232, 0.85); color: #8c1330; }
:root[data-theme="light"] .logo { filter: drop-shadow(0 2px 10px rgba(233, 79, 100, 0.35)); }

/* ---- responsive ---- */
@media (max-width: 980px) {
  .layout { display: flex; flex-direction: column; }
  .side-nav {
    order: -1;
    position: sticky;
    top: 10px;
    z-index: 60;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    max-height: none;
    padding: 8px;
    gap: 4px;
  }
  .nav-label { display: none; }
  .nav-item { flex: none; padding: 7px 10px; }
  .nav-item:hover { transform: none; }
  .island { bottom: 10px; gap: 8px; padding: 9px 10px; }
  .custom-pop { right: auto; left: 50%; transform: translateX(-50%); }
  body { padding-bottom: 170px; }
}
