/* PAD: Plant and Defense - website (Phase 42). One stylesheet for every page; mobile first.
   Pixel-theme pass: "Press Start 2P" for display text only (headings, brand, buttons, badges) --
   body copy and tables stay in a readable sans-serif, since a full page of bitmap-font text is
   illegible at paragraph size. Corners are squarer (6px vs the old 12-14px) and panels/header/
   footer get a pure-CSS pixel-dither texture instead of a flat fill, to read as a game UI rather
   than a rounded modern card -- no new bitmap assets, so this stays lightweight. */
:root {
  --bg: #1d3a24; --bg2: #25502c; --panel: #fff4d6; --ink: #3a2410; --wood: #5a3a1c; --wood-dark: #2b1a0c; --accent: #f2c23a; --accent-2: #e5a82e;
  --cream: #fff4d6; --muted: rgba(255, 244, 214, .72); --good: #3fbf5a; --bad: #d9534f; --warn: #e0a82e; --line: rgba(255, 244, 214, .16);
  --radius: 6px; --gutter: 16px;
  --pixel-font: "Press Start 2P", "Trebuchet MS", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--cream); font: 16px/1.55 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); }
a:hover { color: #fff; }
h1, h2, h3 { font-family: var(--pixel-font); line-height: 1.5; margin: 0 0 .7em; }
h1 { font-size: clamp(18px, 4vw, 30px); }
h2 { font-size: clamp(14px, 2.2vw, 19px); }
h3 { font-size: 13px; }
p { margin: 0 0 1em; }
.wrap { width: min(1120px, 100% - 2 * var(--gutter)); margin-inline: auto; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* inline SVG icons (replace emoji): sized via the container's font-size-equivalent rules below,
   always square, crisp pixel edges, tinted via currentColor so they follow surrounding text color. */
.pxicon { display: inline-block; width: 1em; height: 1em; vertical-align: -0.15em; shape-rendering: crispEdges; }
/* Wraps an icon built at runtime by svgIcon() (site.js) -- keeps it inline with normal text-node
   spacing around it, so an icon followed by " Label" never collides with the label text. */
.pxicon-wrap { display: inline-flex; vertical-align: -0.15em; }
.pxicon-wrap .pxicon { vertical-align: baseline; }
.menu-btn .pxicon { width: 22px; height: 22px; }
.card .icon .pxicon, .icon .pxicon { width: 36px; height: 36px; color: var(--accent-2); }
.hero-art .pxicon { width: clamp(48px, 10vw, 84px); height: clamp(48px, 10vw, 84px); color: var(--accent); }

/* header */
.site-header { position: sticky; top: 0; z-index: 20; background: rgba(29, 58, 36, .96); background-image: linear-gradient(rgba(29, 58, 36, .96), rgba(29, 58, 36, .96)), linear-gradient(rgba(0, 0, 0, .1) 50%, transparent 50%), linear-gradient(90deg, rgba(0, 0, 0, .1) 50%, transparent 50%); background-size: auto, 4px 4px, 4px 4px; backdrop-filter: blur(6px); border-bottom: 3px solid var(--wood-dark); }
.site-header .wrap { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--pixel-font); font-size: 13px; color: var(--cream); text-decoration: none; white-space: nowrap; }
.nav { display: none; flex: 1; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--cream); text-decoration: none; padding: 8px 12px; border-radius: var(--radius); font-family: var(--pixel-font); font-size: 11px; }
.nav a:hover { background: rgba(255, 255, 255, .08); }
.nav a[aria-current='page'] { background: var(--wood); color: #fff; }
.header-end { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.menu-btn { background: var(--wood); color: var(--cream); border: 2px solid var(--wood-dark); border-radius: var(--radius); width: 44px; height: 44px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.site-header.open .nav { display: flex; flex-direction: column; position: absolute; top: 100%; left: 0; right: 0; background: var(--bg); padding: 8px var(--gutter) 14px; border-bottom: 3px solid var(--wood-dark); }
.site-header.open .nav a { padding: 12px; }
.acct-link { color: var(--cream); font-family: var(--pixel-font); font-size: 10px; text-decoration: none; padding: 8px 10px; border-radius: var(--radius); max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-link:hover { background: rgba(255, 255, 255, .08); }
@media (min-width: 900px) {
  .menu-btn { display: none; }
  .nav { display: flex; }
  
}

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 20px; border-radius: var(--radius); border: 3px solid var(--wood-dark); background: var(--cream); color: var(--ink); font-family: var(--pixel-font); font-size: 11px; text-decoration: none; cursor: pointer; box-shadow: 0 4px 0 var(--wood-dark); }
.btn:hover { filter: brightness(1.05); color: var(--ink); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--wood-dark); }
.btn.primary { background: var(--accent); }
.btn.big { font-size: 14px; padding: 16px 32px; }
.btn.ghost { background: transparent; color: var(--cream); border-color: var(--line); box-shadow: none; }
.btn:disabled { opacity: .5; cursor: default; }

/* hero */
.hero { background: radial-gradient(circle at 20% 10%, #2f6d3a 0, transparent 55%), radial-gradient(circle at 85% 30%, #355f8c 0, transparent 45%), linear-gradient(rgba(0, 0, 0, .1) 50%, transparent 50%), linear-gradient(90deg, rgba(0, 0, 0, .1) 50%, transparent 50%), var(--bg2); background-size: auto, auto, 4px 4px, 4px 4px, auto; border-bottom: 3px solid var(--wood-dark); }
.hero .wrap { padding: clamp(36px, 8vw, 96px) 0; text-align: center; }
.hero h1 { margin-bottom: 12px; text-shadow: 0 4px 0 rgba(0, 0, 0, .35); }
.hero .lead { max-width: 640px; margin: 0 auto 24px; font-size: clamp(17px, 2.4vw, 21px); color: var(--cream); }
.hero .actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.hero-art { margin-bottom: 8px; }
.page-hero { background: var(--bg2); background-image: linear-gradient(rgba(0, 0, 0, .1) 50%, transparent 50%), linear-gradient(90deg, rgba(0, 0, 0, .1) 50%, transparent 50%); background-size: 4px 4px, 4px 4px; border-bottom: 3px solid var(--wood-dark); }
.page-hero .wrap { padding: 36px 0 28px; }
.page-hero p { max-width: 720px; color: var(--muted); margin: 0; font-size: 18px; }

section.block { padding: clamp(28px, 5vw, 56px) 0; }
section.block.alt { background: rgba(0, 0, 0, .14); }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head h2 { margin: 0; }

/* cards */
.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card { background: var(--panel); color: var(--ink); border: 4px solid var(--wood-dark); border-radius: var(--radius); padding: 16px; box-shadow: 0 5px 0 rgba(0, 0, 0, .3); }
.card h3 { margin-bottom: 6px; }
.card p:last-child { margin-bottom: 0; }
.card .icon { line-height: 1; margin-bottom: 8px; }
.card a { color: #7a4a10; }
.dark-card { background: rgba(0, 0, 0, .25); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; }

/* live statistics */
.stat { background: var(--panel); color: var(--ink); border: 4px solid var(--wood-dark); border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 5px 0 rgba(0, 0, 0, .3); }
.statlabel { display: block; font-weight: 700; font-size: 14px; opacity: .8; }
.statnum { display: block; font-size: clamp(28px, 5vw, 40px); font-weight: 900; line-height: 1.15; font-variant-numeric: tabular-nums; }
.statnote { display: flex; align-items: center; gap: 6px; font-size: 12.5px; opacity: .75; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #999; flex: none; }
.dot.on { background: var(--good); box-shadow: 0 0 0 0 rgba(63, 191, 90, .6); animation: pulse 2s infinite; }
.dot.warn { background: var(--warn); }
.dot.off { background: var(--bad); }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(63, 191, 90, 0); } 100% { box-shadow: 0 0 0 0 rgba(63, 191, 90, 0); } }
@media (prefers-reduced-motion: reduce) { .dot.on { animation: none; } html { scroll-behavior: auto; } }
.statusbar { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin-bottom: 14px; color: var(--muted); font-size: 15px; }
.statusbar b { color: var(--cream); }
.note { background: rgba(0, 0, 0, .22); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 8px; color: var(--muted); font-size: 15px; }

/* growth chart */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding: 8px 0 0; }
.chart .bar { flex: 1; min-width: 6px; background: var(--accent); border-radius: 4px 4px 0 0; position: relative; min-height: 3px; }
.chart .bar:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: #000c; color: #fff; padding: 3px 7px; border-radius: 6px; font-size: 12px; white-space: nowrap; margin-bottom: 4px; }
.chart-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

/* feeds and lists */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.feed li:last-child { border-bottom: 0; }
.feed .when { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }
.empty { color: var(--muted); font-style: italic; padding: 12px 0; }

/* leaderboard */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tab { background: rgba(0, 0, 0, .25); color: var(--cream); border: 2px solid var(--line); border-radius: 999px; padding: 8px 14px; font-family: var(--pixel-font); font-size: 10px; cursor: pointer; min-height: 40px; }
.tab[aria-pressed='true'] { background: var(--accent); color: var(--ink); border-color: var(--wood-dark); }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.controls input, .controls select, .field input { font: inherit; padding: 10px 12px; border-radius: var(--radius); border: 3px solid var(--wood-dark); background: #fffdf4; color: var(--ink); min-height: 44px; min-width: 0; }
.controls .grow { flex: 1 1 220px; }
.tablewrap { overflow-x: auto; border-radius: var(--radius); border: 4px solid var(--wood-dark); background: var(--panel); color: var(--ink); }
table.board { width: 100%; border-collapse: collapse; }
table.board th, table.board td { padding: 10px 14px; text-align: left; border-bottom: 1px solid rgba(58, 36, 16, .18); }
table.board th { background: var(--wood); color: var(--cream); font-size: 14px; white-space: nowrap; }
table.board td.num, table.board th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.board td.rank { width: 64px; font-weight: 800; font-size: 18px; }
table.board tr.me { background: #ffe9a3; }
table.board tr:last-child td { border-bottom: 0; }
table.board a { color: var(--ink); font-weight: 700; text-decoration: none; }
table.board a:hover { text-decoration: underline; }
.sub { display: block; font-size: 12.5px; opacity: .7; font-weight: 500; }
.matches { margin-bottom: 14px; }

/* news */
.news-item { background: var(--panel); color: var(--ink); border: 4px solid var(--wood-dark); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.news-item h3 { margin-bottom: 4px; }
.news-item .meta { font-size: 13px; opacity: .75; margin-bottom: 8px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.news-item .body { white-space: pre-wrap; margin: 0; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-family: var(--pixel-font); font-size: 9px; background: var(--wood); color: var(--cream); }
.badge.update { background: #3f7fbf; } .badge.announcement { background: #7a4fa8; } .badge.maintenance { background: #c0392b; } .badge.event { background: #2f7d32; }
.pin { font-size: 13px; }

/* forms and account */
.logincard { width: min(440px, 100%); background: var(--panel); color: var(--ink); border: 4px solid var(--wood-dark); border-radius: var(--radius); padding: 20px; box-shadow: 0 6px 0 rgba(0, 0, 0, .35); margin: 0 auto; }
.logincard h1 { font-size: 24px; text-align: center; margin: 0 0 4px; }
.loginsub { text-align: center; opacity: .8; font-size: 14.5px; }
.logintabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; }
.logintabs .opt { background: #eadcb6; color: var(--ink); border: 3px solid var(--wood-dark); border-radius: var(--radius); padding: 8px 14px; font-family: var(--pixel-font); font-size: 10px; cursor: pointer; min-height: 42px; }
.logintabs .opt.on { background: var(--accent); }
.loginform { display: flex; flex-direction: column; gap: 10px; }
.loginform label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 14px; }
.loginform label[hidden] { display: none; }
.loginform input { font: inherit; padding: 10px 12px; border-radius: var(--radius); border: 3px solid #8a6a3a; background: #fffdf4; min-height: 44px; }
.loginmsg { min-height: 1.4em; font-weight: 700; color: #a02a1f; margin: 8px 0 0; }
.loginlink, .loginback { background: none; border: 0; color: #7a4a10; text-decoration: underline; font: inherit; font-size: 14px; cursor: pointer; align-self: center; padding: 6px; }
.loginback { display: block; text-align: center; margin-top: 8px; }
.loginmore { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 2px dashed #c9a86a; }
.loginhint { font-size: 12.5px; opacity: .75; margin: 0; }
.logincard .btn { width: 100%; }
.recoverycode { font: 800 22px/1.4 ui-monospace, Consolas, monospace; letter-spacing: .08em; text-align: center; background: #fffdf4; border: 3px dashed #8a6a3a; border-radius: var(--radius); padding: 14px 8px; margin: 12px 0; user-select: all; word-break: break-all; }
.loginconfirm { display: flex; gap: 8px; align-items: center; margin: 12px 0; font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 4px; }

/* profile */
.profile-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.avatar { image-rendering: pixelated; width: 128px; height: 128px; background: #b9e0a5; border: 4px solid var(--wood-dark); border-radius: var(--radius); }
.rankgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.rankbox { background: rgba(0, 0, 0, .22); border-radius: var(--radius); padding: 10px 12px; }
.rankbox b { display: block; font-size: 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--panel); color: var(--ink); border: 3px solid var(--wood-dark); border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: 14px; }
.chip.locked { opacity: .45; }
.bar { height: 10px; background: rgba(0, 0, 0, .3); border-radius: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }

/* footer */
.site-footer { margin-top: auto; background: #14281a; background-image: linear-gradient(rgba(0, 0, 0, .12) 50%, transparent 50%), linear-gradient(90deg, rgba(0, 0, 0, .12) 50%, transparent 50%); background-size: 4px 4px; border-top: 3px solid var(--wood-dark); padding: 24px 0; color: var(--muted); font-size: 14px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 12px 28px; justify-content: space-between; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: #fff; }
.cta { text-align: center; }
.cta .actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
ul.plain { padding-left: 1.2em; margin: 0 0 1em; }
ul.plain li { margin-bottom: .4em; }
.two-col { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 800px) { .two-col { grid-template-columns: 1fr 1fr; } }

#profile h3 { margin: 24px 0 8px; }
#profile .chips { margin-bottom: 4px; }

.brand img { height: 48px; width: auto; display: block; }
.beta-badge { display: inline-block; background: var(--accent); color: var(--ink); font-family: var(--pixel-font); font-size: 8px; line-height: 1; padding: 4px 6px; border-radius: 6px; border: 2px solid var(--wood-dark); vertical-align: top; margin-left: 4px; white-space: nowrap; }
.beta-badge.hero { position: absolute; top: 8%; right: 6%; margin-left: 0; font-size: 11px; padding: 6px 10px; transform: rotate(-8deg); box-shadow: 0 3px 0 rgba(0, 0, 0, .3); }
/* inline-block so this shrinks to the logo image's own box (an h1 is block-level and would
   otherwise span the full centered .wrap width, throwing off the badge's %-based position below). */
.hero-title { position: relative; display: inline-block; margin: 0 0 12px; line-height: 0; text-shadow: none; }
.hero-logo { width: min(520px, 86%); height: auto; filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .3)); }
.loginlogo { display: block; width: min(220px, 70%); height: auto; margin: 0 auto 6px; }

.logout-btn { background: none; border: 2px solid var(--line); color: var(--cream); border-radius: var(--radius); padding: 6px 10px; font: inherit; font-weight: 600; cursor: pointer; min-height: 40px; }
.logout-btn:hover { background: rgba(255, 255, 255, .08); }
