/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f6f4ec;
  --surface: #ffffff;
  --surface-2: #fbfaf5;
  --text: #1e2a2e;
  --text-muted: #5c6b70;
  --border: #e3ded0;

  --primary: #0e7c86;
  --primary-dark: #095e66;
  --primary-light: #e3f3f2;
  --accent: #f0a63d;
  --accent-dark: #c9821f;
  --danger: #d1495b;
  --success: #1c8a5c;

  --pitch-a: #1f8a4c;
  --pitch-b: #1a7943;
  --gold: #d4a017;
  --gold-dark: #a97b0f;
  --silver: #9aa3ab;
  --silver-dark: #767f86;
  --bronze: #b06a35;
  --bronze-dark: #8a5228;

  --cream: #fffdf7;

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Manrope", var(--sans);

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;

  --shadow-sm: 0 1px 2px rgba(20, 30, 30, 0.06);
  --shadow: 0 6px 20px rgba(20, 40, 40, 0.08);
  --shadow-lg: 0 20px 50px rgba(10, 30, 30, 0.16);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  --header-h: 68px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1a1c;
    --surface: #16262a;
    --surface-2: #1b2c30;
    --text: #eef4f2;
    --text-muted: #a7b7ba;
    --border: #24393e;
    --primary: #22a6ac;
    --primary-dark: #1a8489;
    --primary-light: #16343a;
    --cream: #16262a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}

img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { font-family: var(--display); text-wrap: balance; line-height: 1.12; letter-spacing: -0.01em; font-weight: 800; }
ul, ol { padding: 0; list-style: none; }
::selection { background: var(--accent); color: #fff; }

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

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: 1080px; margin-inline: auto; padding-inline: 1.25rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--text); color: var(--cream);
  z-index: 9999; border-radius: 8px; font-weight: 600;
  transition: top .2s var(--ease-out);
}
.skip-link:focus { top: 1rem; }

.icon { width: 1.1em; height: 1.1em; flex: none; }

/* =============================================================
   4. Typography
   ============================================================= */
h1 { font-size: clamp(1.9rem, 4.6vw, 2.75rem); max-width: 20ch; }
h2 { font-size: clamp(1.5rem, 3.4vw, 2.05rem); margin-bottom: .6rem; }
h3 { font-size: clamp(1.1rem, 2.2vw, 1.3rem); margin-block: 1.4rem .5rem; }
.section-sub { color: var(--text-muted); max-width: 62ch; }

/* =============================================================
   5. Components
   ============================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .85rem 1.3rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: .96rem;
  transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), background .18s var(--ease-out);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow); }

.btn-secondary { background: var(--primary-light); color: var(--primary-dark); }
.btn-secondary:hover { background: var(--border); }

.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }

/* =============================================================
   6. Header
   ============================================================= */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: var(--header-h); gap: 1rem; }
.logo { display: flex; align-items: baseline; gap: .5rem; }
.logo-mark { font-family: var(--display); font-weight: 800; font-size: 1.35rem; color: var(--primary-dark); letter-spacing: -.02em; }
.logo-sub { font-size: .78rem; color: var(--text-muted); display: none; }
@media (min-width: 540px) { .logo-sub { display: inline; } }

.site-nav { display: flex; gap: 1.3rem; font-weight: 600; font-size: .92rem; }
.site-nav a { color: var(--text-muted); transition: color .15s var(--ease-out); }
.site-nav a:hover { color: var(--primary-dark); }

/* =============================================================
   7. Hero + tool card
   ============================================================= */
.hero { padding-block: 2.2rem 1.5rem; }
.hero-sub { margin-top: .6rem; color: var(--text-muted); max-width: 58ch; font-size: 1.05rem; }

.tool-card {
  position: relative;
  margin-top: 1.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  padding-top: calc(1.4rem + 10px);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.tool-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 10px;
  background: repeating-linear-gradient(
    -45deg, var(--pitch-a) 0 14px, var(--pitch-b) 14px 28px
  );
}

.eyebrow {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .78rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  color: var(--primary-dark);
  background: var(--primary-light);
  padding: .3rem .7rem; border-radius: 999px;
  margin-bottom: .7rem;
}

.tool-card-top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-bottom: 1rem; flex-wrap: wrap;
}
.tool-instructions { display: flex; align-items: center; gap: .5rem; color: var(--text-muted); font-size: .92rem; }
.tool-instructions .icon { color: var(--accent-dark); }

.ranking-board { display: flex; flex-direction: column; gap: .55rem; touch-action: none; }

.rank-item {
  display: flex; align-items: center; gap: .8rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .8rem;
  cursor: grab;
  user-select: none;
  position: relative;
  transition: box-shadow .18s var(--ease-out), background .18s var(--ease-out);
}
.rank-item:active { cursor: grabbing; }
.rank-item.is-dragging {
  box-shadow: var(--shadow-lg);
  background: var(--surface);
  z-index: 5;
  cursor: grabbing;
}

.rank-pos {
  flex: none;
  width: 2.1rem; height: 2.1rem;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .95rem;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.5);
}
.rank-item:nth-child(1) .rank-pos { background: linear-gradient(155deg, var(--gold), var(--gold-dark)); color: #fff; }
.rank-item:nth-child(2) .rank-pos { background: linear-gradient(155deg, var(--silver), var(--silver-dark)); color: #fff; }
.rank-item:nth-child(3) .rank-pos { background: linear-gradient(155deg, var(--bronze), var(--bronze-dark)); color: #fff; }
.rank-pos .icon { width: 1.15em; height: 1.15em; }

.rank-badge { flex: none; width: 2.4rem; height: 2.4rem; border-radius: 50%; overflow: hidden; box-shadow: var(--shadow-sm); }
.rank-badge img { width: 100%; height: 100%; }

.rank-name { flex: 1; font-weight: 700; font-size: 1rem; }

.rank-controls { display: flex; gap: .25rem; flex: none; }
.rank-btn {
  width: 2rem; height: 2rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); border: 1px solid var(--border);
  transition: background .15s var(--ease-out), color .15s var(--ease-out);
}
.rank-btn:hover:not(:disabled) { background: var(--primary-light); color: var(--primary-dark); }
.rank-btn:disabled { opacity: .35; cursor: not-allowed; }

.drag-handle { flex: none; color: var(--text-muted); opacity: .6; touch-action: none; padding: .2rem; }

.notice {
  background: var(--primary-light); color: var(--primary-dark);
  border-radius: var(--radius); padding: 1rem; font-size: .92rem;
}

.awards-inputs {
  margin-top: 1.3rem; padding-top: 1.1rem; border-top: 1px dashed var(--border);
}
.awards-inputs-title { font-size: .9rem; font-weight: 700; color: var(--text-muted); margin-bottom: .7rem; }
.awards-fields { display: grid; gap: .8rem; grid-template-columns: 1fr; }
@media (min-width: 540px) { .awards-fields { grid-template-columns: 1fr 1fr; } }
.award-field label {
  display: flex; align-items: center; gap: .4rem;
  font-size: .86rem; font-weight: 700; margin-bottom: .4rem;
}
.award-field label .icon { width: 1.05em; height: 1.05em; color: var(--accent-dark); }
.award-field input[type="text"] {
  width: 100%; padding: .7rem .85rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-size: .95rem;
  transition: border-color .15s var(--ease-out), background .15s var(--ease-out);
}
.award-field input[type="text"]:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.award-field input[type="text"]::placeholder { color: var(--text-muted); }
.award-field .hint { display: block; margin-top: .3rem; font-size: .76rem; color: var(--text-muted); }

.tool-card-actions {
  margin-top: 1.3rem; padding-top: 1.1rem; border-top: 1px dashed var(--border);
  display: flex; flex-wrap: wrap; align-items: center; gap: .8rem;
}
.submit-status { font-size: .88rem; color: var(--text-muted); flex-basis: 100%; }
.submit-status[data-tone="ok"] { color: var(--success); }
.submit-status[data-tone="warn"] { color: var(--accent-dark); }
.submit-status[data-tone="error"] { color: var(--danger); }

.privacy-badge {
  margin-top: 1rem; font-size: .86rem; color: var(--text-muted);
  display: inline-flex; align-items: center; gap: .4rem;
}

/* =============================================================
   8. Ad slots (placeholders only)
   ============================================================= */
.ad-wrap { padding-block: 1.6rem; }
.ad-slot {
  position: relative;
  margin-inline: auto;
  width: 100%;
  border: 2px dashed color-mix(in srgb, var(--text-muted) 45%, transparent);
  border-radius: var(--radius);
  background: repeating-linear-gradient(
    135deg, color-mix(in srgb, var(--text-muted) 6%, transparent) 0 12px,
    transparent 12px 24px
  );
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem;
  color: var(--text-muted);
  text-align: center;
}
.ad-leaderboard { max-width: 728px; min-height: 90px; }
.ad-rectangle { max-width: 336px; min-height: 220px; }
.ad-tag {
  position: absolute; top: .5rem; left: .6rem;
  font-size: .65rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: .15rem .55rem; color: var(--text-muted);
}
.ad-placeholder-text { font-family: var(--display); font-weight: 800; font-size: 1.4rem; letter-spacing: .08em; opacity: .55; }
.ad-dims { font-size: .72rem; opacity: .55; }

/* Corner ad notification */
.ad-corner {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 60;
  width: min(260px, calc(100vw - 2rem));
  background: var(--surface);
  border: 2px dashed color-mix(in srgb, var(--text-muted) 45%, transparent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1.6rem 1rem 1rem;
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  color: var(--text-muted); text-align: center;
  opacity: 0; transform: translateY(12px);
  transition: opacity .3s var(--ease-out), transform .3s var(--ease-out);
}
.ad-corner.is-visible { opacity: 1; transform: translateY(0); }
.ad-corner-close {
  position: absolute; top: .4rem; right: .4rem;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--text-muted); font-size: .8rem;
}
.ad-corner-close:hover { background: var(--border); color: var(--text); }

/* Download interstitial dialog */
.ad-dialog {
  border: none; border-radius: var(--radius-lg);
  padding: 1.4rem; width: min(360px, calc(100vw - 2.5rem));
  box-shadow: var(--shadow-lg); background: var(--surface); color: var(--text);
  position: relative;
}
.ad-dialog::backdrop { background: rgba(10, 20, 20, 0.55); backdrop-filter: blur(2px); }
.ad-dialog-title { font-weight: 700; margin-bottom: 1rem; padding-right: 1.6rem; }
.ad-dialog-close {
  position: absolute; top: .8rem; right: .8rem;
  width: 1.8rem; height: 1.8rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--text-muted);
}
.ad-dialog-close:hover { background: var(--border); color: var(--text); }
.ad-dialog-slot { min-height: 200px; margin-block: .2rem 1.1rem; }
.ad-dialog-continue { width: 100%; }

/* =============================================================
   9. La General
   ============================================================= */
.la-general { padding-block: 1rem 1.5rem; }
.general-table-wrap {
  margin-top: 1.1rem; overflow-x: auto;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.general-table { width: 100%; border-collapse: collapse; min-width: 420px; }
.general-table th, .general-table td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.general-table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); background: var(--surface-2); }
.general-table tbody tr:last-child td { border-bottom: none; }
.general-table .g-team { display: flex; align-items: center; gap: .6rem; font-weight: 700; }
.general-table .g-badge { width: 1.9rem; height: 1.9rem; border-radius: 50%; flex: none; }
.general-loading, .general-error { text-align: center; color: var(--text-muted); padding: 1.4rem !important; }
.general-fallback { margin-top: .8rem; font-size: .88rem; color: var(--text-muted); }

.g-pos {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.8rem; height: 1.8rem; border-radius: 50%;
  background: var(--primary-light); color: var(--primary-dark);
  font-weight: 800; font-size: .82rem;
}
.g-pos.medal-1 { background: linear-gradient(155deg, var(--gold), var(--gold-dark)); color: #fff; }
.g-pos.medal-2 { background: linear-gradient(155deg, var(--silver), var(--silver-dark)); color: #fff; }
.g-pos.medal-3 { background: linear-gradient(155deg, var(--bronze), var(--bronze-dark)); color: #fff; }
.g-pos .icon { width: 1.05em; height: 1.05em; }

.section-title-row { display: flex; align-items: center; gap: .55rem; }
.section-title-row .icon { width: 1.5rem; height: 1.5rem; color: var(--gold-dark); flex: none; }

.awards-grid {
  display: grid; gap: 1rem; margin-top: 1.4rem;
  grid-template-columns: 1fr;
}
@media (min-width: 720px) { .awards-grid { grid-template-columns: 1fr 1fr; } }
.award-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1rem 1.1rem; box-shadow: var(--shadow-sm);
}
.award-card h3 { display: flex; align-items: center; gap: .45rem; margin: 0 0 .7rem; font-size: 1rem; }
.award-card h3 .icon { width: 1.15em; height: 1.15em; color: var(--accent-dark); }
.award-list { display: flex; flex-direction: column; gap: .45rem; }
.award-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .5rem .65rem; border-radius: var(--radius-sm); background: var(--surface-2); font-size: .92rem; }
.award-row .award-name { font-weight: 700; }
.award-row .award-votes { color: var(--text-muted); font-size: .82rem; white-space: nowrap; }
.award-empty { color: var(--text-muted); font-size: .88rem; padding: .4rem .1rem; }

/* =============================================================
   10. Content / prose
   ============================================================= */
.content-seo { padding-block: 1.4rem 2rem; }
.prose p { margin-block: .8rem; max-width: 72ch; color: var(--text); }
.prose ul { list-style: disc; padding-left: 1.3rem; max-width: 72ch; }
.prose li { margin-block: .35rem; }
.prose strong { color: var(--primary-dark); }

/* =============================================================
   11. FAQ
   ============================================================= */
.faq { padding-block: 1rem 3rem; }
.faq-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .95rem 1.1rem; margin-block: .6rem;
}
.faq-item summary { font-weight: 700; cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 1.3rem; color: var(--primary); flex: none; }
.faq-item[open] summary::after { content: "−"; }
.faq-item p { margin-top: .6rem; color: var(--text-muted); }

/* =============================================================
   12. Footer
   ============================================================= */
.site-footer { border-top: 1px solid var(--border); padding-block: 1.8rem; margin-top: 1rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 1.2rem; align-items: flex-start; justify-content: space-between; }
.footer-note { margin-top: .4rem; max-width: 46ch; font-size: .82rem; color: var(--text-muted); }
.footer-tagline { margin-top: .5rem; font-size: .82rem; font-weight: 700; color: var(--primary-dark); }
.footer-nav { display: flex; gap: 1rem; font-size: .88rem; color: var(--text-muted); }
.footer-nav a:hover { color: var(--primary-dark); }

/* =============================================================
   13. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .tool-card { padding: 1.8rem; }
}
@media (min-width: 720px) {
  .rank-name { font-size: 1.05rem; }
  .ad-leaderboard { min-height: 100px; }
}
@media (min-width: 960px) {
  .hero-sub { font-size: 1.12rem; }
}

/* =============================================================
   14. Reduced motion (only intrusive effects)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .ad-corner { transition: none; }
}

/* =============================================================
   15. Export card (offscreen template rendered to PNG)
   ============================================================= */
.export-card {
  position: fixed; top: 0; left: -9999px;
  width: 480px;
  background: #ffffff;
  color: #1e2a2e;
  padding: 2rem;
  border-radius: 20px;
  font-family: var(--sans);
}
.export-head { display: flex; align-items: baseline; gap: .5rem; margin-bottom: 1.1rem; }
.export-logo { font-family: var(--display); font-weight: 800; font-size: 1.5rem; color: var(--primary-dark); }
.export-tag { font-size: .82rem; color: #5c6b70; }
.export-title { font-family: var(--display); font-weight: 800; font-size: 1.25rem; margin-bottom: 1.2rem; color: #1e2a2e; }
.export-list { display: flex; flex-direction: column; gap: .55rem; }
.export-row { display: flex; align-items: center; gap: .8rem; padding: .5rem .6rem; border-bottom: 1px solid #ece6d6; }
.export-row:last-child { border-bottom: none; }
.export-pos {
  flex: none; width: 1.9rem; height: 1.9rem; border-radius: 50%;
  background: var(--primary-light); color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .88rem;
}
.export-row:nth-child(1) .export-pos { background: linear-gradient(155deg, var(--gold), var(--gold-dark)); color: #fff; }
.export-row:nth-child(2) .export-pos { background: linear-gradient(155deg, var(--silver), var(--silver-dark)); color: #fff; }
.export-row:nth-child(3) .export-pos { background: linear-gradient(155deg, var(--bronze), var(--bronze-dark)); color: #fff; }
.export-pos .icon { width: 1.1em; height: 1.1em; }
.export-foot-awards { margin-top: .5rem; text-align: right; font-size: .82rem; color: #5c6b70; }
.export-badge { flex: none; width: 2.1rem; height: 2.1rem; border-radius: 50%; }
.export-name { font-weight: 700; }
.export-foot { margin-top: 1.3rem; text-align: right; font-size: .76rem; color: #8a9598; }
