:root {
  --ink: #2b2118;
  --muted: #7a6a5c;
  --panel: #fffaf2;
  --line: #eadbc8;
  --glass: rgba(26, 20, 34, 0.86);
  --glass-line: rgba(255, 255, 255, 0.1);
  --accent: #ffc400;
  --accent-dark: #c99600;
  --accent-ink: #2a1d00;
  --green: #2fbf71;
  --green-dark: #1f8d52;
  --red: #e94f37;
  --shadow: 0 10px 30px rgba(10, 5, 20, 0.45);
  --pixel: "Silkscreen", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d1626; color: var(--ink); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; cursor: pointer; border: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

canvas#town { position: fixed; inset: 0; display: block; touch-action: none; cursor: grab; }
canvas#town.dragging { cursor: grabbing; }
canvas#town.pointing { cursor: pointer; }

/* ---------- floating HUD ---------- */
.hud { position: fixed; z-index: 5; display: flex; gap: 8px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud.tl { top: 12px; left: 12px; align-items: center; flex-wrap: wrap; max-width: calc(100% - 300px); }
.hud.tr { top: 12px; right: 12px; }
.hud.bl { left: 12px; bottom: 12px; align-items: flex-end; }

.brand {
  font-family: var(--pixel); font-size: 18px; color: #fff; background: var(--glass); border: 1px solid var(--glass-line);
  padding: 7px 14px; border-radius: 12px; box-shadow: var(--shadow); white-space: nowrap;
}
.stats { display: flex; gap: 6px; flex-wrap: wrap; }
.stats .chip { color: #fff; background: var(--glass); border: 1px solid var(--glass-line); border-radius: 999px; padding: 6px 11px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); white-space: nowrap; }

.hbtn {
  display: flex; align-items: center; gap: 6px; color: #fff; background: var(--glass); border: 1px solid var(--glass-line);
  border-radius: 12px; padding: 8px 12px; font-weight: 700; box-shadow: var(--shadow);
}
.hbtn:hover { background: rgba(50, 40, 64, 0.92); }
.hbtn span { font-size: 14px; }

#minimap { border-radius: 12px; border: 2px solid rgba(255,255,255,0.85); box-shadow: var(--shadow); cursor: pointer; image-rendering: auto; background: #5f8f47; }
.zoom { display: flex; flex-direction: column; gap: 6px; }
.zoom button { width: 40px; height: 38px; border-radius: 10px; background: var(--glass); color: #fff; font-size: 20px; border: 1px solid var(--glass-line); box-shadow: var(--shadow); }
.zoom button:hover { background: rgba(50, 40, 64, 0.92); }

.zone {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 4; pointer-events: none;
  font-family: var(--pixel); font-size: 22px; color: #fff; text-shadow: 0 2px 0 #1d1626, 0 0 12px rgba(0,0,0,0.5);
  animation: zoneIn 2.6s ease forwards;
}
@keyframes zoneIn { 0% { opacity: 0; transform: translate(-50%, -6px); } 12% { opacity: 1; transform: translate(-50%, 0); } 80% { opacity: 1; } 100% { opacity: 0; } }
.shout {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 5; width: min(720px, calc(100% - 24px)); overflow: hidden;
  background: linear-gradient(90deg, #ff4fa3, #7d5cff); color: #fff; border-radius: 999px; padding: 7px 0; font-weight: 800; box-shadow: var(--shadow); pointer-events: none;
}
.shout span { display: inline-block; white-space: nowrap; padding-left: 100%; animation: marquee 18s linear infinite; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-100%); } }
.conn { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: 6; background: var(--glass); color: #fff; padding: 6px 12px; border-radius: 999px; font-size: 13px; }

/* ---------- dock ---------- */
.dock {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; max-width: min(640px, calc(100% - 24px));
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 18px; color: #fff; box-shadow: var(--shadow);
}
.dock .who { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.dock .face { width: 44px; height: 44px; border-radius: 10px; background: #efe2cf; image-rendering: pixelated; flex: none; }
.dock .txt { min-width: 0; }
.dock .txt b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.dock .txt span { display: block; font-size: 12px; opacity: 0.75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { font-family: var(--pixel); font-size: 22px; min-width: 84px; text-align: center; color: #ffe27a; }

/* chunky game buttons */
.btn {
  border-radius: 12px; padding: 10px 16px; font-weight: 800; white-space: nowrap; letter-spacing: 0.01em;
  box-shadow: 0 3px 0 rgba(0,0,0,0.35); transition: transform 0.06s, box-shadow 0.06s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.35); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 0 var(--accent-dark); }
.btn.green { background: var(--green); color: #fff; box-shadow: 0 3px 0 var(--green-dark); }
.btn.soft { background: rgba(255,255,255,0.14); color: #fff; }
.btn.light { background: #f1e6d6; color: var(--ink); box-shadow: 0 3px 0 #d9c7ad; }
.btn.danger { background: #fbe1dc; color: #b3261e; box-shadow: 0 3px 0 #efc0b8; }
.btn.big { padding: 13px 22px; font-size: 16px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- panels ---------- */
.panel {
  position: fixed; top: 64px; right: 12px; bottom: 96px; width: min(380px, calc(100% - 24px)); z-index: 7;
  background: var(--panel); border-radius: 18px; box-shadow: var(--shadow); padding: 14px 16px; overflow-y: auto;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel h2 { margin: 0; font-family: var(--pixel); font-size: 17px; font-weight: 400; }
button.icon { background: transparent; font-size: 18px; color: var(--muted); padding: 4px 8px; border-radius: 8px; }
button.icon:hover { background: #f1e6d6; }
#board-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 10px; }
#board-list li { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
#board-list li.shipped { border-color: #ffd36b; background: #fffbea; }
#board-list .who { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
#board-list .who b { color: var(--ink); cursor: pointer; }
#board-list .what { margin-top: 4px; word-wrap: break-word; }
.swatch-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.room { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-top: 10px; }
.room.mine { border-color: #9be3b9; background: #f2fcf6; }
.room.free { border-style: dashed; background: #fffdf6; }
.room h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.room .members { font-size: 13px; color: var(--muted); margin-top: 4px; }
.room .row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.room .row .btn { padding: 8px 12px; font-size: 13px; }

/* ---------- modals ---------- */
#modal-root .backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(15, 10, 20, 0.55); display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal { background: var(--panel); border-radius: 20px; box-shadow: var(--shadow); width: min(560px, 100%); max-height: calc(100vh - 24px); overflow-y: auto; padding: 20px 20px 16px; }
.modal.wide { width: min(900px, 100%); }
.modal h2 { margin: 0 0 4px; font-size: 21px; }
.modal h3 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.modal label.field { display: block; margin-top: 10px; font-size: 13px; color: var(--muted); }
.modal input[type=text], .modal input[type=url], .modal textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font: inherit; color: var(--ink);
}
.modal textarea { resize: vertical; min-height: 70px; }
.modal input:focus, .modal textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.err { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 1em; }
.copybox { display: flex; gap: 6px; margin-top: 10px; }
.copybox input { flex: 1; font-size: 13px !important; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { background: #f1e6d6; color: var(--ink); border-radius: 999px; padding: 6px 11px; font-size: 13px; }
.chips button.on { background: var(--ink); color: #fff; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cards button { text-align: left; background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.cards button b { display: block; }
.cards button span { font-size: 12px; color: var(--muted); }
.cards button.on { border-color: var(--ink); background: #fff8e6; }
.chips button.pro { background: #fff3cf; box-shadow: inset 0 0 0 1px #f0c94a; }
.chips button.pro.on { background: #5c3e08; color: #ffe27a; }
.chips button.locked { opacity: 0.8; }
.cards button.pro { background: #fffaf0; border-color: #f0c94a; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-top: 14px; }
.plan { background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; }
.plan.on { border-color: #f0c94a; box-shadow: 0 0 0 4px #fff3cf; }
.plan h3 { margin: 0; font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--ink); }
.plan .owned { color: var(--green-dark); font-weight: 800; margin: 4px 0; }
.buy-row { display: flex; flex-wrap: wrap; gap: 6px; }
.buy-row .btn { padding: 8px 12px; font-size: 13px; }
.card .product { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.card .product .btn { padding: 7px 12px; font-size: 13px; text-decoration: none; }
.modal .row { display: flex; gap: 6px; margin-top: 6px; }
.modal .row input { margin-top: 0 !important; }
.plan .price { font-family: var(--pixel); font-size: 20px; margin: 6px 0; }
.plan ul { padding-left: 18px; margin: 6px 0 12px; font-size: 14px; flex: 1; }
.plan li { margin: 3px 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches button { width: 28px; height: 28px; border-radius: 8px; border: 2px solid rgba(0,0,0,0.12); }
.swatches button.on { outline: 3px solid var(--ink); outline-offset: 1px; }

.creator { display: grid; grid-template-columns: 300px 1fr; gap: 18px; }
.creator .preview { position: sticky; top: 0; align-self: start; }
.creator canvas { width: 300px; height: 210px; border-radius: 14px; image-rendering: pixelated; display: block; }
.creator .preview .hint { font-size: 12px; color: var(--muted); margin-top: 6px; text-align: center; }
.steps { display: flex; gap: 6px; margin: 10px 0 4px; }
.steps span { flex: 1; height: 5px; border-radius: 5px; background: var(--line); }
.steps span.on { background: var(--accent); }
@media (max-width: 760px) {
  .creator { grid-template-columns: 1fr; }
  .creator .preview { position: static; display: flex; flex-direction: column; align-items: center; }
  .creator canvas { width: 100%; max-width: 360px; height: auto; aspect-ratio: 10 / 7; }
}

.card { width: min(380px, 100%); }
.card .head { display: flex; gap: 12px; align-items: center; }
.card .avatar { width: 64px; height: 64px; border-radius: 12px; image-rendering: pixelated; background: #efe2cf; flex: none; }
.card .name { font-size: 18px; font-weight: 800; }
.card .handle a { color: #1d6fd1; text-decoration: none; }
.card .status { margin-top: 10px; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.card .facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.card .facts span { background: #f1e6d6; border-radius: 999px; padding: 4px 10px; font-size: 12px; }
.card .project { margin-top: 10px; }
.card .project a { color: #1d6fd1; word-break: break-all; }
.reactions { display: flex; gap: 6px; margin-top: 12px; }
.reactions button { flex: 1; font-size: 22px; padding: 8px 0; background: #f1e6d6; border-radius: 12px; }
.reactions button:hover { background: #ead9c2; }

.durations { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.durations button { flex: 1 1 70px; padding: 10px; border-radius: 12px; background: #f1e6d6; font-weight: 700; }
.durations button.on { background: var(--ink); color: #fff; }
label.check { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-weight: 600; cursor: pointer; }
label.check input { width: 18px; height: 18px; }

#toasts { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 30; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: var(--glass); color: #fff; padding: 9px 14px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); max-width: 92vw; animation: pop 0.2s ease-out; border: 1px solid var(--glass-line); }
@keyframes pop { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 700px) {
  .hbtn span, .brand span { display: none; }
  .hud.tl { max-width: calc(100% - 210px); }
  .stats .chip.opt { display: none; }
  #minimap { display: none; }
  .hud.bl { left: auto; right: 12px; bottom: 150px; }
  .dock { bottom: 10px; flex-wrap: wrap; justify-content: center; border-radius: 16px; }
  .dock .who { flex-basis: 100%; }
  .timer { font-size: 18px; min-width: 64px; }
  .btn { padding: 9px 12px; }
  .panel { top: 60px; bottom: 120px; }
}

/* X photo + cheers */
.card .handle { display: flex; align-items: center; gap: 6px; }
.xphoto { width: 20px; height: 20px; border-radius: 50%; }
#board-list li { position: relative; padding-right: 64px; }
#board-list .cheer { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: #fff3cf; border: 1px solid #f0c94a; border-radius: 999px; padding: 4px 10px; font-weight: 800; font-size: 13px; }
#board-list .cheer:hover { background: #ffe9a3; }
#board-list .cheer.own { background: #f1e6d6; border-color: var(--line); cursor: default; }
.xlinked { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.xlinked .xphoto { width: 26px; height: 26px; }

/* ship bar, big ship, feed, league, insights */
.shipbar { position: fixed; top: 104px; left: 50%; transform: translateX(-50%); z-index: 8; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 16px; max-width: calc(100% - 24px);
  background: linear-gradient(90deg, #1f8d52, #2fbf71); color: #fff; font-weight: 800; border-radius: 999px; box-shadow: var(--shadow); animation: barin 0.3s ease-out; }
@keyframes barin { from { transform: translate(-50%, -8px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.shipbar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shipbar .btn { padding: 6px 12px; font-size: 13px; }
.bigship { position: fixed; inset: 0; z-index: 40; background: radial-gradient(circle at 50% 40%, rgba(80, 30, 120, 0.93), rgba(10, 5, 20, 0.97)); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fadein 0.25s ease-out; }
.big-inner { text-align: center; color: #fff; max-width: 760px; }
.big-kicker { font-family: var(--pixel); color: #ffe27a; font-size: 22px; letter-spacing: 0.1em; }
.big-name { font-family: var(--pixel); font-size: clamp(28px, 6vw, 56px); margin-top: 10px; text-shadow: 0 0 24px #ff4fa3; }
.big-text { font-size: clamp(18px, 3vw, 26px); margin-top: 12px; font-weight: 700; }
.big-prod { margin-top: 10px; color: #ffe27a; font-weight: 800; }
.feed { flex-basis: 100%; display: flex; flex-direction: column; gap: 4px; max-width: 360px; background: var(--glass); border: 1px solid var(--glass-line); border-radius: 12px; padding: 8px 10px; color: #fff; box-shadow: var(--shadow); }
.feed-head { font-family: var(--pixel); font-size: 12px; color: #ffe27a; }
.feed-item { text-align: left; background: transparent; color: #fff; font-size: 13px; padding: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-item em { color: #ffe27a; font-style: normal; font-weight: 800; }
#board-list li.league { border-color: #b197fc; }
#board-list li.champ { background: #fff3cf; border-color: #f0c94a; }
#board-list li.rules { background: transparent; border: 0; padding: 0 2px; }
#board-list .rank { font-weight: 800; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 140px; margin-top: 12px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.chart .col { flex: 1; height: 100%; display: flex; align-items: flex-end; gap: 1px; position: relative; padding-bottom: 14px; }
.chart .bar { flex: 1; min-height: 2px; border-radius: 3px 3px 0 0; }
.chart .bar.v { background: #4dabf7; }
.chart .bar.c { background: #2fbf71; }
.chart .col span { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--muted); }
button.linkish { background: transparent; color: #b3261e; font-size: 12px; padding: 0; text-decoration: underline; float: right; margin-top: -26px; }
@media (max-width: 700px) { .shipbar { top: 64px; } }
@media (max-width: 1240px) { .hbtn span { display: none; } }
