/* ============================================
   DP Battle — public site
   Aesthetic: editorial-meets-arena. Cream paper,
   ink black, electric red accent, sharp serifs.
   ============================================ */

:root {
  --paper: #f4efe6;
  --paper-2: #ebe4d4;
  --ink: #161413;
  --ink-soft: #2a2622;
  --muted: #7a716a;
  --line: #1a1817;
  --accent: #e7311a;
  --accent-2: #ffb800;
  --win: #1f7a3a;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 2px 2px 0 var(--ink);
  --radius: 0;
  --container: 1180px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background-image:
    radial-gradient(rgba(0,0,0,0.04) 1px, transparent 1px);
  background-size: 3px 3px;
  mix-blend-mode: multiply;
  opacity: 0.6;
}

.container { max-width: var(--container); margin: 0 auto; padding: 0 24px; position: relative; z-index: 2; }

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
hr { border: 0; border-top: 2px solid var(--ink); margin: 32px 0; }

h1, h2, h3, h4 { font-family: "Instrument Serif", Georgia, serif; font-weight: 400; letter-spacing: -0.01em; line-height: 1.05; margin: 0 0 0.5em; }
h1 { font-size: clamp(2.6rem, 6vw, 5rem); }
h2 { font-size: clamp(2rem, 4vw, 3rem); }
h3 { font-size: 1.7rem; }
h4 { font-size: 1.1rem; font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.mono { font-family: "JetBrains Mono", monospace; }
.serif { font-family: "Instrument Serif", Georgia, serif; }
.italic { font-style: italic; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 0.95rem; font-weight: 600;
  padding: 10px 18px;
  border: 2px solid var(--ink); background: var(--paper);
  color: var(--ink); cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  text-decoration: none;
  border-radius: var(--radius);
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); color: var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { color: white; }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ink:hover { color: var(--paper); }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-ghost:hover { box-shadow: var(--shadow-sm); }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 24px; font-size: 1.05rem; }

/* ---------- Nav ---------- */
.site-nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
  backdrop-filter: blur(6px);
}
.nav-inner { display: flex; align-items: center; gap: 24px; min-height: 70px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: "Instrument Serif", serif; font-size: 1.5rem; font-weight: 400; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; background: var(--ink); color: var(--accent-2); font-size: 1.3rem; border-radius: 50%; }
.brand-name { letter-spacing: -0.01em; font-style: italic; }
.nav-links { margin-left: auto; display: flex; gap: 28px; font-weight: 500; }
.nav-links a { padding: 6px 0; border-bottom: 2px solid transparent; }
.nav-links a:hover { border-color: var(--ink); color: var(--ink); }
.nav-actions { display: flex; align-items: center; gap: 12px; }

.nav-menu { position: relative; }
.nav-menu summary { list-style: none; cursor: pointer; }
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-avatar { width: 40px; height: 40px; border: 2px solid var(--ink); border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--paper-2); }
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-fallback { font-weight: 700; font-size: 1rem; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); background: var(--paper); border: 2px solid var(--ink); box-shadow: var(--shadow); min-width: 180px; }
.menu-pop a { display: block; padding: 10px 16px; border-bottom: 1px solid var(--paper-2); }
.menu-pop a:last-child { border-bottom: 0; }
.menu-pop a:hover { background: var(--accent); color: white; }
/* Sign-out is a POST form now (CSRF-protected); make its button look like
   the sibling links in the dropdown. */
.menu-pop-form { margin: 0; }
.menu-pop-link { display: block; width: 100%; padding: 10px 16px; border: 0;
  border-top: 1px solid var(--paper-2); background: none; font: inherit;
  color: inherit; text-align: left; cursor: pointer; }
.menu-pop-link:hover { background: var(--accent); color: white; }

/* ---------- Flash ---------- */
.flash-stack { padding-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border: 2px solid var(--ink);
  background: var(--paper-2);
  font-weight: 500; box-shadow: var(--shadow-sm);
}
.flash-success { background: #d4ebd9; }
.flash-danger { background: #f7d4d0; }
.flash-warning { background: #fcedb6; }
.flash-info { background: #d4e3f7; }
.flash-x { background: none; border: 0; font-size: 1.4rem; cursor: pointer; line-height: 1; padding: 0 4px; }

/* ---------- Hero ---------- */
.hero {
  padding: 80px 0 60px;
  border-bottom: 2px solid var(--ink);
  position: relative;
  overflow: hidden;
}
.hero-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 48px; align-items: center; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: "JetBrains Mono", monospace; font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.12em;
  padding: 6px 12px; background: var(--ink); color: var(--accent-2);
}
.hero-title {
  font-size: clamp(3rem, 7vw, 6.5rem); margin: 16px 0;
}
.hero-title em { color: var(--accent); font-style: italic; }
.hero-title .strike { background: var(--ink); color: var(--paper); padding: 0 12px; transform: rotate(-1deg); display: inline-block; }
.hero-sub { font-size: 1.2rem; color: var(--ink-soft); max-width: 520px; margin-bottom: 32px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }

.hero-vs {
  position: relative; aspect-ratio: 1/1.2; max-width: 420px; margin-left: auto;
}
.hero-card { position: absolute; width: 70%; aspect-ratio: 3/4; border: 2px solid var(--ink); background: var(--paper-2); box-shadow: var(--shadow); overflow: hidden; }
.hero-card.left { top: 0; left: 0; transform: rotate(-4deg); background: linear-gradient(135deg, #fcedb6, #ffb800); }
.hero-card.right { bottom: 0; right: 0; transform: rotate(5deg); background: linear-gradient(135deg, #f7d4d0, #e7311a); }
.hero-card-label { position: absolute; bottom: 12px; left: 12px; font-family: "Instrument Serif", serif; font-size: 1.5rem; font-style: italic; color: var(--ink); }
.hero-vs-mark { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: "Instrument Serif", serif; font-size: 5rem; color: var(--ink); z-index: 5; }
.hero-vs-mark span { background: var(--paper); border: 2px solid var(--ink); padding: 0 20px; box-shadow: var(--shadow); }

@media (max-width: 880px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-vs { max-width: 320px; margin: 0 auto; }
}

/* ---------- Stats Strip ---------- */
.stats-strip {
  background: var(--ink); color: var(--paper);
  padding: 28px 0; border-bottom: 2px solid var(--ink);
}
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-num { font-family: "Instrument Serif", serif; font-size: 2.8rem; line-height: 1; color: var(--accent-2); }
.stat-label { font-family: "JetBrains Mono", monospace; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; opacity: 0.7; }
@media (max-width: 700px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Sections ---------- */
.section { padding: 64px 0; }
.section-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 32px; gap: 24px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head .lead { color: var(--muted); max-width: 480px; }

/* ---------- Contest Cards ---------- */
.contest-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
@media (max-width: 900px) { .contest-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .contest-grid { grid-template-columns: 1fr; } }

.contest-card {
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.contest-card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.contest-vs {
  display: grid; grid-template-columns: 1fr auto 1fr;
  background: var(--paper-2);
  position: relative;
}
.contest-pic { aspect-ratio: 1/1; overflow: hidden; position: relative; }
.contest-pic img { width: 100%; height: 100%; object-fit: cover; }
.contest-pic.win::before { content: "WINNER"; position: absolute; top: 8px; left: 8px; font-family: "JetBrains Mono", monospace; font-size: 0.65rem; padding: 3px 6px; background: var(--win); color: white; letter-spacing: 0.1em; z-index: 2; }
.contest-vs-mark { display: flex; align-items: center; justify-content: center; font-family: "Instrument Serif", serif; font-size: 1.5rem; font-style: italic; padding: 0 12px; background: var(--ink); color: var(--accent-2); }
.contest-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.contest-title { font-family: "Instrument Serif", serif; font-size: 1.15rem; line-height: 1.2; }
.contest-meta { display: flex; justify-content: space-between; align-items: center; font-family: "JetBrains Mono", monospace; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.contest-bar { height: 6px; background: var(--paper-2); border: 2px solid var(--ink); display: flex; }
.contest-bar .a { background: var(--accent); }
.contest-bar .b { background: var(--ink); }

.badge {
  display: inline-block; font-family: "JetBrains Mono", monospace;
  font-size: 0.65rem; padding: 2px 8px; letter-spacing: 0.1em;
  border: 1.5px solid var(--ink); background: var(--paper);
}
.badge.live { background: var(--accent); color: white; border-color: var(--accent); }
.badge.live::before { content: "●"; margin-right: 4px; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.badge.ended { background: var(--ink); color: var(--paper); }

/* ---------- Leaderboard ---------- */
.lb-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--paper); border: 2px solid var(--ink);
  box-shadow: var(--shadow);
}
.lb-table th, .lb-table td { padding: 14px 18px; border-bottom: 1.5px solid var(--paper-2); text-align: left; }
.lb-table th { background: var(--ink); color: var(--paper); font-family: "JetBrains Mono", monospace; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; }
.lb-table tbody tr:hover { background: var(--paper-2); }
.lb-rank { font-family: "Instrument Serif", serif; font-size: 1.4rem; font-style: italic; }
.lb-rank.gold { color: #c79a00; }
.lb-rank.silver { color: #8a8a8a; }
.lb-rank.bronze { color: #a86a3d; }
.lb-user { display: flex; align-items: center; gap: 12px; }
.lb-avatar { width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--ink); object-fit: cover; }

/* ---------- Forms ---------- */
.form-page { max-width: 480px; margin: 64px auto; padding: 40px; background: var(--paper); border: 2px solid var(--ink); box-shadow: var(--shadow); }
.form-page h1 { font-size: 2.4rem; margin-bottom: 8px; }
.form-page .lead { color: var(--muted); margin-bottom: 32px; }
.form-row { margin-bottom: 18px; }
.form-row label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; }
.form-row .hint { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 4px; font-family: "JetBrains Mono", monospace; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], textarea, select, input[type=file] {
  width: 100%; padding: 11px 14px; font-size: 0.95rem;
  border: 2px solid var(--ink); background: var(--paper);
  font-family: inherit; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; box-shadow: var(--shadow-sm); transform: translate(-1px, -1px); }
.form-divider { display: flex; align-items: center; gap: 12px; margin: 24px 0; color: var(--muted); font-family: "JetBrains Mono", monospace; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; }
.form-divider::before, .form-divider::after { content: ""; flex: 1; height: 1.5px; background: var(--ink); opacity: 0.3; }

.social-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 12px; border: 2px solid var(--ink); background: var(--paper); margin-bottom: 10px; font-weight: 600; }
.social-btn:hover { box-shadow: var(--shadow-sm); transform: translate(-1px, -1px); }
.social-btn.fb { background: #1877f2; color: white; }

.checkrow { display: flex; align-items: center; gap: 8px; }
.checkrow input { width: auto; }

/* ---------- Tabs (for picture source) ---------- */
.tabs { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 2px solid var(--ink); }
.tab-btn {
  padding: 10px 18px; background: transparent; border: 2px solid transparent;
  border-bottom: 0; cursor: pointer; font-weight: 600; font-family: inherit;
  margin-bottom: -2px;
}
.tab-btn.active { border-color: var(--ink); border-bottom-color: var(--paper); background: var(--paper); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ---------- Contest detail page ---------- */
.contest-arena {
  padding: 48px 0;
}
.contest-meta-bar { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; margin-bottom: 24px; }
.countdown { font-family: "JetBrains Mono", monospace; font-size: 1.1rem; padding: 4px 10px; background: var(--ink); color: var(--accent-2); }

.battle-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 24px; align-items: stretch; margin: 32px 0; }
@media (max-width: 760px) { .battle-grid { grid-template-columns: 1fr; } .battle-vs-mark { transform: rotate(90deg); } }
.battle-side { display: flex; flex-direction: column; gap: 12px; }
.battle-pic-wrap {
  aspect-ratio: 1/1; border: 3px solid var(--ink);
  background: var(--paper-2); overflow: hidden; position: relative;
  box-shadow: var(--shadow);
}
.battle-pic-wrap img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.battle-pic-wrap:hover img { transform: scale(1.04); }
.battle-side.winner .battle-pic-wrap { border-color: var(--win); box-shadow: 4px 4px 0 var(--win); }
.battle-side.winner::after { content: "WINNER"; position: absolute; }

.battle-name { font-family: "Instrument Serif", serif; font-size: 1.6rem; font-style: italic; }
.battle-percent { font-family: "JetBrains Mono", monospace; font-size: 1.3rem; }
.battle-votes { font-family: "JetBrains Mono", monospace; color: var(--muted); font-size: 0.85rem; }
.battle-vs-mark { display: flex; align-items: center; justify-content: center; font-family: "Instrument Serif", serif; font-size: 4rem; font-style: italic; }

.vote-bar { height: 14px; border: 2px solid var(--ink); display: flex; box-shadow: var(--shadow-sm); margin: 24px 0; }
.vote-bar .a { background: var(--accent); transition: width 0.6s ease; }
.vote-bar .b { background: var(--ink); transition: width 0.6s ease; }

.share-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 16px; border: 2px solid var(--ink); background: var(--paper-2); box-shadow: var(--shadow-sm); }
.share-url { flex: 1; font-family: "JetBrains Mono", monospace; font-size: 0.85rem; padding: 8px 12px; background: var(--paper); border: 1.5px solid var(--ink); min-width: 200px; word-break: break-all; }

/* ---------- Static page styling (privacy/terms/about) ---------- */
.prose { max-width: 720px; margin: 0 auto; padding: 64px 24px; }
.prose h1 { font-size: 3.2rem; margin-bottom: 8px; }
.prose .lead { font-size: 1.2rem; color: var(--muted); font-style: italic; margin-bottom: 32px; font-family: "Instrument Serif", serif; }
.prose h2 { font-size: 2rem; margin-top: 40px; }
.prose h3 { font-size: 1.3rem; font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; margin-top: 24px; }
.prose p, .prose li { font-size: 1.02rem; }
.prose ul { padding-left: 20px; }

/* ---------- Footer ---------- */
.site-foot { background: var(--ink); color: var(--paper); padding: 56px 0 24px; margin-top: 80px; }
.foot-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1.2fr; gap: 48px; }
@media (max-width: 800px) { .foot-grid { grid-template-columns: repeat(2, 1fr); } }
.foot-grid .brand-mark { background: var(--accent); }
.foot-grid h4 { color: var(--accent-2); margin-bottom: 14px; }
.foot-grid ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.foot-grid a:hover { color: var(--accent-2); }
.foot-tag { color: rgba(244,239,230,0.7); font-size: 0.9rem; max-width: 280px; margin-top: 12px; }
.foot-form { display: flex; gap: 6px; margin-top: 12px; }
.foot-form input { background: var(--ink-soft); color: var(--paper); border-color: var(--paper); flex: 1; }
.foot-form input::placeholder { color: rgba(244,239,230,0.5); }
.foot-base { margin-top: 40px; padding-top: 24px; border-top: 1.5px solid rgba(244,239,230,0.2); display: flex; justify-content: space-between; font-family: "JetBrains Mono", monospace; font-size: 0.75rem; opacity: 0.6; }
.foot-mono { letter-spacing: 0.1em; }

/* ---------- Reveal animation ---------- */
.reveal { animation: reveal 0.8s ease both; }
.reveal-1 { animation-delay: 0.05s; }
.reveal-2 { animation-delay: 0.15s; }
.reveal-3 { animation-delay: 0.25s; }
.reveal-4 { animation-delay: 0.35s; }
@keyframes reveal {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Empty state ---------- */
.empty {
  padding: 80px 24px; text-align: center; border: 2px dashed var(--ink); background: var(--paper-2);
}
.empty h3 { font-family: "Instrument Serif", serif; font-style: italic; }
.empty p { color: var(--muted); margin-bottom: 16px; }

/* ============================================================
   MOBILE OPTIMIZATIONS
   Comprehensive responsive rules added after initial design.
   ============================================================ */

/* Container padding on small screens */
@media (max-width: 640px) {
  .container { padding: 0 16px; }
}

/* ---- Top nav ---- */
@media (max-width: 760px) {
  .nav-inner { gap: 12px; min-height: 60px; flex-wrap: wrap; }
  .brand-name { font-size: 1.25rem; }
  .brand-mark { width: 32px; height: 32px; font-size: 1.1rem; }
  .nav-links { display: none; }  /* hidden, we'll show in a slide-down on the next breakpoint */
  .nav-actions .btn { padding: 8px 12px; font-size: 0.85rem; }
  .nav-actions .btn-primary { letter-spacing: -0.01em; }
}

/* ---- Hero ---- */
@media (max-width: 880px) {
  .hero { padding: 56px 0 40px; }
  .hero-title { font-size: clamp(2.5rem, 9vw, 3.6rem); }
  .hero-sub { font-size: 1.05rem; }
  .hero-cta .btn { font-size: 0.95rem; padding: 12px 18px; }
}
@media (max-width: 480px) {
  .hero { padding: 40px 0 32px; }
  .hero-title { font-size: 2.4rem; line-height: 1.05; }
  .hero-vs { max-width: 260px; }
  .hero-cta { flex-direction: column; }
  .hero-cta .btn { width: 100%; }
}

/* ---- Stats strip ---- */
@media (max-width: 480px) {
  .stats-strip { padding: 20px 0; }
  .stat-num { font-size: 2.1rem; }
  .stat-label { font-size: 0.65rem; }
  .stats-grid { gap: 16px; }
}

/* ---- Sections ---- */
@media (max-width: 640px) {
  .section { padding: 40px 0; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 24px; }
  h2 { font-size: 2rem !important; }
}

/* ---- Contest grid: full width on phone ---- */
@media (max-width: 480px) {
  .contest-grid { grid-template-columns: 1fr !important; gap: 16px; }
  .contest-card .contest-vs-mark { font-size: 1.1rem; padding: 0 8px; }
  .contest-title { font-size: 1.05rem; }
}

/* ---- Contest detail / battle page ---- */
@media (max-width: 760px) {
  .contest-arena { padding: 32px 0; }
  .battle-grid { grid-template-columns: 1fr; gap: 16px; }
  .battle-vs-mark { transform: none; font-size: 2.4rem; padding: 8px 0; }
  .contest-meta-bar { gap: 12px; }
  .countdown { font-size: 0.95rem; }
  .battle-name { font-size: 1.3rem; }
  .battle-percent { font-size: 1.1rem; }
}
@media (max-width: 480px) {
  .share-row { padding: 12px; gap: 6px; }
  .share-row .btn { font-size: 0.8rem; padding: 8px 12px; }
  .share-url { font-size: 0.75rem; padding: 6px 10px; }
}

/* ---- Leaderboard table: scroll horizontally instead of cramping ---- */
@media (max-width: 640px) {
  .lb-table { font-size: 0.85rem; display: block; overflow-x: auto; white-space: nowrap; }
  .lb-table th, .lb-table td { padding: 10px 12px; }
  .lb-rank { font-size: 1.1rem; }
  .lb-avatar { width: 28px; height: 28px; }
}

/* ---- Forms ---- */
@media (max-width: 640px) {
  .form-page { padding: 24px 20px; margin: 32px 16px; }
  .form-page h1 { font-size: 1.9rem; }
}

/* Profile page-specific */
.profile-summary {
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.profile-summary-meta { flex: 1; min-width: 200px; }
.profile-avatar { width: 120px; height: 120px; border-radius: 50%; border: 3px solid var(--ink); object-fit: cover; }
.profile-avatar-fallback {
  background: var(--paper-2);
  display: flex; align-items: center; justify-content: center;
  font-family: "Instrument Serif", serif; font-size: 3rem; font-style: italic;
}
.profile-form {
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
  padding: 24px;
}
@media (max-width: 480px) {
  .profile-summary { padding: 16px; gap: 16px; flex-direction: column; text-align: center; }
  .profile-form { padding: 18px; }
  .profile-avatar { width: 96px; height: 96px; }
  .profile-avatar-fallback { font-size: 2.4rem; }
}

/* ---- Footer ---- */
@media (max-width: 640px) {
  .site-foot { padding: 36px 0 16px; margin-top: 48px; }
  .foot-grid { grid-template-columns: 1fr; gap: 24px; }
  .foot-base { flex-direction: column; gap: 8px; text-align: center; }
}

/* ---- Tabs (contest creation, etc.) ---- */
@media (max-width: 480px) {
  .tabs { flex-wrap: wrap; }
  .tab-btn { padding: 8px 12px; font-size: 0.85rem; flex: 1; min-width: 0; }
}

/* ---- How-it-works cards ---- */
@media (max-width: 760px) {
  .contest-grid[style*="repeat(3"] { grid-template-columns: 1fr !important; }
}

/* ---- General touch-friendly buttons ---- */
@media (hover: none) and (pointer: coarse) {
  .btn { min-height: 44px; }
}

/* ---- Long text and URLs in forms ---- */
input[type=text], input[type=email], input[type=password], input[type=url] {
  word-break: break-word;
}

/* ---- Recaptcha frame: tame the 304px width on tiny screens ---- */
@media (max-width: 360px) {
  .g-recaptcha { transform: scale(0.85); transform-origin: 0 0; }
}

/* ---- Prose pages (privacy, terms, about) ---- */
@media (max-width: 640px) {
  .prose { padding: 40px 16px; }
  .prose h1 { font-size: 2.4rem; }
  .prose h2 { font-size: 1.6rem; }
}

/* ---- User profile header card ---- */
@media (max-width: 640px) {
  .container > div[style*="display:flex"][style*="align-items:center"][style*="border:2px solid var(--ink)"] {
    flex-direction: column !important;
    text-align: center;
    padding: 20px !important;
  }
}
