/* Nong RPG — hanji paper UI.
   Palette and rules from the v2 style guide:
   paper, paper2, card, ink, muted, celadon, pine, soil, persimmon, gold.
   2px ink outlines, hard offset shadows, radius 3–4px, type at least 11px.
   Gold (#F2C48D) is only for the Gold currency, and only on ink. */

@import url('https://fonts.googleapis.com/css2?family=Gowun+Batang:wght@400;700&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  color-scheme: light;
  --paper: #EFE6D2;
  --paper2: #E4D7BC;
  --card: #F7F1E3;
  --ink: #2B2620;
  --muted: #6E6455;
  --cel: #8FA89A;
  --pine: #4F6B5E;
  --soil: #5E4330;
  --acc: #C8582A;
  --gold: #F2C48D;
  /* aliases so older rules and the admin page keep resolving */
  --paper-2: var(--paper2);
  --line: var(--ink);
  --panel: var(--card);
  --panel-solid: var(--card);
  --green: var(--pine);
  --green-2: var(--pine);
  --green-soft: var(--paper2);
  --red: var(--acc);
  --red-soft: #F3D9CE;
  --gold-soft: var(--paper2);
  --soil-dark: var(--soil);
  --shadow: 4px 4px 0 var(--ink);
  --radius-lg: 4px;
  --radius-md: 4px;
  --radius-sm: 3px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* pan-y + pinch: vertical scroll and pinch-zoom stay, double-tap zoom
   does not, and the page itself cannot be dragged sideways.
   Not inherited, so it has to sit on the tapped element too.
   A horizontal scroller (the tab row) and the fishing overlay opt out. */
html, body, body * {
  touch-action: pan-y pinch-zoom;
}
html { background: var(--paper); }
body {
  background-color: var(--paper);
  background-image: radial-gradient(rgba(43, 38, 32, .045) 0.7px, transparent 0.7px);
  background-size: 3px 3px;
  color: var(--ink);
  font-family: Nunito, "Gowun Batang", sans-serif;
  font-size: 14px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
input, textarea, [contenteditable="true"] {
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}
img { -webkit-user-drag: none; }
*, *::before, *::after { -webkit-touch-callout: none !important; }
input, textarea, [contenteditable="true"] { -webkit-touch-callout: default !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}
h1, h2, h3, .serif { font-family: "Gowun Batang", serif; font-weight: 700; }
h1 { font-size: 40px; line-height: 1.05; margin: 0; }
h2 { font-size: 22px; line-height: 1.2; margin: 0; }
h3 { font-size: 18px; line-height: 1.25; margin: 0; }
a { color: var(--ink); }

.eb {
  font-family: Nunito, sans-serif;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--muted);
  text-transform: uppercase;
}
.pine .eb, .ink .eb, .acc .eb, .card.pine .eb, .card.ink .eb, .card.acc .eb { color: var(--paper2); }
.muted { color: var(--muted); }
.small, .sm { font-size: 12px; }
.xs { font-size: 11px; }
.b { font-weight: 700; }
.xb { font-weight: 800; }
.up { color: var(--pine); font-weight: 800; }
.dn, .down { color: var(--acc); font-weight: 800; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* ---------- top bar ---------- */
#topbars { position: sticky; top: 0; z-index: 40; }
#playerbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  width: 100%;
  margin: 0;
  padding: 8px 18px;
  position: relative;
  top: auto;
  left: auto;
  transform: none;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}
#playerbar .logo {
  color: var(--acc);
  font-family: "Gowun Batang", serif;
  font-weight: 700;
  font-size: 28px;
  line-height: 1;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.hdr-chat {
  position: relative;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  color: var(--paper);
  cursor: pointer;
  padding: 0;
}
.hdr-chat svg { width: 22px; height: 22px; }
.hdr-chat .chat-badge {
  position: absolute;
  top: 2px;
  right: 0;
  background: var(--acc);
  color: var(--card);
  border-radius: 3px;
  font-size: 11px;
  font-weight: 800;
  padding: 0 4px;
}
.coin-ico { display: inline-flex; width: 16px; height: 16px; vertical-align: -3px; }
.coin-ico svg { width: 16px; height: 16px; }
.term { color: var(--muted); font-size: 12px; line-height: 1.35; margin: 4px 0 0; font-weight: 600; }
.callout {
  background: var(--paper2);
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 12px 14px;
  margin: 0 0 14px;
}
.callout p { margin: 6px 0 0; font-weight: 700; }
.plot.empty:disabled { opacity: .45; cursor: not-allowed; }
.lg-pair { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
.lg-en { font-weight: 800; font-size: 12px; }
.topnav button.soon, .more-grid button.soon { opacity: .45; }
.race-row .nm { overflow: hidden; text-overflow: ellipsis; }
.race-row .lb-nums { white-space: nowrap; }
#playerbar .brand {
  font-family: "Gowun Batang", serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .08em;
  margin-right: 8px;
  white-space: nowrap;
}
#playerbar .sp { flex: 1; }
.hdr-money { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.field-strip { display: none; }
.locked-fold {
  margin-top: 8px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
}
.locked-fold summary {
  min-height: 44px;
  padding: 10px 12px;
  font-weight: 800;
  cursor: pointer;
}
.locked-fold .animal-card, .locked-fold .region-card { margin: 0 10px 10px; }
.mkt-notes { margin-top: 4px; }
.topnav {
  display: flex;
  gap: 4px;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
}
.topnav button {
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  color: var(--paper2);
  background: transparent;
  border: 0;
  border-radius: 3px;
  padding: 7px 10px;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}
.topnav button.on { background: var(--paper); color: var(--ink); }
.topnav button:hover { color: var(--paper); }
.topnav button.on:hover { color: var(--ink); }
.topnav .new {
  background: var(--paper);
  color: var(--ink);
  margin-left: 4px;
}
.topnav button.on .new { background: var(--ink); color: var(--paper); }
#playerbar .coin {
  color: var(--paper);
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
}
#playerbar .jade {
  color: var(--gold);
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
}
#playerbar .et-clock {
  display: flex;
  flex-direction: column;
  border: 0;
  padding: 0 4px;
  color: var(--paper2);
}
#playerbar .et-clock small { color: var(--paper2); font-size: 11px; font-weight: 700; letter-spacing: .08em; }
#playerbar .et-clock strong { font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 700; }
#playerbar .lang-link { color: var(--paper2); font-size: 12px; font-weight: 800; text-decoration: none; padding: 4px; }
#playerbar .music-toggle { color: var(--paper); background: none; border: 0; cursor: pointer; font-size: 16px; padding: 4px; }
.me {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  text-align: left;
  padding: 0;
  font: inherit;
}
.me b { display: block; font-size: 13px; line-height: 1.15; }
.me small { display: block; color: var(--paper2); font-weight: 600; font-size: 11px; white-space: nowrap; }
.hdr-av {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--paper); overflow: hidden; flex: none; background: var(--soil);
}
.hdr-av svg { width: 100%; height: 100%; display: block; }
.tab-dot {
  position: absolute; top: 4px; right: 4px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--acc);
}

#tabbar { display: none; }
#hero { display: none !important; }

#guest-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--acc);
  color: var(--card);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
}
#guest-banner .btn { text-decoration: none; background: var(--card); color: var(--ink); }

/* ---------- page ---------- */
#tabcontent {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px 22px 96px;
}
.page-head { margin: 4px 0 14px; }
.page-head h1 { font-size: clamp(32px, 4vw, 44px); }
.page-head .eb { margin-bottom: 4px; }

.card {
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 4px 4px 0 var(--ink);
  padding: 14px 16px;
  margin: 0 0 14px;
  overflow: hidden;
}
.card h2, .card h3 { font-family: "Gowun Batang", serif; }
.card.pine { background: var(--pine); color: var(--paper); }
.card.acc { background: var(--acc); color: var(--card); }
.card.ink { background: var(--ink); color: var(--paper); }
.card.flat { box-shadow: none; }
p.hint, .hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; line-height: 1.45; }
.card.pine .hint, .card.acc .hint, .card.ink .hint,
.card.pine .term, .card.acc .term, .card.ink .term { color: var(--paper2); }
.card .term { clear: both; }
.hr { height: 1px; background: var(--paper2); margin: 10px 0; border: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  padding: 7px 14px;
  font-weight: 700;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
}
.btn.primary, .btn.gold { background: var(--acc); color: var(--card); }
.btn.primary:hover, .btn.gold:hover { filter: brightness(1.05); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.danger { background: var(--card); color: var(--acc); }
.btn:disabled, .btn.primary:disabled, .btn.gold:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn > span { display: inline-flex; align-items: center; }
.card.acc .btn { color: var(--ink); background: var(--card); }

.tag, .new, .count-chip, .score-chip, .upd-new {
  display: inline-block;
  font-family: Nunito, sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  padding: 1px 6px;
  border-radius: 2px;
  border: 2px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  text-transform: uppercase;
  line-height: 1.45;
  vertical-align: middle;
}
.new { background: var(--ink); color: var(--paper); letter-spacing: .08em; margin-left: 6px; text-transform: uppercase; }
.tag.pine, .count-chip { background: var(--pine); color: var(--card); }
.tag.acc { background: var(--acc); color: var(--card); }
.score-chip { background: var(--paper2); }

.bar, .xpbar, .progress-line {
  height: 8px;
  background: var(--paper2);
  border-radius: 4px;
  overflow: hidden;
}
.bar > i, .xpbar > i, .progress-fill {
  display: block;
  height: 100%;
  background: var(--pine);
  border-radius: 4px;
  width: 0;
}
.bar.a > i, .bar.acc > i { background: var(--acc); }
.card.pine .bar, .card.ink .bar, .card.pine .xpbar, .card.ink .xpbar { background: var(--ink); }
.card.pine .bar > i, .card.pine .xpbar > i { background: var(--paper); }

/* league shapes: pine circle, soil hex, persimmon diamond */
.badge-lg {
  width: 56px; height: 56px;
  background: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.badge-lg span {
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Gowun Batang", serif;
  font-weight: 700;
  color: var(--card);
  font-size: 15px;
  line-height: 1;
}
.badge-lg.sm { width: 40px; height: 40px; }
.badge-lg.sm span { font-size: 12px; }
.badge-lg.lg { width: 72px; height: 72px; }
.badge-lg.lg span { font-size: 20px; }
.lg-sprout, .lg-sprout span { clip-path: circle(50%); }
.lg-sprout span { background: var(--pine); }
.lg-harvest, .lg-harvest span { clip-path: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0 50%); }
.lg-harvest span { background: var(--soil); }
.lg-master, .lg-master span { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.lg-master span { background: var(--acc); }

/* ---------- hub ---------- */
.hub-top {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.3fr) minmax(220px, .7fr);
  gap: 14px;
  margin-bottom: 14px;
  align-items: stretch;
}
.hub-top .card { margin: 0; min-height: 220px; }
.hub-mid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(240px, .8fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.hub-mid .card { margin: 0 0 14px; }
.hub-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.sun {
  width: 84px; height: 84px; border-radius: 50%;
  background: var(--acc); border: 2px solid var(--ink);
  float: right; margin: 0 0 8px 12px;
}
.quest { padding: 8px 0; border-bottom: 1px solid var(--paper2); }
.quest:last-child { border: 0; }
.quest .qname { font-weight: 800; }
.quest .qdesc { font-size: 12px; color: var(--muted); }
.quest .qprog { font-size: 12px; font-weight: 800; color: var(--muted); }
.soon-note, .soon-card p { color: var(--muted); font-size: 13px; }
.soon-card h2 { margin-bottom: 6px; }

/* ---------- field ---------- */
.play {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 280px;
  gap: 14px;
  align-items: start;
}
.play-main { margin: 0; }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.field-head h2 { font-size: 22px; }
.play-side .card { margin-bottom: 12px; }
.race-cd {
  font-family: "Gowun Batang", serif;
  font-size: 32px;
  line-height: 1;
  margin: 6px 0;
}
.seed-tray {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 12px 0 4px;
  padding-bottom: 4px;
}
.seed {
  position: relative;
  flex: 0 0 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 8px 6px 6px;
  cursor: pointer;
  color: inherit;
}
.seed strong { font-size: 11px; font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seed small { color: var(--muted); font-size: 11px; }
.seed.active { background: var(--pine); color: var(--card); }
.seed.active small { color: var(--paper2); }
.seed-count {
  position: absolute; top: -8px; right: -6px;
  background: var(--ink); color: var(--paper);
  border-radius: 3px; font-size: 11px; font-weight: 800;
  padding: 0 5px; line-height: 1.45;
}
.plots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.plot {
  position: relative;
  background: var(--soil);
  color: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 3px 3px 0 var(--ink);
  min-height: 148px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  text-align: left;
}
.plot.empty {
  background: var(--paper2);
  color: var(--ink);
  cursor: pointer;
  justify-content: center;
  align-items: center;
}
.plot.ready { outline: 3px solid var(--acc); outline-offset: -5px; }
.plot-art { margin: -8px -8px 6px; aspect-ratio: 5 / 3; overflow: hidden;
  border-bottom: 2px solid var(--ink); border-radius: 2px 2px 0 0; }
.plot-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.plot.empty { background: var(--soil); justify-content: flex-start; align-items: stretch; }
.plot.empty .plot-art { position: relative; }
.plot.empty .plot-name, .plot.empty .plot-status { color: var(--paper); }
.plot.empty:disabled .plot-art { opacity: .6; }
.plot.ready .plot-art { border-bottom-color: var(--acc); }
.plot-top { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.plot-name { font-weight: 800; font-size: 13px; }
.plot-status { font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--paper2); }
.plot.ready .plot-status { color: #F6C7B4; }
.plant-visual { display: none; }
.plot.empty .plant-visual {
  display: block;
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  width: 44px;
  height: 44px;
  line-height: 40px;
  text-align: center;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 3px 3px 0 var(--ink);
  font-family: "Gowun Batang", serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
}
.progress { margin-top: auto; }
.progress-copy { display: flex; justify-content: space-between; margin-top: 4px; font-size: 11px; color: var(--paper2); }
.plot .harvest-btn, .gold-skip-btn {
  margin-top: 8px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  background: var(--acc);
  color: var(--card);
  font-weight: 800;
  font-size: 12px;
  padding: 6px 8px;
  cursor: pointer;
  width: 100%;
}
.gold-skip-btn { background: var(--card); color: var(--ink); }
.gold-skip-btn:disabled { opacity: .45; cursor: not-allowed; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.animal-board { display: grid; gap: 8px; margin-top: 8px; }
.animal-card {
  border-top: 1px solid var(--paper2);
  padding-top: 8px;
}
.animal-card .nm { font-weight: 800; }

/* ---------- lists, pantry, world ---------- */
.subtabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 12px; }
.subtabs .btn.sm.sel, .qty-presets .btn.sel { background: var(--ink); color: var(--paper); }
.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  margin: 0;
  background: transparent;
  border-radius: 0;
  border-top: 1px solid var(--paper2);
}
.item-row .nm { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; min-width: 0; }
.item-row .ko { color: var(--muted); font-size: 12px; }
.item-row .qty { margin-left: auto; color: var(--muted); font-weight: 800; }
.item-row .row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.price { color: var(--ink); font-weight: 800; font-size: 13px; white-space: nowrap; }
.price.up { color: var(--pine); }
.price.down { color: var(--acc); }
.pantry-sec { display: flex; align-items: center; gap: 8px; margin: 14px 0 6px; font-size: 16px; }
.pantry-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: stretch; }
.pantry-card {
  position: relative;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  height: 100%;
}
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; align-items: stretch; margin-top: 8px; }
.recipe-grid .item-row {
  height: 100%;
  margin: 0;
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 10px;
  align-items: stretch;
}
.pantry-card strong { font-size: 13px; }
.pantry-card .term { font-size: 12px; }
.pantry-qty {
  position: absolute; top: 4px; right: 4px;
  font-size: 11px; font-weight: 800;
}
.item-icon { display: inline-block; width: 36px; height: 36px; margin-right: 8px; vertical-align: middle; flex: none; cursor: pointer; }
.item-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: 3px; border: 2px solid var(--ink); display: block; }
.seed .item-icon { margin: 0; width: 36px; height: 36px; }
.nm .item-icon { width: 28px; height: 28px; }
.crop-mark { width: 28px; height: 28px; display: inline-grid; place-items: center; color: var(--pine); }
.crop-mark svg { width: 100%; height: 100%; }
.region-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.region-card { border: 2px solid var(--ink); border-radius: 4px; box-shadow: 4px 4px 0 var(--ink); overflow: hidden; background: var(--card); }
.region-card.locked { opacity: .55; }
.region-banner { width: 100%; height: 110px; object-fit: cover; display: block; }
.region-body { padding: 10px 12px 12px; }
.region-name { font-family: "Gowun Batang", serif; font-weight: 700; font-size: 18px; margin-bottom: 6px; }
.region-loot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.region-loot > .small { flex: 1 0 100%; margin: 0; }
.region-loot .item-icon { width: 36px; height: 36px; margin: 0; }
.equip-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.equip-card {
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}
.equip-card.locked { opacity: .6; }
.equip-stars, .mastery-stars { color: var(--ink); letter-spacing: 1px; font-size: 13px; }
.mastery-stars.small { font-size: 12px; }
.mastery-max { font-weight: 800; }
.equip-emoji { font-size: 28px; }
.skill-strip { margin: 8px 0; }
.xp-text { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }

/* ---------- market ---------- */
.mkt-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.mkt-pills { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mkt-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, .8fr); gap: 14px; align-items: stretch; }
.sheet { width: 100%; border-collapse: collapse; }
.sheet th {
  font-size: 11px; letter-spacing: .12em; color: var(--muted); font-weight: 800;
  text-transform: uppercase; text-align: left; padding: 6px; border-bottom: 2px solid var(--ink);
  white-space: nowrap;
}
.sheet td { padding: 7px 6px; border-top: 1px solid var(--paper2); vertical-align: middle; }
.sheet tr.me td, .sheet tr.on td { background: var(--paper2); }
.sheet .nm { font-weight: 800; }
.event-banner { margin-bottom: 12px; }
.idx-up { color: var(--pine); font-weight: 800; }
.idx-down { color: var(--acc); font-weight: 800; }
.week-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 7px 0; border-top: 1px solid var(--paper2); font-size: 13px; }
.week-row span:last-child { font-size: 12px; }
.week-row.on { font-weight: 800; background: var(--paper2); margin: 0 -8px; padding: 7px 8px; }

/* ---------- bank ---------- */
.bank-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(260px, .8fr); gap: 14px; align-items: stretch; }
.hub-top > .card, .mkt-grid > .card, .bank-grid > .card { height: 100%; }
/* Sidebar cards size to their content. height:100% made each one as tall as the whole column. */
.mkt-grid > aside > .card { height: auto; }
.bank-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.bank-bal { font-family: "Gowun Batang", serif; font-size: 42px; line-height: 1; margin: 6px 0; }
.bank-next { display: flex; justify-content: space-between; gap: 8px; background: var(--ink); color: var(--paper); border-radius: 3px; padding: 8px 10px; margin: 10px 0; font-size: 13px; }
.bank-next b { color: var(--paper); }
.bank-loans { margin-top: 4px; }
.bank-loan-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.score-ring {
  --p: 50;
  width: 132px; height: 132px; border-radius: 50%;
  background: conic-gradient(var(--pine) calc(var(--p) * 1%), var(--paper2) 0);
  display: grid; place-items: center; margin: 8px auto;
  border: 2px solid var(--ink);
}
.score-ring b {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--ink);
  display: grid; place-items: center;
  font-family: "Gowun Batang", serif; font-size: 32px;
}
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.stat { background: var(--paper); border: 2px solid var(--ink); border-radius: 3px; padding: 8px; }
.stat .k { font-size: 11px; color: var(--muted); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.stat .v { font-size: 16px; font-weight: 800; }
.inline-form { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.inline-form input, .set-form input, .auth-card input, .mastery-search input, .ref-link-row input, .qty-presets + input, #bank-amt, #m-amt, #m-qty {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 3px;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 16px;
  min-width: 0;
}
.inline-form input { flex: 1; }
.set-form label, .auth-card label { display: block; font-size: 13px; font-weight: 700; margin: 8px 0 0; }
.set-form input, .auth-card input { display: block; width: 100%; margin-top: 4px; }
.set-form .btn, .auth-card .btn { margin-top: 10px; }
.qty-presets { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.qty-presets .btn { flex: 1; }
ol.rules { margin: 8px 0 12px 18px; padding: 0; font-size: 14px; line-height: 1.5; }
ol.rules li { margin: 0 0 6px; }

/* ---------- races ---------- */
.race-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 300px); gap: 14px; align-items: start; }
.league-row { display: flex; gap: 8px; }
.league-pick {
  flex: 1;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 3px 3px 0 var(--ink);
  padding: 8px;
  cursor: pointer;
  text-align: center;
  color: inherit;
  font: inherit;
}
.league-pick.on { outline: 3px solid var(--acc); outline-offset: 1px; }
.league-pick .eb { display: block; margin-top: 6px; }
.podium { display: flex; align-items: stretch; gap: 10px; justify-content: center; width: min(640px, 100%); margin: 10px auto 0; }
.podium-card { overflow: visible; }
.podium .pod {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  border: 2px solid var(--ink);
  background: var(--paper2);
  text-align: center;
  padding: 10px 8px;
  font-weight: 800;
  min-height: 110px;
}
.podium .pod.p1 { background: var(--acc); color: var(--card); }
.podium .pod.p2 { background: var(--paper); color: var(--ink); }
.podium .pod.p3 { background: var(--cel); color: var(--ink); }
.podium .pod b { display: block; font-family: "Gowun Batang", serif; font-size: 28px; line-height: 1; }
.podium .who {
  display: block;
  margin-top: 4px;
  max-width: 100%;
  font-size: 13px;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* ---------- profile / settings ---------- */
.profile-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.profile-stats div { border: 2px solid var(--ink); border-radius: 3px; padding: 8px; background: var(--paper); }
.profile-stats b { display: block; font-family: "Gowun Batang", serif; font-size: 22px; }
.set-account { display: flex; gap: 12px; align-items: center; }
.set-avatar, .profile-avatar-big {
  width: 72px; height: 72px; border-radius: 50%; overflow: hidden;
  border: 2px solid var(--ink); flex: none; background: var(--soil);
}
.set-avatar svg, .profile-avatar-big svg { width: 100%; height: 100%; display: block; }
.ref-link-row { display: flex; gap: 8px; margin: 8px 0; }
.ref-link-row input { flex: 1; }
.ref-tier-name { font-weight: 800; margin-bottom: 4px; }

/* ---------- chat ---------- */
#chatfab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  width: auto;
  height: auto;
  min-width: 52px;
  padding: 8px 12px;
  border-radius: 4px;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  box-shadow: 4px 4px 0 var(--soil);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
}
#chatfab svg { width: 18px; height: 18px; }
#chatfab[hidden] { display: none; }
#chatfab .chat-badge {
  background: var(--acc); color: var(--card);
  border-radius: 3px; font-size: 11px; font-weight: 800;
  padding: 0 5px; line-height: 1.45;
}
#chatfab .chat-badge[hidden] { display: none; }
#chatveil {
  position: fixed;
  inset: 0;
  z-index: 54;
  background: rgba(43, 38, 32, .45);
}
#chatveil[hidden] { display: none; }
#chatsheet {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 56;
  width: min(380px, calc(100% - 24px));
  height: min(520px, calc(100% - 90px));
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 4px 4px 0 var(--ink);
  display: flex;
  flex-direction: column;
}
#chatsheet[hidden] { display: none; }
.chat-head, .chat-online {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-bottom: 2px solid var(--ink);
}
.chat-head strong { font-family: "Gowun Batang", serif; font-size: 18px; }
.chat-head button { background: var(--card); border: 2px solid var(--ink); border-radius: 3px; font-weight: 800; cursor: pointer; width: 28px; height: 28px; }
.chat-online { font-size: 12px; font-weight: 700; color: var(--muted); }
.chat-online[hidden] { display: none; }
.chat-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pine); border: 2px solid var(--ink); display: inline-block; }
.chat-names { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.chat-list { flex: 1; overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.chat-empty { color: var(--muted); font-size: 13px; padding: 12px 0; }
.chat-meta { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.chat-avatar { width: 22px; height: 22px; border-radius: 50%; overflow: hidden; border: 2px solid var(--ink); flex: none; }
.chat-avatar svg { width: 100%; height: 100%; display: block; }
.chat-user { font-size: 12px; font-weight: 800; }
.chat-level, .chat-time, .chat-refbadge { font-size: 11px; color: var(--muted); font-weight: 700; }
.chat-msg p {
  margin: 0;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 13px;
}
.chat-form { display: flex; gap: 6px; padding: 8px; border-top: 2px solid var(--ink); }
.chat-form input {
  flex: 1; min-width: 0;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 3px;
  padding: 8px 10px; font-size: 16px;
}
.chat-form button {
  background: var(--acc); color: var(--card);
  border: 2px solid var(--ink); border-radius: 3px;
  font-weight: 800; padding: 0 12px; cursor: pointer;
}
.chat-form button:disabled { opacity: .5; }

/* ---------- modals, toasts, detail ---------- */
#modal-root:empty { display: none; }
.modal-veil {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(43, 38, 32, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
}
.modal {
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 6px 6px 0 var(--ink);
  padding: 16px;
  width: min(420px, 100%);
  max-height: 86vh;
  overflow: auto;
}
.modal h3 { margin: 0 0 8px; font-family: "Gowun Batang", serif; }
.modal-total { margin: 8px 0; font-size: 16px; font-weight: 800; }
.detail-modal, .profile-modal, .equip-modal { max-width: 440px; }
.detail-head, .profile-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.detail-head h3, .profile-head strong { margin: 0; }
.detail-modal h4 { margin: 12px 0 6px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.detail-src { display: flex; gap: 8px; padding: 6px 0; border-top: 1px solid var(--paper2); font-size: 14px; }
.detail-uses { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-use { display: flex; align-items: center; gap: 6px; border: 2px solid var(--ink); border-radius: 3px; padding: 4px 8px; font-size: 12px; background: var(--paper); }
.avatar-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 10px 0; }
.av-pick {
  background: var(--paper); border: 2px solid var(--ink); border-radius: 3px;
  padding: 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: inherit; font: inherit;
}
.av-pick svg { width: 40px; height: 40px; border-radius: 50%; }
.av-pick span { font-size: 11px; color: var(--muted); text-align: center; }
.av-pick.sel { background: var(--pine); color: var(--card); }
.av-pick.sel span { color: var(--paper); }
.profile-actions { display: flex; gap: 8px; justify-content: flex-end; }
.av-sm { width: 32px; height: 32px; border-radius: 50%; overflow: hidden; border: 2px solid var(--ink); flex: none; }
.av-sm svg { width: 100%; height: 100%; display: block; }
.equip-modal { text-align: center; }
.equip-modal-icon { font-size: 40px; margin-bottom: 6px; }
.equip-modal-price { font-size: 18px; font-weight: 800; margin: 8px 0; }
.lb-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lb-rank { min-width: 36px; font-weight: 800; }
.lb-nums { text-align: right; font-size: 12px; font-weight: 700; }
.item-row.lb-me { background: var(--paper2); }
.mcat-head { cursor: pointer; }
.collap-arrow { margin-left: auto; font-size: 11px; color: var(--muted); }
.mastery-search input { width: 100%; }
.locked-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.upd-home-top, .upd-item-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.upd-item { padding: 8px 0; border-top: 1px solid var(--paper2); }
.upd-item p, .upd-home p { margin: 4px 0 0; white-space: pre-wrap; }
.upd-x { background: var(--card); border: 2px solid var(--ink); border-radius: 3px; font-weight: 800; cursor: pointer; width: 26px; height: 26px; }
#toast-root {
  position: fixed; right: 16px; bottom: 72px; z-index: 90;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  background: var(--ink); color: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 4px 4px 0 var(--soil);
  padding: 10px 12px;
  font-size: 13px; font-weight: 700;
  max-width: 320px;
}
.top-links { display: flex; justify-content: space-between; margin-bottom: 8px; }
.top-links a { color: var(--muted); font-size: 12px; font-weight: 700; text-decoration: none; }

/* fishing — the reel needs the finger, so this overlay opts out of
   pan and pinch. Everywhere else keeps pinch-zoom. */
.fg-overlay, .fg-overlay * {
  touch-action: none;
}
.fg-overlay {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(43, 38, 32, .55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.fg-card {
  background: var(--card); border: 2px solid var(--ink); border-radius: 4px;
  box-shadow: 6px 6px 0 var(--ink); padding: 12px; width: min(360px, 100%);
}
.fg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 800; }
.fg-card canvas { display: block; margin: 0 auto; background: var(--paper); border: 2px solid var(--ink); touch-action: none; }
.fg-hint { text-align: center; margin-top: 8px; min-height: 1.4em; font-size: 13px; color: var(--muted); }

/* auth / login */
.auth-wrap, .landing-hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  background: var(--paper);
}
.landing-hero::before { display: none; }
.landing-inner {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  align-items: center;
}
.landing-head, .landing-feats { grid-column: 1; }
.landing-card, .landing-single { grid-column: 2; grid-row: 1 / span 2; }
.landing-discord { grid-column: 1 / -1; }
.landing-logo {
  font-family: "Gowun Batang", serif;
  font-size: 64px;
  color: var(--ink);
  margin: 0;
  text-shadow: none;
  letter-spacing: .04em;
}
.landing-tagline { color: var(--muted); font-size: 18px; margin: 8px 0 0; text-shadow: none; }
.landing-feats { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.landing-feats li {
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 3px 3px 0 var(--ink);
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 700;
}
.auth-card {
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 4px 4px 0 var(--ink);
  padding: 18px;
}
.auth-card h2 { font-family: "Gowun Batang", serif; font-size: 26px; margin: 0 0 8px; }
.game-logo { text-align: center; font-family: "Gowun Batang", serif; }
.tagline { text-align: center; color: var(--muted); }
.error {
  background: var(--red-soft);
  border: 2px solid var(--ink);
  color: var(--acc);
  border-radius: 3px;
  padding: 8px 10px;
  font-weight: 700;
}
.switch, .lang { text-align: center; margin-top: 10px; font-size: 13px; }
.switch a, .lang a { font-weight: 800; }
.guest-btn { display: block; width: 100%; text-align: center; text-decoration: none; margin-top: 8px; }
.discord-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--ink); color: var(--paper); text-decoration: none;
  font-weight: 800; padding: 10px 16px; border-radius: 3px; border: 2px solid var(--ink);
}
.auth-music {
  position: fixed; right: 14px; bottom: 14px; z-index: 60;
  display: grid; place-items: center; padding: 0;
  background: var(--ink); color: var(--paper);
  border: 2px solid var(--ink); border-radius: 4px;
  box-shadow: 3px 3px 0 var(--soil);
  width: 44px; height: 44px; cursor: pointer;
}
.auth-music svg { display: block; }

@media (max-width: 1100px) {
  .landing-inner { grid-template-columns: 1fr; }
  .landing-head, .landing-feats, .landing-card, .landing-single, .landing-discord { grid-column: 1; grid-row: auto; }
  h1, .page-head h1 { font-size: 32px; }
}
/* iPad portrait and other widths under 900: one column, two plot columns.
   The nav sits on its own row under the status bar so it is not clipped. */
@media (max-width: 899px) {
  .hub-top, .hub-mid, .play, .mkt-grid, .bank-grid, .bank-split, .bank-loan-split, .race-layout {
    grid-template-columns: 1fr;
  }
  .hub-top .card, .hub-mid .card, .mkt-grid > .card, .mkt-grid > aside > .card, .bank-grid > .card {
    height: auto;
    min-height: 0;
  }
  .play { grid-template-columns: 1fr; }
  .plots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .equip-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #playerbar { flex-wrap: wrap; align-items: center; padding: 8px 12px; }
  #playerbar .brand { margin-right: 0; }
}
/* iPad landscape around 1024: two columns, not a stretched phone stack. */
@media (min-width: 900px) and (max-width: 1100px) {
  .hub-top { grid-template-columns: 1fr 1fr; }
  .hub-top > .card:nth-child(3) { grid-column: 1 / -1; }
  .hub-top .card, .mkt-grid > .card, .mkt-grid > aside > .card, .bank-grid > .card { height: auto; min-height: 0; }
  .hub-mid { grid-template-columns: 1fr 1fr; }
  .hub-mid > :nth-child(3) { grid-column: 1 / -1; }
  .play { grid-template-columns: minmax(0, 1fr) 280px; }
  .play > .play-side:first-child {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .play > .play-side:first-child > .card { margin: 0; }
  .mkt-grid { grid-template-columns: minmax(0, 1fr) 280px; align-items: start; }
  .bank-grid { grid-template-columns: minmax(0, 1.2fr) minmax(240px, .8fr); }
  .plots { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .equip-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #playerbar { flex-wrap: wrap; align-items: center; padding: 8px 12px; }
  #playerbar .brand { margin-right: 0; }
}
@media (max-width: 640px) {
  #tabcontent { padding: 12px 12px 96px; }
  .plots { grid-template-columns: 1fr 1fr; }
  .seed { flex-basis: 84px; }
  #playerbar .coin, #playerbar .jade { font-size: 12px; }
  .me small { display: none; }
  .race-cd { font-size: 26px; }
}
/* Phone + short landscape. Desktop (wider than 520px and taller than 520px) is untouched. */
@media (max-width: 520px), (max-height: 520px) and (orientation: landscape) and (max-width: 950px) {
  html, body {
    overflow-x: clip;
    overscroll-behavior-x: none;
    max-width: 100%;
  }
  #app, #tabcontent, #playerbar, .card, .play, .play-main {
    max-width: 100%;
    min-width: 0;
  }
  #playerbar { overflow: hidden; }
  body { min-height: 100dvh; background-color: var(--paper); }
  #topbars {
    position: sticky;
    top: 0;
    background: var(--ink);
    padding-top: env(safe-area-inset-top);
  }
  #topbars::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 120px;
    background: var(--ink);
  }
  #playerbar {
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    min-height: 48px;
    height: 48px;
    padding: 0 8px;
  }
  #playerbar .logo,
  #playerbar .hdr-chat,
  #playerbar .music-toggle,
  #playerbar .lang-link,
  #playerbar .me {
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
  }
  .hdr-money { flex: 1; gap: 8px; }
  #playerbar .coin, #playerbar .jade {
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #playerbar .hdr-chat { margin-left: auto; }
  #playerbar .brand,
  #playerbar .et-clock,
  #playerbar .me b,
  #playerbar .me small,
  #playerbar .sp,
  .topnav { display: none !important; }
  #playerbar .logo { font-size: 24px; }
  #playerbar .coin, #playerbar .jade { font-size: 13px; }
  #playerbar .music-toggle,
  #playerbar .lang-link {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }
  .me { min-width: 44px; min-height: 44px; justify-content: center; padding: 0; }
  .hdr-av { width: 36px; height: 36px; }
  #guest-banner { padding: 8px 10px; font-size: 13px; }
  #guest-banner .btn { min-height: 44px; }

  #tabbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 45;
    background: var(--ink);
    min-height: calc(64px + env(safe-area-inset-bottom));
    padding: 0 0 env(safe-area-inset-bottom);
    border-top: 2px solid var(--paper);
    gap: 0;
  }
  #tabbar button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    background: transparent;
    color: var(--paper2);
    border: 0;
    border-radius: 0;
    font-family: inherit;
    font-weight: 800;
    font-size: 11px;
    line-height: 1.1;
    cursor: pointer;
    position: relative;
    padding: 6px 2px;
  }
  #tabbar button svg { width: 24px; height: 24px; }
  #tabbar button.on { background: transparent; color: var(--paper); }
  #tabbar button.on::before {
    content: "";
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 4px;
    background: var(--acc);
  }
  #tabbar .tab-dot { top: 6px; right: 18%; }

  #tabcontent { padding: 12px 12px calc(88px + env(safe-area-inset-bottom)); }
  .small, .sm, .xs, .eb, .hint, .term, .tag, .sheet th, .seed small, .plot-status, .ko, .pantry-card .term {
    font-size: 13px;
  }
  h1, .page-head h1 { font-size: 28px; }
  .hub-top h1 { font-size: 28px !important; }
  h2, .card h2 { font-size: 18px; }
  .hub-top .card { min-height: 0; }
  .sun { width: 52px; height: 52px; }
  .card { padding: 12px; }
  .btn, .btn.sm, button.harvest-btn, .gold-skip-btn {
    min-height: 44px;
    padding: 8px 12px;
    font-size: 14px;
  }
  input, select, textarea { font-size: 16px; } /* 16px keeps iOS from zooming on focus */
  input, select { min-height: 44px; }

  .subtabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y pinch-zoom;
  }
  .subtabs .btn {
    flex: 1 1 calc(33% - 6px);
    width: auto;
    max-width: 100%;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    touch-action: pan-x pan-y pinch-zoom;
  }
  .qty-presets { display: grid; grid-template-columns: 1fr 1fr; }
  .qty-presets .btn { width: 100%; }
  .inline-form .btn { flex: 1; }
  .hub-actions .btn { min-height: 44px; }
  .quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 10px; }
  .quick-actions .eb { grid-column: 1 / -1; }
  .quick-actions .btn { width: 100%; }

  .play { display: flex; flex-direction: column; }
  .play > .play-side { display: none; }
  .play-main { order: 0; min-width: 0; }
  .field-strip {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto;
    gap: 6px;
    margin: 0 0 10px;
  }
  .strip-bit {
    min-height: 44px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 1px;
    padding: 4px 8px;
    border: 2px solid var(--ink);
    border-radius: 4px;
    background: var(--paper);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    text-align: left;
    cursor: pointer;
  }
  .strip-bit .eb { font-size: 11px; }
  .strip-bit span:last-child {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .strip-chat { align-items: center; justify-content: center; padding: 4px 12px; background: var(--acc); color: var(--card); }
  .field-head h2 { font-size: 18px; }
  .seed-tray {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: visible;
    gap: 6px;
  }
  .seed { flex: none; width: 100%; min-width: 0; min-height: 72px; padding: 8px 4px; }
  .plots { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .plot { min-width: 0; min-height: 118px; }
  .plot-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .item-row { flex-wrap: wrap; row-gap: 8px; }
  .item-row > .btn { margin-left: auto; }
  .league-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .league-pick { min-height: 72px; padding: 8px 4px; }
  .podium .pod { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; }
  .podium .pod b { font-size: 22px; }
  .bank-bal { font-size: 34px; }
  .avatar-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .av-pick { min-height: 64px; }
  .chat-head button, .upd-x { width: 44px; height: 44px; }

  table.sheet.stack { border-collapse: separate; }
  table.sheet.stack thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0);
  }
  table.sheet.stack,
  table.sheet.stack tbody,
  table.sheet.stack tr { display: block; width: 100%; }
  table.sheet.stack tr {
    border: 2px solid var(--ink);
    border-radius: 4px;
    padding: 8px 10px;
    margin: 0 0 8px;
    background: var(--card);
  }
  table.sheet.stack tr.me { background: var(--paper2); }
  table.sheet.stack td { border: 0; background: transparent; }
  table.sheet.stack td:not([data-k]) { display: inline; padding: 0 6px 0 0; font-weight: 800; }
  table.sheet.stack td[data-k] {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
  }
  table.sheet.stack td[data-k]::before {
    content: attr(data-k);
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
  }
  .pantry-qty, .xp-text, .stat .k { font-size: 13px; }
  table.sheet.stack td[data-k] .row { justify-content: flex-end; }

  .modal-veil { align-items: flex-end; padding: 0; }
  .modal, .detail-modal, .profile-modal, .equip-modal {
    width: 100%;
    max-width: none;
    border-radius: 4px 4px 0 0;
    max-height: min(88vh, 100%);
    margin: 0;
    box-shadow: 0 -4px 0 var(--ink);
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .fg-overlay { align-items: flex-end; padding: 0; }
  .fg-card {
    width: 100%;
    max-width: none;
    border-radius: 4px 4px 0 0;
    box-shadow: 0 -4px 0 var(--ink);
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .fg-card canvas {
    width: min(320px, 100%) !important;
    height: auto !important;
  }
  .fg-head .btn { min-height: 44px; }

  #chatfab {
    right: 12px;
    bottom: calc(68px + env(safe-area-inset-bottom));
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    padding: 0;
    justify-content: center;
    border-radius: 4px;
  }
  #chatfab span:not(.chat-badge) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
  #chatsheet {
    left: 0; right: 0; bottom: 0;
    width: 100%;
    height: min(72vh, 560px);
    border-radius: 4px 4px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .chat-form button { min-height: 44px; min-width: 64px; }
  #toast-root {
    left: 12px; right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    align-items: stretch;
  }
  .toast { max-width: none; }

  #more-sheet { position: fixed; inset: 0; z-index: 60; }
  #more-sheet[hidden] { display: none; }
  .more-veil { position: absolute; inset: 0; background: rgba(43, 38, 32, .45); }
  .more-panel {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    background: var(--card);
    border: 2px solid var(--ink);
    border-bottom: 0;
    border-radius: 4px 4px 0 0;
    box-shadow: 0 -4px 0 var(--ink);
    padding: 14px 14px calc(18px + env(safe-area-inset-bottom));
  }
  .more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
  .more-grid button {
    min-height: 52px;
    border: 2px solid var(--ink);
    border-radius: 4px;
    background: var(--paper);
    color: var(--ink);
    font-family: inherit;
    font-weight: 800;
    font-size: 15px;
    cursor: pointer;
  }
  .more-grid button.on { background: var(--ink); color: var(--paper); }
  .more-grid .new { margin-left: 6px; }
  .more-grid button:last-child:nth-child(odd) { grid-column: 1 / -1; }

  .auth-wrap, .landing-hero {
    align-items: flex-start;
    padding: calc(16px + env(safe-area-inset-top)) 12px calc(20px + env(safe-area-inset-bottom));
  }
  .landing-logo { font-size: 44px; }
  .landing-tagline { font-size: 16px; }
  .auth-card .btn, .guest-btn, .discord-btn { width: 100%; min-height: 48px; justify-content: center; }
  .auth-music {
    width: 48px; height: 48px;
    right: calc(12px + env(safe-area-inset-right));
    bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

@media (max-height: 520px) and (orientation: landscape) and (max-width: 950px) {
  h1, .page-head h1, .hub-top h1 { font-size: 22px !important; }
  #playerbar { min-height: 44px; padding-top: 2px; padding-bottom: 2px; }
  #tabbar { min-height: 48px; }
  #tabbar button { min-height: 44px; padding-top: 2px; padding-bottom: 2px; }
  #tabcontent { padding: 4px 8px calc(52px + env(safe-area-inset-bottom)); }
  .hub-top { grid-template-columns: 1fr 1fr; margin-bottom: 8px; }
  .hub-top .card { min-height: 0; }
  .hub-top .card:last-child { grid-column: 1 / -1; }
  .play { display: block; }
  .play > .play-side { display: none; }
  .play-main.card { padding: 4px 8px; margin: 0; }
  .subtabs { margin-bottom: 2px; }
  .field-head { margin: 0; }
  .field-head h2 { font-size: 15px; line-height: 1.1; }
  .skill-strip { margin: 0 0 2px; }
  .seed-tray { margin: 2px 0; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .seed { min-height: 44px; padding: 2px; }
  .seed strong, .seed small { display: none; }
  .seed .item-icon { width: 28px; height: 28px; }
  .plots { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; align-items: stretch; }
  .plot { min-height: 0; padding: 4px 6px; }
  .plot-art { margin: -4px -6px 2px; aspect-ratio: 2 / 1; }
  .plot .harvest-btn, .gold-skip-btn { min-height: 44px; margin-top: 2px; padding: 4px 6px; }
  .skill-strip .xp-text { display: none; }
  #chatsheet { height: min(78vh, 300px); width: min(420px, 100%); left: auto; }
  #chatfab { bottom: calc(52px + env(safe-area-inset-bottom)); }
}

/* Tablet widths, including iPad portrait and landscape.
   The wrapped tab row used to paint outside a 64px bar and get clipped,
   so the game had no way to change screens. Keep pinch-zoom; do not clip the page. */
@media (min-width: 521px) and (max-width: 1180px) {
  #playerbar {
    overflow: visible;
    height: auto;
    max-height: none;
    flex-wrap: wrap;
    row-gap: 6px;
  }
  .topnav {
    display: flex;
    order: 5;
    flex: 1 0 100%;
    width: 100%;
    flex-wrap: wrap;
    overflow: visible;
    gap: 6px;
    padding-bottom: 2px;
  }
  .topnav button,
  .btn, .btn.sm,
  button.harvest-btn, .gold-skip-btn,
  .subtabs .btn,
  .qty-presets .btn,
  #playerbar .logo,
  #playerbar .hdr-chat,
  #playerbar .music-toggle,
  #playerbar .lang-link,
  #playerbar .me {
    min-height: 44px;
  }
  .topnav button { padding: 8px 12px; }
  #playerbar .logo,
  #playerbar .hdr-chat,
  #playerbar .music-toggle,
  #playerbar .lang-link {
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  #tabcontent, .play, .play-main, .hub-top, .hub-mid, .mkt-grid, .bank-grid, .card {
    min-width: 0;
    max-width: 100%;
  }
  .seed { min-height: 72px; }
  table.sheet:not(.stack) {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
  }
}

#chatfab { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

/* Login landing. Hero art is webp with a jpg fallback. */
body:has(.login-page) {
  background-image: none;
  background-color: var(--paper);
  overflow-x: clip;
}
.login-page {
  position: relative;
  min-height: 100svh;
  overflow-x: clip;
  background-color: var(--paper);
}
/* Viewport-sized layer so cover matches the screen. A tall card would
   otherwise scale the hero to the whole page and hide the village. */
.login-page::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-color: var(--paper);
  background-image: url("/assets/login/hero-desktop.jpg");
  background-image: image-set(
    url("/assets/login/hero-desktop.webp") type("image/webp"),
    url("/assets/login/hero-desktop.jpg") type("image/jpeg")
  );
  background-position: center left;
  background-size: cover;
  background-repeat: no-repeat;
}
.login-card {
  z-index: 1;
  position: absolute;
  left: clamp(32px, 8vw, 160px);
  top: 50%;
  transform: translateY(-50%);
  width: min(400px, 90vw);
  max-width: calc(100% - 48px);
  padding: 32px;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 4px 4px 0 rgba(43, 38, 32, .25);
}
.login-brand { display: flex; gap: 12px; align-items: center; }
.login-seal { width: 56px; height: 56px; flex: none; display: block; }
.login-card h1 { font: 700 30px/1.1 "Gowun Batang", serif; color: var(--ink); margin: 2px 0 0; }
.login-card .eyebrow {
  font: 800 14px/1.2 "Nunito", sans-serif;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--acc);
  margin: 0;
}
.login-card p { font: 600 15px/1.4 "Nunito", sans-serif; color: var(--muted); margin: 14px 0 0; }
.login-card label { display: block; font: 700 14px/1.3 "Nunito", sans-serif; color: var(--ink); margin: 12px 0 0; }
.login-card input {
  display: block;
  width: 100%;
  height: 48px;
  margin-top: 6px;
  padding: 0 12px;
  font: 600 16px/1 "Nunito", sans-serif;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 4px;
}
.login-card input::placeholder { color: var(--muted); }
.login-card input:focus-visible,
.login-card button:focus-visible,
.login-card a:focus-visible {
  outline: 3px solid var(--pine);
  outline-offset: 2px;
}
.stage + .stage { margin-top: 20px; padding-top: 16px; border-top: 2px solid var(--ink); }
html.js .login-card .stage { display: none; }
html.js .stage + .stage { margin-top: 0; padding-top: 0; border-top: 0; }
html.js .login-card[data-stage="welcome"] .stage-welcome,
html.js .login-card[data-stage="login"] .stage-login,
html.js .login-card[data-stage="signup"] .stage-signup {
  display: block;
  animation: stage-in .18s ease;
}
@keyframes stage-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.stage-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.stage-head { display: flex; align-items: center; gap: 4px; }
.stage-head h2 { margin: 0; font: 800 20px/1.2 "Nunito", sans-serif; color: var(--ink); }
.stage-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  margin-left: -8px;
  font: 800 22px/1 "Nunito", sans-serif;
  color: var(--ink);
  text-decoration: none;
}
.login-card .btn-primary,
.login-card .btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  margin-top: 16px;
  font: 800 20px/1 "Nunito", sans-serif;
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 4px 4px 0 rgba(43, 38, 32, .25);
  cursor: pointer;
  text-decoration: none;
}
.login-card .btn-primary { color: var(--card); background: var(--acc); }
.login-card .btn-secondary { color: var(--card); background: var(--ink); }
.stage-actions .btn-primary,
.stage-actions .btn-secondary { margin-top: 0; }
.login-card .btn-primary:active,
.login-card .btn-secondary:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 rgba(43, 38, 32, .25); }
.login-card .error {
  font: 700 14px/1.35 "Nunito", sans-serif;
  color: var(--soil);
  border-left: 3px solid var(--acc);
  padding: 8px 12px;
  margin: 14px 0 0;
}
.login-card .error:empty { display: none; }
.login-card a.login-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0;
  font: 700 15px/1.3 "Nunito", sans-serif;
  color: var(--ink);
  text-decoration: underline;
}
.login-links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; }
.login-card .check {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  margin-top: 12px;
  font: 700 14px/1.35 "Nunito", sans-serif;
  color: var(--ink);
}
.login-card .check input {
  width: 22px;
  height: 22px;
  margin: 0;
  flex: none;
  padding: 0;
}
.login-card .ref-banner { color: var(--ink); margin-top: 12px; }
body:has(.login-page) .auth-music {
  top: calc(12px + env(safe-area-inset-top));
  bottom: auto;
}
@media (max-width: 899px), (orientation: portrait) {
  .login-page::before {
    background-image: url("/assets/login/hero-mobile.jpg");
    background-image: image-set(
      url("/assets/login/hero-mobile.webp") type("image/webp"),
      url("/assets/login/hero-mobile.jpg") type("image/jpeg")
    );
    background-position: center top;
  }
  .login-card {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    margin: 36svh auto calc(24px + env(safe-area-inset-bottom));
    width: calc(100vw - 48px);
    max-width: min(420px, calc(100% - 48px));
    padding: 24px;
  }
  .login-card h1 { font-size: 26px; }
}
