/* Fanville — cozy "sticker" style: warm cream, sunny yellow, ink outlines, chunky buttons */
:root {
  --bg: #fff6e6;
  --surface: #ffffff;
  --surface-2: #fff9ef;
  --ink: #1f2430;
  --muted: #6e6a62;
  --line: #f0e2c6;
  --line-2: #e6d3ad;
  --accent: #ffc531;
  --accent-deep: #e39a12;
  --accent-ink: #3a2a00;
  --brick: #e0573d;
  --sky: #7fc4ef;
  --good: #22a35a;
  --bad: #e0483c;
  --radius: 22px;
  --display: "Fredoka", "Avenir Next", system-ui, sans-serif;
  --body: "Nunito", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-family: var(--body);
  color: var(--ink);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; color: var(--ink); -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1200px 500px at 50% -200px, #ffe9b8 0%, rgba(255, 233, 184, 0) 70%),
    var(--bg);
}
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
a { color: inherit; }
h1, h2, h3, .display { font-family: var(--display); }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 18px; background: rgba(255, 249, 238, 0.88); backdrop-filter: blur(10px) saturate(1.2);
  border-bottom: 2px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand .logo { width: 40px; height: 40px; flex: none; filter: drop-shadow(0 2px 0 rgba(31, 36, 48, 0.25)); transition: transform .2s; }
.brand:hover .logo { transform: rotate(-6deg) scale(1.05); }
.wordmark { font-family: var(--display); font-weight: 700; font-size: 27px; letter-spacing: 0.2px; line-height: 1; }
.beta {
  display: inline-block; font-family: var(--display); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px;
  background: var(--ink); color: var(--accent); padding: 3px 8px 2px; border-radius: 999px; transform: rotate(-6deg) translateY(-8px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
}
.stats { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.pill {
  background: var(--surface); border: 2px solid var(--line); border-radius: 999px; padding: 5px 11px;
  font-size: 13px; font-weight: 800; white-space: nowrap; color: var(--ink);
}
.pill.how { background: var(--ink); color: #fff; border-color: var(--ink); display: inline-flex; gap: 6px; align-items: center; }
.pill.how > span:first-child {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: var(--ink); font-size: 12px; font-weight: 900;
}

/* ---------- Map ---------- */
.map-wrap {
  position: relative; height: min(62vh, 660px); min-height: 340px; background: #8cc866; overflow: hidden; touch-action: none;
  border-bottom: 3px solid var(--ink); box-shadow: 0 6px 0 rgba(31, 36, 48, 0.08);
}
#map { width: 100%; height: 100%; display: block; cursor: grab; }
#map:active { cursor: grabbing; }
.map-title {
  position: absolute; left: 16px; top: 14px; background: rgba(255, 255, 255, 0.94); color: var(--ink); padding: 9px 14px 8px; border-radius: 16px;
  font-family: var(--display); font-weight: 700; font-size: 17px; max-width: calc(100% - 90px); border: 2px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
}
.map-title small { display: block; font-family: var(--body); font-weight: 700; color: var(--muted); font-size: 12px; margin-top: 1px; }
.map-hint {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); font-size: 12px; color: #fff; font-weight: 800;
  background: rgba(31, 36, 48, 0.55); padding: 5px 12px; border-radius: 999px; white-space: nowrap; pointer-events: none;
}
.zoom { position: absolute; right: 14px; top: 14px; display: flex; flex-direction: column; gap: 6px; }
.zoom button {
  width: 38px; height: 38px; border-radius: 12px; border: 2px solid var(--ink); background: #fff; color: var(--ink); font-size: 18px; font-weight: 900;
  box-shadow: 0 3px 0 var(--ink); transition: transform .08s, box-shadow .08s;
}
.zoom button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.tooltip {
  position: absolute; z-index: 5; background: rgba(31, 36, 48, 0.94); color: #fff; padding: 10px 12px; border-radius: 12px; font-size: 13px;
  max-width: 240px; pointer-events: none; transform: translate(-50%, calc(-100% - 12px)); line-height: 1.35;
}

/* Focus card (click on the map) */
.focus {
  position: absolute; left: 14px; bottom: 14px; z-index: 6; width: min(350px, calc(100% - 28px)); background: #fff;
  border: 2px solid var(--ink); border-radius: 18px; padding: 14px 16px; box-shadow: 0 5px 0 var(--ink); animation: focusIn .25s ease-out;
}
@keyframes focusIn { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.focus-close { position: absolute; right: 10px; top: 10px; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface-2); font-weight: 900; color: var(--ink); }
.focus-kicker { font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.focus-title { font-family: var(--display); font-size: 21px; font-weight: 700; margin: 2px 34px 4px 0; word-break: break-word; }
.focus-sub { font-size: 13px; color: #4a4f5c; margin-bottom: 10px; line-height: 1.45; font-weight: 600; }
.plaque { background: var(--surface-2); border: 2px dashed var(--line-2); border-radius: 12px; padding: 8px 10px; font-size: 13px; }
.plaque b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 4px; }
.plaque div { display: flex; justify-content: space-between; padding: 2px 0; font-weight: 800; }

/* ---------- Layout ---------- */
.grid { display: grid; grid-template-columns: 1fr; gap: 18px; padding: 22px 16px; max-width: 1140px; margin: 0 auto; }
@media (min-width: 880px) { .grid { grid-template-columns: 1.12fr 1fr; padding: 28px 22px; } }
.col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
@media (max-width: 879px) { .col:last-child { order: -1; } }

.card {
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 20px;
  box-shadow: 0 4px 0 var(--line);
}
.card h2 { margin: 0 0 6px; font-size: 24px; font-weight: 700; line-height: 1.15; }
.card h3 {
  margin: 0 0 10px; font-family: var(--display); font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.2px; color: #a36d0c;
}
.card p { margin: 6px 0 12px; line-height: 1.55; color: #3d4250; font-weight: 600; }
.muted { color: var(--muted); font-size: 13px; font-weight: 600; }
.crisis { display: inline-block; background: #ffe1dc; color: #9b1c1c; font-weight: 900; font-size: 12px; padding: 5px 11px; border-radius: 999px; margin-bottom: 8px; border: 2px solid #f6b7ac; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 2px solid var(--accent-deep); border-radius: 14px;
  padding: 10px 16px; font-weight: 900; background: var(--accent); color: var(--accent-ink); text-decoration: none;
  box-shadow: 0 4px 0 var(--accent-deep); transition: transform .08s, box-shadow .08s, filter .15s; line-height: 1.2;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-deep); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.ghost { background: #fff; border-color: var(--line-2); color: var(--ink); box-shadow: 0 4px 0 var(--line-2); }
.btn.dark { background: var(--ink); border-color: #000; color: #fff; box-shadow: 0 4px 0 #000; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 11px; box-shadow: 0 3px 0 var(--accent-deep); }
.btn.small.ghost { box-shadow: 0 3px 0 var(--line-2); }
.btn.small.dark { box-shadow: 0 3px 0 #000; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Story & vote ---------- */
.vote-opt {
  position: relative; width: 100%; text-align: left; border: 2px solid var(--line-2); background: #fff; border-radius: 16px; padding: 13px 15px;
  margin-bottom: 9px; font-weight: 800; overflow: hidden; color: var(--ink); box-shadow: 0 3px 0 var(--line-2);
}
.vote-opt .bar { position: absolute; inset: 0; width: 0; background: rgba(255, 197, 49, 0.3); transition: width .5s; }
.vote-opt span { position: relative; display: flex; justify-content: space-between; gap: 8px; }
.vote-opt.mine { border-color: var(--accent-deep); box-shadow: 0 3px 0 var(--accent-deep); }
.vote-opt:not(:disabled):hover { border-color: var(--accent-deep); transform: translateY(-1px); }

.progress { height: 18px; border-radius: 99px; background: #f3e8d3; overflow: hidden; margin: 10px 0 6px; border: 2px solid var(--line-2); }
.progress > div { height: 100%; background: repeating-linear-gradient(-45deg, #ffc531 0 10px, #ffd65c 10px 20px); border-radius: 99px; transition: width .6s; }

/* ---------- Passport & me ---------- */
.passport {
  border-radius: 18px; padding: 18px; color: #fff; background: linear-gradient(135deg, #1f2a44, #2c3e66); position: relative; overflow: hidden;
  margin-bottom: 16px; border: 2px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
}
.passport::after { content: ''; position: absolute; right: -10px; top: -10px; width: 90px; height: 90px; background: url('/logo.svg') center / contain no-repeat; opacity: 0.22; transform: rotate(12deg); }
.passport .num { font-size: 12px; letter-spacing: 2px; opacity: 0.85; font-weight: 800; }
.passport .handle { font-family: var(--display); font-size: 28px; font-weight: 700; margin: 2px 0 8px; word-break: break-all; }
.badge { display: inline-block; font-size: 11px; font-weight: 900; padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.18); margin: 2px 4px 2px 0; }
.badge.gold { background: var(--accent); color: var(--accent-ink); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.kv > div { background: var(--surface-2); border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.kv .k { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 900; }
.kv .v { font-family: var(--display); font-size: 22px; font-weight: 700; margin-top: 2px; }
.energy { letter-spacing: 2px; }

.play-card {
  display: flex; gap: 14px; align-items: center; background: linear-gradient(135deg, #fff1c4, #ffd77a); border: 2px solid var(--accent-deep);
  border-radius: 18px; padding: 14px; margin-bottom: 14px; box-shadow: 0 4px 0 var(--accent-deep);
}
.play-art {
  position: relative; width: 76px; height: 76px; flex: none; border-radius: 16px; background: #bfe3ff; display: grid; place-items: center; font-size: 30px;
  overflow: hidden; border: 2px solid var(--ink);
}
.play-art span { position: absolute; bottom: 4px; font-size: 26px; }
.play-title { font-family: var(--display); font-weight: 700; font-size: 22px; }
.play-sub { font-size: 13px; color: #5b4a12; margin: 2px 0 10px; line-height: 1.4; font-weight: 700; }
.play-btn { width: 100%; font-size: 16px; padding: 12px 16px; background: var(--ink); color: #fff; border-color: #000; box-shadow: 0 4px 0 #000; }
.play-btn:active { box-shadow: 0 1px 0 #000; }
.play-btn:disabled { background: #8a8f9c; border-color: #6b707c; box-shadow: 0 4px 0 #6b707c; }
.play-card.fish { background: linear-gradient(135deg, #dcf1ff, #a9dbff); border-color: #3f8fd0; box-shadow: 0 4px 0 #3f8fd0; }
.play-card.fish .play-sub { color: #194a6b; }
.play-card.fish .play-art { background: #2f86d6; }

.tasks { border: 2px dashed var(--line-2); border-radius: 16px; padding: 12px 14px; margin-bottom: 14px; background: var(--surface-2); }
.tasks-head { display: flex; justify-content: space-between; margin-bottom: 6px; font-family: var(--display); font-size: 16px; }
.task { display: flex; gap: 10px; align-items: center; padding: 5px 0; font-weight: 700; }
.task .check { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line-2); display: grid; place-items: center; font-size: 13px; font-weight: 900; flex: none; background: #fff; }
.task.done { color: var(--muted); }
.task.done > span:last-child { text-decoration: line-through; }
.task.done .check { background: var(--good); border-color: var(--good); color: #fff; }

/* ---------- Join ---------- */
.step { border: 2px dashed var(--line-2); border-radius: 16px; padding: 12px; margin-bottom: 10px; }
.step.active { border-style: solid; border-color: var(--accent-deep); background: #fffaf0; }
.step.done { opacity: 0.6; }
.step > b { display: block; margin-bottom: 6px; font-family: var(--display); font-weight: 600; font-size: 16px; }
.field { width: 100%; padding: 11px 12px; border: 2px solid var(--line-2); border-radius: 12px; background: #fff; margin-bottom: 8px; color: var(--ink); font-weight: 700; }
.field:focus { outline: none; border-color: var(--accent-deep); box-shadow: 0 0 0 3px rgba(255, 197, 49, 0.35); }
.districts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.district-btn { border: 2px solid var(--line-2); background: #fff; border-radius: 12px; padding: 10px; font-weight: 900; text-align: left; color: var(--ink); }
.district-btn.sel { border-color: var(--c); box-shadow: inset 0 0 0 2px var(--c); }
.district-btn i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 6px; }
.tweetbox { background: var(--surface-2); border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 8px; word-break: break-word; font-weight: 600; }
.error { color: var(--bad); font-weight: 800; font-size: 13px; margin-top: 4px; }

/* ---------- Boards ---------- */
.board { list-style: none; margin: 0; padding: 0; }
.board li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 2px solid #f7efdf; font-weight: 800; }
.board li:last-child { border-bottom: 0; }
.board .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.board .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dbar { height: 10px; border-radius: 9px; background: #f3e8d3; margin-top: 5px; }
.dbar > div { height: 100%; border-radius: 9px; }

/* ---------- Perks, shop, election ---------- */
.perks { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 560px) { .perks { grid-template-columns: 1fr 1fr; } }
.perk { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); border: 2px solid var(--line); }
.perk.locked { opacity: 0.6; background: #f8f4ec; border-style: dashed; }
.perk .ico { font-size: 22px; width: 32px; text-align: center; flex: none; }
.perk .txt { flex: 1; min-width: 0; font-size: 13px; line-height: 1.35; font-weight: 600; }
.perk .txt b { font-size: 14px; font-weight: 900; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 10px; }
.shop-item {
  border: 2px solid var(--line-2); border-radius: 14px; padding: 10px; background: #fff; text-align: center; color: var(--ink);
  box-shadow: 0 3px 0 var(--line-2); transition: transform .08s;
}
.shop-item:not(:disabled):hover { transform: translateY(-2px); border-color: var(--accent-deep); }
.shop-item .ico { font-size: 28px; }
.shop-item .nm { font-weight: 900; font-size: 13px; margin: 4px 0 2px; }
.shop-item .pr { font-size: 12px; color: var(--muted); font-weight: 800; }
.shop-item.owned { border-color: var(--good); background: #effaf3; box-shadow: 0 3px 0 var(--good); }
.shop-item:disabled { opacity: 0.55; cursor: default; }
.shop-item.owned:disabled { opacity: 1; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.swatch { width: 30px; height: 30px; border-radius: 9px; border: 2px solid #fff; box-shadow: 0 0 0 2px var(--line-2); }
.swatch.sel { box-shadow: 0 0 0 3px var(--ink); }
.cands { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.cand { display: flex; gap: 10px; align-items: center; border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px; background: #fff; }
.cand .who { flex: 1; min-width: 0; }
.cand .who b { display: block; }
.cand .who small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.cand .votes { font-family: var(--display); font-weight: 700; }
.cand.mine { border-color: var(--accent-deep); background: #fffaf0; }
.mayor-box { display: flex; gap: 12px; align-items: center; background: linear-gradient(135deg, #fff1c4, #ffd77a); border: 2px solid var(--accent-deep); border-radius: 16px; padding: 12px; margin-bottom: 10px; }
.mayor-box .crown { font-size: 32px; }
.policy-grid { display: grid; gap: 8px; margin-top: 8px; }
.policy { text-align: left; border: 2px solid var(--line-2); border-radius: 14px; padding: 10px 12px; background: #fff; color: var(--ink); box-shadow: 0 3px 0 var(--line-2); }
.policy:hover { border-color: var(--accent-deep); }

video { width: 100%; max-height: 70vh; border-radius: 16px; background: #000; border: 2px solid var(--ink); }

/* ---------- Footer ---------- */
.site-foot { text-align: center; padding: 28px 16px 48px; border-top: 2px solid var(--line); margin-top: 8px; }
.foot-brand { display: inline-flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 20px; }
.foot-brand .beta { transform: rotate(-6deg) translateY(-6px); }
.foot { color: var(--muted); font-size: 14px; font-weight: 700; margin: 10px auto 4px; max-width: 520px; }
.foot-small { color: #a39b8c; font-size: 12px; font-weight: 600; margin: 0; }

/* ---------- Modals & toast ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(31, 36, 48, 0.55); display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(2px); }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 22px; padding: 14px; width: min(392px, 100%); border: 2px solid var(--ink); box-shadow: 0 6px 0 var(--ink); }
.modal-head { display: flex; justify-content: space-between; align-items: center; font-weight: 900; margin-bottom: 10px; gap: 8px; }
.modal-head strong { font-family: var(--display); font-size: 18px; font-weight: 700; }
#shiftCanvas { width: 100%; height: auto; border-radius: 14px; background: #bfe3ff; display: block; touch-action: none; border: 2px solid var(--ink); }
.modal-foot { margin-top: 12px; text-align: center; }
.shift-start { display: flex; gap: 8px; justify-content: center; }
.guide-box { width: min(470px, 100%); max-height: 90vh; overflow: auto; padding: 22px; }
.guide-box h2 { margin: 0 0 6px; font-size: 26px; }
.guide-steps { list-style: none; padding: 0; margin: 14px 0 18px; display: flex; flex-direction: column; gap: 12px; }
.guide-steps li { display: flex; gap: 12px; align-items: flex-start; line-height: 1.45; font-size: 14px; font-weight: 600; }
.guide-steps li b { font-family: var(--display); font-size: 16px; font-weight: 600; }
.guide-steps li > span { font-size: 24px; width: 44px; height: 44px; border-radius: 14px; background: var(--surface-2); border: 2px solid var(--line); display: grid; place-items: center; flex: none; }
.share-box { width: min(560px, 100%); }
.share-box img { width: 100%; border-radius: 12px; display: block; background: #eee; border: 2px solid var(--line); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 16px;
  font-weight: 800; z-index: 60; box-shadow: 0 4px 0 #000; max-width: calc(100% - 32px); border: 2px solid #000;
}
.toast.bad { background: var(--bad); border-color: #8f1f15; box-shadow: 0 4px 0 #8f1f15; }

/* ---------- Small screens ---------- */
@media (max-width: 600px) {
  .topbar { padding: 8px 12px; }
  .brand .logo { width: 34px; height: 34px; }
  .wordmark { font-size: 23px; }
  .how-text { display: none; }
  .pill { font-size: 12px; padding: 4px 9px; }
  .map-hint { display: none; }
  .map-title { font-size: 15px; }
  .focus { padding: 10px 12px; max-height: 46%; overflow: auto; }
  .focus-title { font-size: 17px; }
  .focus-sub { margin-bottom: 6px; }
  .card { padding: 16px; }
}
@media (max-width: 400px) { #moralePill { display: none; } }
