/* YARD WARS — styles */
:root {
  --bg: #0d1b3d; --bg2: #13254f; --card: #fdfaf3; --ink: #1d2433; --muted: #66708a;
  --red: #d7263d; --green: #1f8a4c; --gold: #ffcf3f; --cyan: #00bcd4; --line: #e4dccb;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif; color: var(--ink);
  background: radial-gradient(ellipse at top, #1d3470 0%, var(--bg) 60%) fixed; overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
body.dragging { cursor: grabbing; user-select: none; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }
button { font-family: inherit; }

/* buttons */
.btn { border: 0; border-radius: 999px; padding: 10px 18px; font-weight: 700; font-size: 15px; cursor: pointer;
  background: var(--red); color: #fff; box-shadow: 0 3px 0 #8e1426; transition: transform .08s, filter .15s; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #8e1426; }
.btn:disabled { background: #b7b2a8; box-shadow: 0 3px 0 #8d887f; cursor: not-allowed; filter: none; }
.btn.go { background: var(--green); box-shadow: 0 3px 0 #0f5a2f; }
.btn.ghost { background: #fff; color: var(--ink); box-shadow: 0 3px 0 #c9c1ad; border: 1px solid var(--line); }
.btn.small { padding: 7px 13px; font-size: 13px; }
.btn.tiny { padding: 4px 9px; font-size: 11px; box-shadow: 0 2px 0 #8e1426; }
.btn.tiny.ghost { box-shadow: 0 2px 0 #c9c1ad; }
.btn.big { padding: 14px 26px; font-size: 18px; width: 100%; }

/* ---------- title ---------- */
#screen-title { align-items: center; justify-content: center; overflow-y: auto; padding: 16px; }
.title-card { background: var(--card); border-radius: 22px; padding: 18px 26px 24px; width: min(680px, 100%); text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.45); margin: auto; }
#title-art { width: 100%; height: auto; background: linear-gradient(#0d1b3d, #1c3a66); border-radius: 14px; }
.logo { font-size: clamp(44px, 9vw, 76px); margin: 8px 0 0; color: var(--red); letter-spacing: 1px;
  text-shadow: 3px 3px 0 var(--gold), 6px 6px 0 rgba(0,0,0,.12); font-family: Impact, "Arial Black", sans-serif; }
.tagline { font-size: 22px; margin: 0; font-style: italic; color: var(--green); font-weight: 700; }
.flavor { margin: 2px 0 14px; color: var(--muted); font-size: 14px; }
.new-game label { display: block; font-weight: 700; margin-bottom: 6px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; padding: 12px 14px; font-size: 16px; border-radius: 12px; border: 2px solid var(--line); font-family: inherit; }
.row input:focus { outline: none; border-color: var(--green); }
.title-card h3 { margin: 18px 0 8px; }
.save-list { list-style: none; padding: 0; margin: 0 0 14px; text-align: left; max-height: 220px; overflow-y: auto; }
.save-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 6px; background: #fff; }
.save-list li small { display: block; color: var(--muted); }
.save-list li span { display: flex; gap: 6px; }
.save-list li.empty { justify-content: center; color: var(--muted); }

/* ---------- hub ---------- */
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: rgba(0,0,0,.25); color: #fff; flex-wrap: wrap; }
.brand { font-family: Impact, "Arial Black", sans-serif; font-size: 26px; color: var(--gold); letter-spacing: 1px; }
.stat span { display: block; font-size: 11px; text-transform: uppercase; opacity: .7; }
.stat b { font-size: 18px; }
.stat.debt b { color: #ff8a80; }
.spacer { flex: 1; }
.hub { flex: 1; display: grid; grid-template-columns: 340px 1fr; gap: 14px; padding: 14px; min-height: 0; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.3); min-height: 0; }
.tonight { overflow-y: auto; display: flex; flex-direction: column; }
.tonight h3 { margin: 0 0 8px; font-size: 26px; }
.rival { display: flex; gap: 10px; align-items: center; background: #fff3e0; border-radius: 12px; padding: 8px 10px; margin-bottom: 10px; }
.rival .big { font-size: 22px; color: var(--red); }
.rival small { color: var(--muted); }
.facts { list-style: none; padding: 0; margin: 0 0 12px; font-size: 14px; }
.facts li { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.alert { background: #ffebee; color: #b71c1c; border: 1px solid #ffcdd2; border-radius: 10px; padding: 10px; margin-bottom: 10px; font-weight: 700; }
.alert.debt { background: #fff8e1; color: #8a5a00; border-color: #ffe082; font-weight: 400; }
.tonight .btn.big { margin-top: auto; }
.shop { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.tabs { display: flex; gap: 4px; padding: 10px 10px 0; border-bottom: 2px solid var(--line); flex-wrap: wrap; }
.tab { border: 0; background: transparent; padding: 9px 14px; font-weight: 700; font-size: 14px; border-radius: 10px 10px 0 0; cursor: pointer; color: var(--muted); }
.tab.active { background: var(--red); color: #fff; }
.shop-body { overflow-y: auto; padding: 12px 14px 20px; flex: 1; }
.shop-body h4 { margin: 16px 0 6px; }
.pack { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; background: #fff; }
.pack.is-owned { border-color: #a5d6a7; background: #f6fff6; }
.pack-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.pack-head h4 { margin: 0 6px 4px 0; display: inline-block; }
.pack-head p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.pack-btn { flex-shrink: 0; text-align: right; }
.owned { color: var(--green); font-weight: 700; font-size: 13px; margin-right: 6px; }
.badge { display: inline-block; color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-right: 4px; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; margin-top: 8px; }
.item { text-align: center; background: linear-gradient(#162a55, #23406f); color: #fff; border-radius: 10px; padding: 6px 6px 8px; font-size: 12px; }
.item.sold { opacity: .45; }
.item-imgs { position: relative; height: 74px; }
.item-imgs img { height: 74px; max-width: 100%; object-fit: contain; }
.item-imgs img.topv { position: absolute; right: -2px; bottom: -2px; height: 34px; background: rgba(0,0,0,.25); border-radius: 50%; }
.item-name { font-weight: 700; margin-top: 2px; }
.item-meta { opacity: .8; font-size: 11px; margin-bottom: 4px; }
.up { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; background: #fff; }
.up small { display: block; color: var(--muted); }
.muted { color: var(--muted); font-size: 14px; }
table.mini { border-collapse: collapse; width: 100%; font-size: 13px; }
table.mini th, table.mini td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; }

/* ---------- night ---------- */
#screen-night { background: #0a1530; }
.hud { display: flex; gap: 6px; padding: 6px 10px; color: #fff; background: rgba(0,0,0,.35); flex-wrap: wrap; align-items: center; }
.hud-item { background: rgba(255,255,255,.08); border-radius: 10px; padding: 4px 10px; min-width: 80px; }
.hud-item span { display: block; font-size: 10px; text-transform: uppercase; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.hud-item b { font-size: 17px; }
.hud-item.warn b { color: #ff8a80; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .4; } }
.yard-wrap { flex: 1; position: relative; min-height: 0; }
#yard-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: pointer; }
.night-banner { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%) scale(.3); opacity: 0; pointer-events: none;
  font-family: Impact, "Arial Black", sans-serif; font-size: clamp(48px, 11vw, 120px); color: #fff59d; text-shadow: 0 0 30px #ffb300, 4px 4px 0 #b71c1c; transition: all .35s cubic-bezier(.2,1.6,.4,1); white-space: nowrap; }
.night-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.night-banner.lose { color: #b0bec5; text-shadow: 0 0 20px #000, 4px 4px 0 #37474f; }
.porch { background: linear-gradient(#5d4037, #4e342e); color: #fff; padding: 6px 10px 10px; border-top: 4px solid #8d6e63; }
.porch-head { font-size: 13px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sel-info { opacity: .9; margin-left: 10px; }
.sel-info .th { color: var(--gold); }
.porch-row { display: flex; gap: 10px; align-items: center; }
.slots { display: flex; gap: 8px; overflow-x: auto; flex: 1; padding: 2px; }
.slot { flex: 0 0 auto; width: 92px; height: 104px; border-radius: 12px; border: 2px dashed rgba(255,255,255,.25); position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; touch-action: none; }
.slot.full { background: #a1887f; border: 2px solid #d7ccc8; cursor: grab; box-shadow: inset 0 -6px 0 rgba(0,0,0,.15); }
.slot.sel { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(255,207,63,.7); }
.slot.arrive { animation: drop .4s ease-out; }
@keyframes drop { from { transform: translateY(-30px); opacity: 0; } }
.slot canvas { width: 70px; height: 70px; pointer-events: none; }
.slot-label { font-size: 10px; font-weight: 700; text-align: center; line-height: 1.1; padding: 0 3px; pointer-events: none; max-height: 22px; overflow: hidden; }
.slot-val { position: absolute; top: 3px; right: 5px; font-size: 11px; font-weight: 700; background: rgba(0,0,0,.4); border-radius: 6px; padding: 0 4px; pointer-events: none; }
.slot-empty { opacity: .4; font-size: 12px; }
.porch-btns { display: flex; flex-direction: column; gap: 6px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(4,8,22,.7); display: flex; align-items: center; justify-content: center; padding: 14px; z-index: 50; }
.modal-card { background: var(--card); border-radius: 18px; padding: 18px 22px; width: min(760px, 100%); max-height: 100%; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal-card.results { width: min(900px, 100%); }
.modal-card h2 { margin: 0 0 10px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.modal-actions .btn.big { width: auto; }
table.breakdown { width: 100%; border-collapse: collapse; font-size: 15px; }
table.breakdown td { padding: 5px 8px; border-bottom: 1px solid var(--line); }
table.breakdown td:last-child { text-align: right; font-weight: 700; white-space: nowrap; }
table.breakdown tr.plus td:last-child { color: var(--green); }
table.breakdown tr.minus td:last-child { color: var(--red); }
table.breakdown tr.sub td { background: #f3eee2; font-weight: 700; }
table.breakdown tr.info td { color: var(--muted); font-size: 13px; padding-top: 1px; padding-bottom: 1px; border: 0; }
table.breakdown tr.total td { font-size: 20px; font-weight: 800; border-top: 3px double var(--ink); border-bottom: 0; }
details { margin: 10px 0; font-size: 14px; }
summary { cursor: pointer; font-weight: 700; }
.vs { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 10px; border-radius: 14px; margin-bottom: 4px; color: #fff; }
.vs.win { background: linear-gradient(90deg, #1f8a4c, #43a047); }
.vs.lose { background: linear-gradient(90deg, #8e1426, #d7263d); }
.vs div { text-align: center; }
.vs span { display: block; font-size: 12px; text-transform: uppercase; opacity: .85; }
.vs b { font-size: 30px; }
.vs-mid { font-weight: 800; font-size: 18px; opacity: .8; }
.vs-msg { text-align: center; margin: 4px 0 10px; font-weight: 700; }
.wallet { margin: 10px 0 0; }
.neg { color: var(--red); }
.debt-note { background: #fff8e1; padding: 8px 10px; border-radius: 10px; font-size: 14px; }
.share-wrap img { width: 100%; border-radius: 12px; display: block; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.howto { padding-left: 20px; line-height: 1.45; }
.howto li { margin-bottom: 8px; }
.k { display: inline-block; padding: 0 6px; border-radius: 6px; background: #eee; font-weight: 700; }
.k.cyan { background: #d9f7fb; color: #006a79; }
.k.gold { background: #fff3c4; color: #7a5a00; }

.toast { position: fixed; left: 50%; bottom: 140px; transform: translateX(-50%) translateY(20px); background: rgba(10,16,36,.92); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700;
  opacity: 0; transition: all .25s; pointer-events: none; z-index: 60; max-width: 92vw; text-align: center; font-size: 14px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  body { overflow: auto; }
  #screen-hub { position: absolute; min-height: 100%; overflow-y: auto; }
  .hub { display: block; flex: none; }
  .hub > .card { margin-bottom: 14px; }
  .tonight { overflow: visible; }
  .tonight .btn.big { margin-top: 8px; }
  .shop { max-height: none; overflow: visible; }
  .shop-body { overflow: visible; }
  .topbar { gap: 10px; }
  .brand { font-size: 20px; width: 100%; }
}
@media (max-width: 600px) {
  .hud-item { min-width: 0; padding: 3px 7px; }
  .hud-item b { font-size: 14px; }
  .slot { width: 74px; height: 88px; }
  .slot canvas { width: 56px; height: 56px; }
  .porch-btns .btn { padding: 8px 10px; font-size: 13px; }
  .sel-info { display: block; margin: 2px 0 0; white-space: normal; }
  .vs b { font-size: 22px; }
  table.breakdown { font-size: 13px; }
  .row { flex-direction: column; }
}
