:root {
  --bg: #0b0b0e; --panel: #131318; --panel2: #1a1a21; --line: #2a2a33; --text: #ececf1; --muted: #8a8a99;
  --amber: #f59e0b; --amber2: #fbbf24; --green: #4a8c4a; --red: #8b3a3a;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, -apple-system, Segoe UI, sans-serif; }
body.thryft-modal-active { overflow: hidden; }
.hold { max-width: 980px; margin: 0 auto; padding: 14px; }
code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; color: var(--amber2); }
a { color: var(--amber2); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.brand { font-weight: 800; font-size: 18px; letter-spacing: .3px; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #b45309, #f59e0b); color: #1a1205; margin-right: 6px; }
.top-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.btn { font: 600 13px Inter, system-ui, sans-serif; color: #1a1205; background: var(--amber); border: 0; border-radius: 8px; padding: 7px 12px; cursor: pointer; transition: background .15s, transform .05s; }
.btn:hover { background: var(--amber2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: #26262e; color: #6a6a78; cursor: default; }
.btn-quiet { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.btn-quiet:hover { background: #24242c; }
.btn-gold { width: 100%; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-head h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }
.tag { font: 11px 'JetBrains Mono', ui-monospace, monospace; color: var(--amber2); background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.25); border-radius: 999px; padding: 2px 8px; }

.resources { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.res { position: relative; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px 12px; display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; column-gap: 6px; transition: border-color .3s; }
.res-icon { grid-row: span 2; align-self: center; display: grid; }
.res-icon .ico { width: 22px; height: 22px; }
.res-name { font-size: 12px; color: var(--muted); }
.res em { font-style: normal; font-size: 11px; color: var(--green); text-align: right; filter: brightness(1.6); }
.res em.idle { color: var(--muted); filter: none; }
.res b { font-size: 20px; font-variant-numeric: tabular-nums; }
.res small { color: var(--muted); font-size: 11px; justify-self: end; }
.res-bar { position: absolute; left: 10px; right: 10px; bottom: 6px; height: 3px; background: #24242c; border-radius: 3px; overflow: hidden; }
.res-bar i { display: block; height: 100%; background: linear-gradient(90deg, #b45309, #f59e0b); transition: width .9s linear; }
.res.res-tick b { color: var(--amber2); }

.cols { display: grid; grid-template-columns: 1.15fr 1fr; gap: 12px; }
.cols > .panel, .side > .panel:last-child { margin-bottom: 0; }
.side { display: flex; flex-direction: column; gap: 12px; }
.side .panel { margin: 0; }

.cards { display: grid; gap: 10px; }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; align-items: center; }
.card-head { display: flex; gap: 10px; align-items: center; grid-column: 1 / -1; cursor: help; }
.card-icon { color: var(--amber2); width: 38px; height: 38px; display: grid; place-items: center; background: #101015; border-radius: 9px; border: 1px solid var(--line); }
.card-title { display: grid; }
.card-title small { color: var(--muted); font-size: 11px; }
.card-sub { font-size: 12px; color: var(--amber2); }
.card-title b { font-size: 14px; }
.costs { display: flex; gap: 10px; flex-wrap: wrap; }
.cost { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); }
.cost svg { width: 22px; height: 22px; }
.cost .cost-text { display: inline-flex; align-items: center; gap: 3px; }
.cost .cost-text .ico { width: 14px; height: 14px; }
.cost .ring-bg { fill: none; stroke: #2a2a3a; stroke-width: 3; }
.cost [data-cost-ring] { transition: stroke-dashoffset .6s ease, stroke .3s; }
.cost.cost-met .cost-text { color: var(--text); }

.ship { display: grid; gap: 8px; text-align: center; }
.ship p { margin: 0; color: var(--muted); }
.ship p b { color: var(--text); }
.ship-art { color: var(--amber2); display: grid; place-items: center; }
.ship-art .ico { width: 34px; height: 34px; }
.ship.sailing .ship-art { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-3deg); } }
.ship .costs { justify-content: center; }
.countdown { color: var(--amber2); font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: #24242c; border-radius: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #b45309, #fbbf24); transition: width .9s linear; }

.inv-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.inv-cell { position: relative; aspect-ratio: 1; background: #101015; border: 1px solid var(--line); border-radius: 8px; display: grid; place-items: center; user-select: none; }
.inv-cell[data-item-key] { cursor: grab; background: var(--panel2); }
.inv-cell[data-item-key]:hover { border-color: rgba(245,158,11,.5); }
.inv-icon { pointer-events: none; display: grid; }
.inv-icon .ico { width: 24px; height: 24px; }
.inv-qty { position: absolute; right: 4px; bottom: 2px; font-size: 11px; font-weight: 700; color: var(--amber2); pointer-events: none; }
.inv-dragging { opacity: .4; }
.inv-dragover { border-color: var(--amber) !important; box-shadow: 0 0 0 2px rgba(245,158,11,.25) inset; }
.hint { margin: 8px 0 0; font-size: 11px; color: var(--muted); }

.saga { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; min-height: 60px; }
.saga li { display: flex; gap: 8px; font-size: 12.5px; animation: in .35s ease; }
.saga time { color: #5d5d6b; font-variant-numeric: tabular-nums; }
.saga li.build span { color: #f3d9a4; }
.saga li.loot span { color: var(--amber2); }
.saga li.sell span { color: #9fe0a0; }
.saga li.warn span { color: #e0a0a0; }
.saga li.sail span { color: #a8c8ff; }
@keyframes in { from { opacity: 0; transform: translateY(-4px); } }

.foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 12px; font-size: 12px; color: var(--muted); }

/* Thryft leaves the look of these to the game */
.tooltip-box { display: none; position: fixed; z-index: 9000; max-width: 240px; background: #1d1d25; border: 1px solid #3a3a46; border-radius: 10px; padding: 9px 11px; box-shadow: 0 10px 30px rgba(0,0,0,.5); pointer-events: none; font-size: 12.5px; }
.tooltip-box b { display: block; margin-bottom: 2px; }
.tooltip-box p { margin: 2px 0 0; color: var(--muted); }
.tooltip-box .tip-gain { color: var(--amber2); }
.thryft-context-menu { background: #1d1d25; border: 1px solid #3a3a46; border-radius: 9px; padding: 4px; min-width: 110px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.thryft-ctx-item { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); font: 600 13px Inter, system-ui, sans-serif; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.thryft-ctx-item:hover { background: rgba(245,158,11,.15); color: var(--amber2); }
.thryft-modal { position: fixed; inset: 0; z-index: 9500;
  /* Embedded in a tall frame, the page says which part is on screen so modals open there */
  top: var(--view-top, 0px); bottom: auto; height: var(--view-h, 100vh); align-items: center; justify-content: center; padding: 16px; }
.thryft-modal-backdrop { position: absolute; inset: 0; background: rgba(5,5,8,.7); backdrop-filter: blur(2px); }
.thryft-modal-content { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; width: min(460px, 100%); max-height: calc(var(--view-h, 100vh) - 32px); overflow: auto; }
.thryft-modal-content h3 { margin: 0 0 4px; }
.muted { color: var(--muted); margin: 0 0 12px; font-size: 13px; }
.ledger table { width: 100%; border-collapse: collapse; }
.ledger td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.ledger td:last-child { text-align: right; font-weight: 700; color: var(--amber2); }
.ledger-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; }
.how dl { margin: 0 0 12px; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; }
.how dt { font-family: 'JetBrains Mono', ui-monospace, monospace; color: var(--amber2); font-size: 12px; }
.how dd { margin: 0; color: #c8c8d2; }

@media (max-width: 720px) {
  .cols { grid-template-columns: 1fr; }
  .resources { grid-template-columns: 1fr; gap: 6px; }
  .inv-grid { grid-template-columns: repeat(6, 1fr); }
  .how dl { grid-template-columns: 1fr; }
}

/* Icons (Lucide, plus a few drawn to match) */
.ico { display: block; flex: none; }
.card-icon .ico { width: 20px; height: 20px; }
.c-timber { color: #8fbf7a; } .c-iron { color: #a9b8c9; } .c-silver { color: #e2e4ea; }
.c-amber { color: #f59e0b; } .c-pelt { color: #e08a4a; } .c-ivory { color: #efe6d2; } .c-ring { color: #d8dce6; }
.c-whetstone { color: #9aa3ad; } .c-rune { color: #c2b394; } .c-glass { color: #7cc7e8; }
