/* ===== Phase Ledger design system — gacha-dash ===== */
:root {
  --bg: #0e1113;
  --surface: #15191c;
  --surface-raised: #1b2024;
  --text: #f4f1e8;
  --text-muted: #9aa2a6;
  --border: #2a3034;

  --accent: #d6b46b;
  --accent-ink: #17130b;
  --focus: #7cc7ff;

  --success: #78b892;
  --warning: #d7a252;
  --danger: #d66b66;

  --genshin: #c9a75c;
  --wuwa: #65aab3;

  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', 'Cascadia Mono', 'Consolas', monospace;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-6: 24px; --space-8: 32px; --space-12: 48px; --space-16: 64px;

  --radius-control: 6px;
  --radius-card: 10px;
  --radius-drawer: 12px;

  --motion-fast: 160ms ease;
  --motion-med: 220ms ease;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

a { color: var(--accent); }

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-control);
}

.shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px var(--space-16);
}

@media (max-width: 1023px) { .shell { padding-left: 20px; padding-right: 20px; } }
@media (max-width: 767px)  { .shell { padding-left: 16px; padding-right: 16px; } }

/* ---------- Header ---------- */
.header {
  padding-top: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-8);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.brand {
  font-size: 22px;
  line-height: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.freshness {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 13px;
  color: var(--text-muted);
}

.freshness-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.freshness-dot[data-state="live"] { background: var(--success); }
.freshness-dot[data-state="stale"] { background: var(--warning); }
.freshness-dot[data-state="error"] { background: var(--danger); }
.freshness-dot[data-state="loading"] { background: var(--text-muted); }

.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 44px;
  padding: 0 var(--space-3);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  transition: border-color var(--motion-fast), background var(--motion-fast);
}

.refresh-btn:hover { border-color: var(--accent); }
.refresh-btn[data-busy="true"] { opacity: 0.6; pointer-events: none; }

.switcher {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.switcher-btn {
  min-height: 44px;
  padding: 0 var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
  transition: border-color var(--motion-fast), color var(--motion-fast), background var(--motion-fast);
}

.switcher-btn:hover { color: var(--text); }

.switcher-btn[aria-current="true"] {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

/* ---------- Board layout ---------- */
.board {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
}

@media (min-width: 1200px) {
  .board {
    grid-template-columns: 2fr 1fr;
    align-items: start;
    gap: var(--space-8);
  }
  .next-column { position: sticky; top: var(--space-6); }
}

.section-heading {
  font-size: 22px;
  line-height: 28px;
  font-weight: 600;
  margin-bottom: var(--space-4);
}

.game-group + .game-group { margin-top: var(--space-8); }

.game-group-heading {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.game-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.game-dot[data-game="genshin"] { background: var(--genshin); }
.game-dot[data-game="wuwa"] { background: var(--wuwa); }

/* ---------- Current banner grid + card ---------- */
.current-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}

@media (min-width: 768px) {
  .current-grid { grid-template-columns: repeat(2, 1fr); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  transition: border-color var(--motion-med);
  display: flex;
  flex-direction: column;
}

.card:hover { border-color: var(--accent); }

.card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: var(--surface-raised);
  overflow: hidden;
  flex-shrink: 0;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.card-media-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 600;
  color: var(--text-muted);
  background: linear-gradient(160deg, var(--surface-raised), var(--surface));
}

/* Weapon banner: two signature weapons side by side instead of one icon
   stretched into the portrait frame meant for character art. */
.card-media-weapons {
  width: 100%;
  height: 100%;
  display: flex;
  background: linear-gradient(160deg, var(--surface-raised), var(--surface));
}

.card-media-weapons .weapon-slot {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

.card-media-weapons .weapon-slot + .weapon-slot { border-left: 1px solid var(--border); }

.card-media-weapons .weapon-slot img { width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; }

.card-media-weapons .weapon-slot .card-media-fallback { background: none; font-size: 28px; }

.card-edge { position: absolute; top: 0; left: 0; bottom: 0; width: 3px; }
.card-edge[data-game="genshin"] { background: var(--genshin); }
.card-edge[data-game="wuwa"] { background: var(--wuwa); }

.card-badges {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  display: flex;
  gap: var(--space-1);
}

.badge {
  padding: 2px 8px;
  border-radius: var(--radius-control);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: rgba(14, 17, 19, 0.72);
  color: var(--text);
  border: 1px solid var(--border);
}

.badge-new { color: var(--accent); border-color: var(--accent); }
.badge-kind { text-transform: uppercase; }

.card-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
}

.card-title {
  font-size: 18px;
  line-height: 24px;
  font-weight: 600;
}

.card-banner-name {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: 13px;
  color: var(--text-muted);
}

.card-companions {
  font-size: 13px;
  color: var(--text-muted);
}

.card-footer {
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.card-dates {
  font-size: 13px;
  color: var(--text-muted);
}

.countdown {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 24px;
  line-height: 28px;
  font-weight: 600;
  color: var(--accent);
}

@media (max-width: 767px) {
  .countdown { font-size: 20px; line-height: 24px; }
}

/* ---------- 4-star rotation strip (phase-wide, shown once per game) ---------- */
.four-star-strip {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.four-star-strip-label {
  font-size: 11px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.four-star-strip-items {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.four-star-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3) var(--space-1) var(--space-1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
}

.four-star-chip-media {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface-raised);
}

.four-star-chip-media img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }

.four-star-chip-media-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.four-star-chip-name {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}

/* ---------- Limited-time events (current column) ---------- */
.event-section { margin-top: var(--space-6); }

.event-heading {
  font-size: 11px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.event-empty {
  padding: var(--space-4);
  border: 1px dashed var(--border);
  border-radius: var(--radius-control);
  color: var(--text-muted);
  font-size: 13px;
}

.event-ledger {
  list-style: none;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.event-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--space-6);
  padding: var(--space-4) 0;
  padding-inline-start: var(--space-3);
  border-inline-start: 3px solid var(--border);
}

.event-row + .event-row { border-top: 1px solid var(--border); }

.event-row[data-lifecycle="ending-soon"] { border-inline-start-color: var(--danger); }
.event-row[data-lifecycle="just-started"] { border-inline-start-color: var(--success); }

.event-row-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.event-status {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.event-row[data-lifecycle="ending-soon"] .event-status { color: var(--danger); }
.event-row[data-lifecycle="just-started"] .event-status { color: var(--success); }

.event-name {
  font-size: 16px;
  line-height: 22px;
  font-weight: 600;
}

.event-reward {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 65ch;
}

.event-row-time {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  text-align: right;
}

.event-end-label { font-size: 12px; color: var(--text-muted); }

.event-countdown {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.event-row[data-lifecycle="ending-soon"] .event-countdown { color: var(--danger); }

@media (max-width: 640px) {
  .event-row { grid-template-columns: 1fr; row-gap: var(--space-2); }
  .event-row-time { align-items: flex-start; text-align: left; }
}

/* ---------- Upcoming events (next column) ---------- */
.event-upcoming-section { margin-top: var(--space-8); }

.event-upcoming-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.event-upcoming-row {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.event-upcoming-date {
  flex-shrink: 0;
  min-width: 44px;
  padding-top: 2px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.event-upcoming-body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.event-upcoming-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.event-upcoming-name { font-size: 14px; font-weight: 600; }

.event-upcoming-reward {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 65ch;
}

.event-upcoming-starts { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.event-upcoming-date.sk { width: 44px; height: 14px; border-radius: var(--radius-control); }

/* ---------- Upcoming timeline ---------- */
.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.entry {
  display: flex;
  gap: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-3);
  align-items: center;
}

.entry-media {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-control);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface-raised);
}

.entry-media img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }

.entry-media-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-muted);
}

.entry-body { min-width: 0; flex: 1; }

.entry-title { font-size: 15px; font-weight: 600; }

.entry-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
  margin-top: 2px;
}

.entry-date { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Skeletons ---------- */
.sk {
  background: linear-gradient(90deg, var(--surface-raised) 25%, var(--surface) 37%, var(--surface-raised) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-control);
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

.sk-line { height: 14px; margin-top: var(--space-2); }
.sk-w40 { width: 40%; }
.sk-w50 { width: 50%; }
.sk-w60 { width: 60%; }
.sk-w70 { width: 70%; }
.sk-w80 { width: 80%; }

/* ---------- Notices / empty / error ---------- */
.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.notice[data-tone="warning"] { border-color: var(--warning); color: var(--text); }
.notice[data-tone="danger"] { border-color: var(--danger); color: var(--text); }

.notice-retry {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 2px var(--space-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
  min-height: 32px;
}

.empty-section {
  padding: var(--space-6);
  border: 1px dashed var(--border);
  border-radius: var(--radius-card);
  color: var(--text-muted);
  font-size: 14px;
  text-align: left;
}

.error-panel {
  padding: var(--space-8);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  text-align: center;
}

.error-panel p { color: var(--text-muted); margin-bottom: var(--space-4); }

.error-retry {
  min-height: 44px;
  padding: 0 var(--space-6);
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius-control);
  font-weight: 600;
}

/* ---------- Footer ---------- */
.footer {
  margin-top: var(--space-12);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.footer-note { margin-top: var(--space-1); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

