/* ===== Self-hosted fonts (variable) — cozy & rounded ===== */
@font-face {
  font-family: "Baloo 2";
  src: url("/fonts/Baloo2.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("/fonts/Nunito.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}

/* ===== Design tokens — "cozy paper" collection journal ===== */
:root {
  /* Warm paper palette */
  --bg: #f4ebda;
  --bg-surface: #fffdf7;
  --bg-topbar: #efe3cd;
  --text: #4a3f33;
  --text-secondary: #8a7a64;
  --text-muted: #b1a085;
  --border: #e4d6bd;
  --border-light: #ece2cf;
  --accent: #e2884a;
  --accent-deep: #cf6f31;
  --accent-soft: #fbe8d4;

  /* Tag colors (Danbooru convention; kept for tagStyle) */
  --tag-general: #2f7bd6;
  --tag-character: #3f9e5f;
  --tag-copyright: #9a4fb0;
  --tag-meta: #c08a1e;

  /* Tier colors (warm-harmonised) */
  --tier-r: #a89685;
  --tier-sr: #5b93c9;
  --tier-ssr: #a06cd0;
  --tier-ur: #e0962f;

  /* Rarity tiers (by EP points) */
  --rar-uncommon: #3f8f5f;
  --rar-rare: #3f7fc0;
  --rar-epic: #9b5cc8;
  --rar-legendary: #b07d12;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 2px 8px rgba(120,90,50,0.10), 0 1px 2px rgba(120,90,50,0.06);
  --shadow-lift: 0 8px 20px rgba(120,90,50,0.18);

  --font-display: "Baloo 2", ui-rounded, "Hiragino Maru Gothic ProN", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --overlay-bg: rgba(60,44,28,0.55);
}

[data-theme="dark"] {
  /* Warm espresso night (deep) */
  --bg: #161009;
  --bg-surface: #221a12;
  --bg-topbar: #2a2017;
  --text: #ece0cd;
  --text-secondary: #bda88c;
  --text-muted: #897760;
  --border: #3b2d20;
  --border-light: #2c2118;
  --accent: #f0a368;
  --accent-deep: #f6b783;
  --accent-soft: #3c2d20;

  --tag-general: #5a9fff;
  --tag-character: #5fbf7f;
  --tag-copyright: #c089d6;
  --tag-meta: #d8a93a;

  --tier-r: #b7a78f;
  --tier-sr: #76a9d8;
  --tier-ssr: #b585e0;
  --tier-ur: #f0b24a;

  --rar-uncommon: #6cc28a;
  --rar-rare: #6aa8e8;
  --rar-epic: #c089ea;
  --rar-legendary: #f0c44a;

  --shadow: 0 2px 10px rgba(0,0,0,0.35), 0 1px 2px rgba(0,0,0,0.25);
  --shadow-lift: 0 10px 24px rgba(0,0,0,0.45);
  --overlay-bg: rgba(15,10,6,0.7);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-body);
  background-color: var(--bg);
  /* faint journal-paper dots */
  background-image: radial-gradient(rgba(120,90,50,0.05) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
[data-theme="dark"] body { background-image: radial-gradient(rgba(255,240,210,0.035) 1.2px, transparent 1.2px); }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; }

/* ===== Topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1rem;
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(255,255,255,0.4) inset, var(--shadow);
}
.topbar-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--accent-deep);
  letter-spacing: 0.01em;
}
.topbar-title::after { content: " ✿"; font-size: 0.9em; color: var(--accent); }
.topbar-spacer { flex: 1; }
.handle { font-size: 0.9rem; font-weight: 700; color: var(--text-secondary); }

/* ===== Buttons ===== */
[hidden] { display: none !important; }

.btn {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.42rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text);
  cursor: pointer;
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px) rotate(-0.6deg); box-shadow: var(--shadow-lift); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-sm { padding: 0.28rem 0.6rem; font-size: 0.8rem; }
.btn-icon {
  background: var(--bg-surface);
  font-size: 1.1rem;
  padding: 0.25rem;
  min-width: 40px;
  min-height: 40px;
  justify-content: center;
  border-radius: 999px;
}

/* ===== Layout ===== */
#main-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
}
section { margin-bottom: 1.5rem; }

/* Shared card surface */
.post-layout, .share-card, .daily-timer, .roll-start, .overlay-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ===== Roll / Post layout (booru post-page, cozied up) ===== */
.post-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.1rem;
  padding: 1rem;
}
.post-image-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.post-image-frame {
  position: relative;
  display: inline-block;
  line-height: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.post-image {
  max-height: 70vh;
  max-width: 100%;
  border-radius: var(--radius-sm);
  transition: opacity 0.35s ease;
}
.post-image.pending { opacity: 0; }

/* Denoise-reveal canvas, overlaid exactly on the image until it hands off. */
.reveal-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.reveal-canvas.done { opacity: 0; }

/* Tier finales — a glow swell as a high pull resolves. */
.post-image-frame.finale-ssr { animation: finaleGlow 1.1s ease-out; --finale: var(--tier-ssr); }
.post-image-frame.finale-ur { animation: finaleGlow 1.4s ease-out, finaleShake 0.5s ease-in-out; --finale: var(--tier-ur); }
@keyframes finaleGlow {
  0%   { box-shadow: 0 0 0 0 transparent; }
  30%  { box-shadow: 0 0 30px 7px var(--finale, var(--accent)); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes finaleShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.post-meta {
  display: flex;
  flex-direction: column;
  justify-content: center; /* centre the result card in the tall sidebar */
  gap: 0.6rem;
  transition: opacity 0.4s ease;
}
.post-meta.pending { opacity: 0; }
.post-meta.meta-pop { animation: metaPop 0.45s cubic-bezier(.2,.8,.2,1); }
@keyframes metaPop {
  0%   { transform: translateY(8px) scale(0.96); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
/* Result card — gacha-style payoff panel: tier ribbon on top, hero EP, standing. */
.result-card {
  --tier-color: var(--tier-r);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
  text-align: center;
  background: color-mix(in srgb, var(--tier-color) 9%, var(--bg-surface));
  box-shadow: var(--shadow);
}
.result-tier {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.8rem 0.5rem;
  background: var(--tier-color);
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.15);
}
.result-tier-name { font-family: var(--font-display); font-weight: 800; font-size: 2.1rem; line-height: 1; letter-spacing: 0.06em; }
.result-tier-stars { font-size: 1rem; letter-spacing: 0.2em; line-height: 1; }
.ep-display {
  font-family: var(--font-display);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: 3.8rem;
  line-height: 1;
  color: var(--text);
  padding: 1.3rem 0.5rem 0.25rem;
}
.ep-display .ep-value::after { content: " EP"; font-size: 0.3em; font-weight: 700; color: var(--text-muted); vertical-align: 0.6em; margin-left: 0.1em; }
.ep-display.ep-flash { animation: epPop 0.9s cubic-bezier(.2,.8,.2,1); }
@keyframes epPop {
  0%   { transform: scale(1.2); color: var(--tier-color); }
  100% { transform: scale(1); color: var(--text); }
}
.pct-display {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-secondary);
  padding: 0 0.5rem 1.2rem;
  transition: opacity 0.4s ease;
}
.pct-display.result-hidden { opacity: 0; } /* held until the EP is fully tallied */

/* ===== Holographic card interaction (tilt + glare + tier holo) ===== */
.card3d {
  position: relative;
  transform: perspective(800px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.35s ease;
  will-change: transform;
  /* No text-selection/callout when touching a card to tilt it on mobile, and
     own the touch gesture so the tilt updates live instead of after release. */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}
.card3d.card-active { transition: transform 0.06s ease; }

/* Keep the readable bits crisp above the foil layers (banner BG still shines). */
.result-card .ep-display, .result-card .pct-display { position: relative; z-index: 7; }
.result-tier-name, .result-tier-stars { position: relative; z-index: 7; }
.holo .result-tier-name, .holo .result-tier-stars { text-shadow: 0 1px 5px rgba(0,0,0,0.55); }

/* glare — a bright highlight that tracks the pointer */
.card3d::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 6;
  background: radial-gradient(circle at var(--px, 50%) var(--py, 50%),
    rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 40%);
  opacity: calc(var(--pfc, 0) * 0.6);
  mix-blend-mode: soft-light;
  transition: opacity 0.35s ease;
}

/* holo foil — tiered; already shining at rest, vivid as you tilt */
.holo::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 4;
  background-size: 200% 200%;
  background-position: var(--px, 50%) var(--py, 50%);
  opacity: calc(0.45 + var(--pfc, 0) * 0.55);
  transition: opacity 0.35s ease;
}
.holo-sr::before {
  background-image: linear-gradient(115deg, transparent 34%, rgba(200,225,255,0.85) 46%, #ffffff 50%, rgba(200,225,255,0.85) 54%, transparent 66%);
  mix-blend-mode: soft-light;
}
/* SSR — gold shine (texture pattern TBD) */
.holo-ssr::before {
  background-image: linear-gradient(115deg, transparent 22%, #ffe79e 38%, #ffb52e 46%, #fffbe0 50%, #ffb52e 54%, #ffe79e 62%, transparent 78%);
  mix-blend-mode: color-dodge;
  opacity: calc(0.55 + var(--pfc, 0) * 0.45);
}
/* UR — rainbow shine (texture pattern TBD) */
.holo-ur::before {
  background-image: repeating-linear-gradient(125deg,
    #ff5d6c 0%, #ffd34e 8%, #5dff95 16%, #4ed8ff 24%, #9b6bff 32%, #ff6bd6 40%, #ff5d6c 48%);
  background-size: 220% 220%;
  background-position: var(--px, 50%) var(--py, 50%);
  mix-blend-mode: color-dodge;
  opacity: calc(0.5 + var(--pfc, 0) * 0.45);
  filter: saturate(1.3);
}

/* constant foil sweep — SSR/UR shine even before you touch them */
.holo-shine {
  position: absolute;
  inset: -40%;
  pointer-events: none;
  z-index: 5;
  background: linear-gradient(115deg, transparent 44%, rgba(255,255,255,0.6) 50%, transparent 56%);
  mix-blend-mode: screen;
  opacity: 0.4;
  animation: holoSweep 3.2s ease-in-out infinite;
}
.holo-sr .holo-shine { opacity: 0.26; }
@keyframes holoSweep {
  0%   { transform: translateX(-55%); }
  100% { transform: translateX(55%); }
}

@media (prefers-reduced-motion: reduce) {
  .card3d { transform: none; transition: none; }
  .card3d::after, .holo::before, .holo-shine { display: none; }
}

/* ===== Tags — sticker cloud, coloured by rarity ===== */
.tag-list {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.4rem;
  padding-top: 0.75rem;
  margin-top: 0.25rem;
  border-top: 1px dashed var(--border);
}
.tag-item {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  cursor: default;
  line-height: 1.5;
}
/* pop-in as each is tallied */
.tag-pop { animation: tagPop 0.34s cubic-bezier(.2,.9,.3,1.35); }
@keyframes tagPop {
  0%   { transform: scale(0.55); opacity: 0; }
  60%  { transform: scale(1.14); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Rarity ladder — colour + chip + escalating flair */
.tag-item.rar-common    { color: var(--text-secondary); }
.tag-item.rar-uncommon  { color: var(--rar-uncommon); background: color-mix(in srgb, var(--rar-uncommon) 13%, transparent); }
.tag-item.rar-rare      { color: var(--rar-rare); font-weight: 700; background: color-mix(in srgb, var(--rar-rare) 15%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--rar-rare) 30%, transparent); }
.tag-item.rar-epic      { color: var(--rar-epic); font-weight: 800; background: color-mix(in srgb, var(--rar-epic) 16%, transparent); box-shadow: 0 0 10px color-mix(in srgb, var(--rar-epic) 45%, transparent); }
.tag-item.rar-legendary { color: var(--rar-legendary); font-weight: 800; letter-spacing: 0.02em; background: color-mix(in srgb, var(--rar-legendary) 18%, transparent); animation: rarPulse 1.5s ease-in-out infinite; }
.tag-item.rar-legendary::after { content: " ✨"; }
@keyframes rarPulse {
  0%, 100% { box-shadow: 0 0 6px color-mix(in srgb, var(--rar-legendary) 45%, transparent); }
  50%      { box-shadow: 0 0 16px color-mix(in srgb, var(--rar-legendary) 85%, transparent); }
}

/* Per-chip "+N" — inherits the tier colour, dimmed; tabular so it doesn't jitter. */
.tag-pts { margin-left: 0.2rem; font-size: 0.72rem; font-weight: 800; color: currentColor; opacity: 0.72; font-variant-numeric: tabular-nums; }

/* Score / fame badges (the non-tag EP axes) */
.ep-badge {
  font-weight: 800;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  color: #fff !important;
  box-shadow: var(--shadow);
}
.ep-badge .tag-pts { color: rgba(255, 255, 255, 0.92); opacity: 1; }
.ep-badge.badge-score { background: linear-gradient(135deg, #e6a52e, #d4860b); }
.ep-badge.badge-fame { background: linear-gradient(135deg, #ec5a86, #d6336c); }
.ep-badge.rar-epic      { box-shadow: 0 0 12px color-mix(in srgb, var(--rar-epic) 55%, transparent); }
.ep-badge.rar-legendary { animation: badgePulse 1.5s ease-in-out infinite; }
@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 8px color-mix(in srgb, var(--rar-legendary) 55%, transparent); }
  50%      { box-shadow: 0 0 22px color-mix(in srgb, var(--rar-legendary) 95%, transparent); }
}

/* ===== Roll start (press-to-roll) — journal placeholder ===== */
.roll-start {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  padding: 4rem 1rem;
  border: 2px dashed var(--border);
  background: var(--bg-surface);
}
.roll-start-text { font-size: 1.05rem; font-weight: 600; color: var(--text-secondary); }
.roll-start-btn { font-family: var(--font-display); font-size: 1.15rem; padding: 0.7rem 1.8rem; }
/* Vibrate excitedly on hover — it can't wait to be opened. */
.roll-start-btn:hover { animation: excitedVibrate 0.16s linear infinite; }
@keyframes excitedVibrate {
  0%   { transform: translate(0, 0) rotate(0deg) scale(1.04); }
  20%  { transform: translate(-2px, 1px) rotate(-2.2deg) scale(1.04); }
  40%  { transform: translate(2px, -1px) rotate(2.2deg) scale(1.04); }
  60%  { transform: translate(-1px, -1px) rotate(-1.4deg) scale(1.04); }
  80%  { transform: translate(1px, 1px) rotate(1.4deg) scale(1.04); }
  100% { transform: translate(0, 0) rotate(0deg) scale(1.04); }
}

/* ===== Skip hint (during reveal) ===== */
.skip-hint {
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0.5rem;
  user-select: none;
  animation: skipPulse 1.6s ease-in-out infinite;
}
@keyframes skipPulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

/* ===== Leaderboard overlay ===== */
.leaderboard-box { max-width: 460px; width: calc(100vw - 2rem); text-align: left; }
.leaderboard-box h2 { text-align: center; }
.lb-body { max-height: 60vh; overflow-y: auto; }
.lb-list { list-style: none; display: flex; flex-direction: column; gap: 0.2rem; }
.lb-row {
  display: grid;
  grid-template-columns: 2.4rem 1fr auto auto;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-sm);
}
.lb-row:nth-child(odd) { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.lb-rank { font-family: var(--font-display); font-weight: 800; color: var(--accent-deep); font-variant-numeric: tabular-nums; }
.lb-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-tier { font-family: var(--font-display); font-weight: 800; }
.lb-ep { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text-secondary); }
.lb-row-click { cursor: pointer; transition: background 0.12s ease, transform 0.12s ease; }
.lb-row-click:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.lb-row-click:active { transform: scale(0.99); }
.lb-row-click:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ===== Inline leaderboard (under the share card) ===== */
.lb-inline {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.4rem 0.75rem 0.8rem;
}
.lb-inline-title {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  width: 100%;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  background: none;
  border: none;
  padding: 0.5rem 0.25rem;
  cursor: pointer;
}
.lb-viewall { margin-left: auto; font-family: var(--font-body); font-size: 0.82rem; font-weight: 700; color: var(--accent-deep); }
.lb-inline-title:hover .lb-viewall { text-decoration: underline; }

/* ===== Entry-roll overlay (clicking a leaderboard row) ===== */
.entry-box { max-width: 460px; width: calc(100vw - 2rem); }
.entry-img { max-width: 100%; max-height: 60vh; border-radius: var(--radius-sm); margin: 0 auto; box-shadow: var(--shadow); }
.entry-result { font-size: 1.1rem; font-weight: 800; color: var(--text); }

/* ===== Auth overlay ===== */
.auth-box { max-width: 380px; width: calc(100vw - 2rem); gap: 0.6rem; }
.auth-box h2 { margin-bottom: 0.25rem; }
.auth-box p { margin: 0; font-size: 0.85rem; color: var(--text-secondary); }
.auth-input {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
.auth-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  margin: 0.4rem 0;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border-light); }
.auth-err { color: #d6336c !important; font-weight: 700; font-size: 0.82rem !important; }

/* ===== Share card (Discord-first) ===== */
.share-card { padding: 0.9rem 1rem; display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.share-head { font-family: var(--font-display); font-size: 1.2rem; font-weight: 800; color: var(--text); }
.share-tags { font-size: 0.88rem; font-weight: 700; color: var(--text-secondary); }
/* little sparkle pop when copied */
.btn.copied { animation: copiedPop 0.45s cubic-bezier(.2,.9,.3,1.4); }
@keyframes copiedPop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.14); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) { .btn.copied { animation: none; } }

/* ===== Profile ===== */
.profile-container { margin-top: 1.5rem; }
.profile-handle { font-family: var(--font-display); font-size: 1.25rem; font-weight: 800; margin-bottom: 0.5rem; }
.profile-container h3 { font-size: 1.1rem; margin: 0.5rem 0; }
.guest-banner {
  display: block;
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.9rem; font-weight: 700; color: var(--text-secondary);
  padding: 0.7rem 0.8rem; margin-bottom: 0.75rem;
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  background: var(--accent-soft);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s ease, color 0.12s ease;
}
.guest-banner:hover { border-color: var(--accent); color: var(--text); }
.rename-form { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }
.rename-form input {
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text);
  max-width: 160px;
}
.rename-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ===== History grid — sticker/polaroid collection ===== */
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.7rem;
}
.history-cell {
  display: flex;
  flex-direction: column;
  border: 2px solid var(--tier-r);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-surface);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
  color: var(--text);
}
.history-cell:hover { box-shadow: var(--shadow-lift); } /* tilt handled by .card3d */
.history-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; }
.history-cell-info { padding: 0.4rem 0.5rem; font-size: 0.78rem; display: flex; flex-direction: column; gap: 0.15rem; }
.history-date { color: var(--text-muted); font-weight: 600; }
.history-ep { font-weight: 800; font-variant-numeric: tabular-nums; }
.history-tier { font-family: var(--font-display); font-weight: 800; }
.empty-history {
  font-size: 0.9rem; color: var(--text-muted); font-weight: 600;
  padding: 1.25rem; text-align: center;
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
}

/* ===== Timer ===== */
.daily-timer {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  padding: 0.6rem;
}
.countdown { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-weight: 800; color: var(--accent-deep); }

/* ===== Overlay ===== */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay-bg);
  backdrop-filter: blur(3px);
  z-index: 1000;
  padding: 1rem;
}
.overlay.active { display: flex; }
.overlay-box {
  padding: 1.75rem;
  max-width: 420px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow-lift);
}
.overlay-box h2 { font-size: 1.3rem; }
.overlay-box p { font-size: 0.9rem; color: var(--text-secondary); }
.account-number {
  display: block;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 0.6rem;
  background: var(--accent-soft);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-sm);
  word-break: break-all;
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .post-image, .reveal-canvas, .post-meta, .btn, .history-cell { transition: none; }
  .tag-pop, .meta-pop, .ep-flash, .skip-hint,
  .tag-item.rar-legendary, .ep-badge.rar-legendary,
  .post-image-frame.finale-ssr, .post-image-frame.finale-ur,
  .roll-start-btn:hover { animation: none; }
  .btn:hover, .history-cell:hover { transform: none; }
}

/* ===== Mobile (< 768px) ===== */
@media (max-width: 768px) {
  #main-content { padding: 0.75rem 0.5rem; }
  .post-layout { grid-template-columns: 1fr; }
  .post-image { max-height: 50vh; }
  .history-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-title { font-size: 1.15rem; }
  .overlay-box { margin: 1rem; padding: 1.4rem; }
}
