:root {
	--bg: #fff4e2;
	--paper: #fffaf1;
	--ink: #1d1a2e;
	--muted: #7b7287;
	--line: #1d1a2e;
	--accent: #ff6b2c;
	--teal: #13a89b;
	--violet: #7a5cff;
	--good: #128a4a;
	--bad: #d62f4b;
	--gold: #f2b705;
	--shadow: 4px 4px 0 var(--line);
	--r: 14px;
	color-scheme: light;
	font-size: clamp(13px, calc(0.55vw + 0.6vh + 2px), 18px);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
	margin: 0;
	background: var(--bg);
	background-image: radial-gradient(circle at 1px 1px, #f1dfc3 1.2px, transparent 0);
	background-size: 22px 22px;
	color: var(--ink);
	font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI Rounded", system-ui, sans-serif;
	line-height: 1.35;
}
#app { min-height: 100vh; }
h1, h2, h3 { margin: 0 0 0.4em; line-height: 1.1; }
h3 { font-size: 1.1rem; }
p { margin: 0.35em 0; }
small { font-size: 0.78em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-top: 0.6rem; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; }
.col { display: flex; flex-direction: column; gap: 0.8rem; align-items: stretch; }

/* Buttons */
.btn {
	font: inherit;
	font-weight: 800;
	border: 2.5px solid var(--line);
	border-radius: 12px;
	padding: 0.55em 1.05em;
	background: var(--paper);
	color: var(--ink);
	box-shadow: 3px 3px 0 var(--line);
	cursor: pointer;
	transition: transform 0.06s, box-shadow 0.06s;
}
.btn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--line); }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
.btn.go { background: var(--accent); color: #fff; }
.btn.sell { background: var(--teal); color: #fff; }
.btn.warn { background: var(--bad); color: #fff; }
.btn.ghost { background: var(--paper); }
.btn.small { padding: 0.35em 0.75em; font-size: 0.9rem; box-shadow: 2px 2px 0 var(--line); }
.btn.big { font-size: 1.35rem; padding: 0.7em 1.6em; border-radius: 16px; box-shadow: var(--shadow); }
.btn.big small { display: block; font-weight: 600; opacity: 0.85; font-size: 0.65em; }
.btn.wide { width: 100%; }
.chip {
	font: inherit; font-size: 0.85rem; font-weight: 700;
	border: 2px solid var(--line); border-radius: 999px; padding: 0.2em 0.8em;
	background: var(--paper); cursor: pointer;
}
.chip.on { background: var(--gold); }
.chip.ghost { border-style: dashed; color: var(--muted); }
.pill { display: inline-block; font-size: 0.7em; font-weight: 800; border: 2px solid var(--line); border-radius: 999px; padding: 0.05em 0.6em; background: var(--gold); vertical-align: middle; margin-left: 0.4em; }
.avatar { display: inline-grid; place-items: center; width: 1.9em; height: 1.9em; border-radius: 50%; background: var(--c); border: 2.5px solid var(--line); font-size: 1em; flex: none; }
.avatar.xl { width: 2.4em; height: 2.4em; font-size: 1.4em; vertical-align: middle; }

/* Title */
.title { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 1.2rem; text-align: center; padding: 2rem; }
.logo { display: flex; gap: 0.15em; font-size: clamp(4rem, 10vw, 9rem); font-weight: 900; letter-spacing: -0.03em; }
.logo span { padding: 0 0.15em; border: 5px solid var(--line); border-radius: 0.18em; box-shadow: 8px 8px 0 var(--line); }
.logo span:first-child { background: var(--accent); color: #fff; transform: rotate(-4deg); }
.logo span:last-child { background: var(--teal); color: #fff; transform: rotate(3deg) translateY(0.08em); }
.tag { font-size: 1.4rem; font-weight: 700; }
.title-goods { font-size: 2.4rem; display: flex; gap: 0.5rem; }
.title-goods span { animation: bob 2.4s ease-in-out infinite; }
.title-goods span:nth-child(odd) { animation-delay: -1.2s; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(6deg); } }
@media (prefers-reduced-motion: reduce) { .title-goods span { animation: none; } }

/* Setup */
.setup { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; display: grid; gap: 1.5rem; }
.setup-head h1 { font-size: 3rem; margin-top: 0.5rem; }
.who-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 1rem; }
.who { border: 3px solid var(--line); border-radius: var(--r); background: var(--paper); box-shadow: var(--shadow); padding: 0.8rem; display: grid; gap: 0.5rem; justify-items: center; }
.who.on { background: color-mix(in srgb, var(--c) 30%, var(--paper)); }
.who-pick { all: unset; cursor: pointer; display: grid; justify-items: center; gap: 0.2rem; width: 100%; padding: 0.4rem 0; }
.who-pick:focus-visible { outline: 3px solid var(--violet); border-radius: 10px; }
.who-emoji { font-size: 3rem; }
.who-name { font-size: 1.3rem; font-weight: 900; }
.who-order { font-weight: 800; font-size: 0.85rem; background: var(--ink); color: #fff; border-radius: 999px; padding: 0.1em 0.7em; }
.who-order.off { background: transparent; color: var(--muted); }
.add-btn { font: inherit; cursor: pointer; border-style: dashed; place-content: center; min-height: 10rem; }
.add { grid-column: span 2; border: 3px dashed var(--line); border-radius: var(--r); padding: 1rem; background: var(--paper); display: grid; gap: 0.7rem; }
.add label { font-weight: 800; display: grid; gap: 0.3rem; }
.add label.check { display: flex; gap: 0.5rem; align-items: center; font-weight: 600; }
.add input[name="name"], .seed input { font: inherit; font-size: 1.2rem; padding: 0.4em 0.6em; border: 2.5px solid var(--line); border-radius: 10px; background: #fff; }
.emoji-row { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.emoji { font-size: 1.6rem; border: 2px solid transparent; background: none; border-radius: 10px; cursor: pointer; padding: 0.1em 0.2em; }
.emoji.on { border-color: var(--line); background: var(--gold); }
.setup-opts { display: flex; flex-wrap: wrap; gap: 1.5rem 2.5rem; align-items: flex-end; }
.opt { display: grid; gap: 0.35rem; }
.opt-label { font-weight: 900; }
.seg { display: inline-flex; border: 2.5px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: 3px 3px 0 var(--line); }
.seg button { font: inherit; font-weight: 800; padding: 0.5em 1em; border: 0; border-right: 2px solid var(--line); background: var(--paper); cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: #fff; }
.seed { display: flex; gap: 0.4rem; }
.seed input { width: 12rem; text-transform: uppercase; }

/* Handoff */
.handoff { min-height: 100vh; display: grid; place-content: center; justify-items: center; text-align: center; gap: 1rem; background: color-mix(in srgb, var(--c) 22%, transparent); padding: 2rem; }
.handoff h1 { font-size: 3rem; }
.day-big { font-size: 1.4rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; }
.mini-board { list-style: none; padding: 0; display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; margin-top: 1.5rem; }
.mini-board li { display: flex; align-items: center; gap: 0.4rem; background: var(--paper); border: 2px solid var(--line); border-radius: 999px; padding: 0.25em 0.9em 0.25em 0.3em; }

/* Game layout */
.game {
	height: 100vh;
	display: grid;
	grid-template-columns: minmax(18rem, 23rem) 1fr minmax(16rem, 21rem);
	grid-template-rows: auto 1fr;
	gap: 0.9rem;
	padding: 0.9rem;
	padding-top: max(0.9rem, env(safe-area-inset-top, 0px));
}
.hud {
	grid-column: 1 / -1;
	display: flex; align-items: center; gap: 0.6rem 1.4rem; flex-wrap: wrap;
	background: var(--paper);
	border: 3px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
	padding: 0.5rem 1rem;
	border-top: 8px solid var(--c);
}
.hud-day { display: grid; line-height: 1; }
.hud-day b { font-size: 1.5rem; }
.hud-day span { color: var(--muted); font-weight: 700; }
.hud-who { display: flex; align-items: center; gap: 0.5rem; font-size: 1.2rem; margin-right: auto; }
.hud-stat { display: grid; line-height: 1.1; }
.hud-stat span { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 800; }
.hud-stat b { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.hud-stat small { font-weight: 800; }
.hud-stat.bad b, .hud-stat.bad small { color: var(--bad); }
.hud-stat.nw b { color: var(--accent); font-size: 1.5rem; }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

.panel { background: var(--paper); border: 3px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 0.9rem 1rem; }
.map-col, .side-col { display: flex; flex-direction: column; gap: 0.9rem; min-height: 0; }
.center { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.tabs button {
	font: inherit; font-weight: 800; font-size: 1.05rem;
	border: 3px solid var(--line); border-bottom: 0; border-radius: 12px 12px 0 0;
	background: #f5e6cc; padding: 0.45em 1em; cursor: pointer;
}
.tabs button.on { background: var(--paper); position: relative; top: 3px; }
.tabs.small button { font-size: 0.9rem; border-bottom: 3px solid var(--line); border-radius: 10px; }
.tabs.small button.on { background: var(--gold); top: 0; }
.tab-body { flex: 1; min-height: 0; overflow: auto; background: var(--paper); border: 3px solid var(--line); border-radius: 0 var(--r) var(--r) var(--r); box-shadow: var(--shadow); padding: 1rem; }

/* Map */
.map-panel { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; min-height: 0; }
.map { position: relative; flex: 1; min-height: 15rem; margin: 0.4rem 0; background: #d9efe0; border: 2.5px solid var(--line); border-radius: 12px; overflow: hidden; }
.map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map .river { fill: none; stroke: #8fcde8; stroke-width: 7; vector-effect: non-scaling-stroke; }
.map .roads line { stroke: var(--line); stroke-width: 2; stroke-dasharray: 4 5; vector-effect: non-scaling-stroke; opacity: 0.45; }
.pin {
	position: absolute; transform: translate(-50%, -50%);
	font: inherit; display: grid; justify-items: center; gap: 0;
	background: var(--paper); border: 2.5px solid var(--line); border-radius: 12px; box-shadow: 2px 2px 0 var(--line);
	padding: 0.2em 0.5em; cursor: pointer; min-width: 5.5rem;
}
.pin:hover { background: #fff; z-index: 2; }
.pin.here { background: var(--c, var(--accent)); color: #fff; z-index: 1; box-shadow: 3px 3px 0 var(--line); }
.pin-icon { font-size: 1.4rem; line-height: 1.1; }
.pin-name { font-weight: 900; font-size: 0.85rem; white-space: nowrap; }
.pin-fare { font-size: 0.72rem; font-weight: 700; opacity: 0.85; }
.pin-others { position: absolute; top: -0.9em; right: -0.6em; font-size: 0.95rem; }

/* News / side */
.news { flex: 1; min-height: 0; overflow: auto; }
.news ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.45rem; }
.news li { display: flex; gap: 0.5rem; font-size: 0.92rem; padding: 0.35rem 0.4rem; border-radius: 8px; }
.news li small { color: var(--muted); font-weight: 800; }
.news li.today { background: #fff0d6; }
.news li.rumor { font-style: italic; }
.n-ico { flex: none; }
.board { list-style: none; padding: 0; margin: 0 0 0.6rem; display: grid; gap: 0.35rem; }
.board li { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0.4rem; border-radius: 10px; }
.board li .nm { flex: 1; font-weight: 700; }
.board li.me { background: #fff0d6; }
.board.big li { font-size: 1.2rem; }
.spark polyline { stroke: var(--muted); }
.spark.up polyline { stroke: var(--good); }
.spark.down polyline { stroke: var(--bad); }
.spark.big { width: 100%; height: auto; }
.nw-chart { margin: 0.2rem 0; }

/* Market */
.mkt { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.mkt th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 0.3rem 0.5rem; border-bottom: 2.5px solid var(--line); }
.mkt td { padding: 0.45rem 0.5rem; border-bottom: 1.5px dashed #e3cfae; vertical-align: middle; }
.mkt td small { display: block; color: var(--muted); font-size: 0.75rem; }
.mkt .num { text-align: right; }
.mkt .item { display: flex; gap: 0.6rem; align-items: center; }
.mkt .item b { font-size: 1.05rem; }
.g-ico { font-size: 1.8rem; }
.ch.up { color: var(--good); font-weight: 800; }
.ch.down { color: var(--bad); font-weight: 800; }
.acts { white-space: nowrap; text-align: right; }
.acts .btn + .btn { margin-left: 0.4rem; }
.table-wrap { overflow-x: auto; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.cards.two { grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); margin-bottom: 1rem; }
.card { border: 2.5px solid var(--line); border-radius: 12px; padding: 0.9rem; background: #fff; box-shadow: 3px 3px 0 var(--line); }
.card.eddie { background: #ffe9e4; }
.card.bank { background: #e6f6ef; }
.card.owned { background: #fff7dc; }
.big-num { font-size: 2rem; font-weight: 900; margin: 0.1em 0; font-variant-numeric: tabular-nums; }
.big-num small { font-size: 0.5em; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 0.8rem; margin: 0.5rem 0; }
.stats dt { font-size: 0.75rem; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.stats dd { margin: 0; font-weight: 900; font-size: 1.1rem; }
.bar { height: 0.8rem; border: 2px solid var(--line); border-radius: 999px; background: #fff; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--teal); }
.bar.big { height: 1.2rem; width: min(24rem, 100%); }
.section { margin: 0.4rem 0 0.7rem; }
.locked { display: grid; justify-items: center; text-align: center; gap: 0.6rem; padding: 3rem 1rem; font-size: 1.2rem; font-weight: 700; }
.lock-ico { font-size: 4rem; filter: grayscale(0.4); }
.cds { padding-left: 1.2rem; }
.cds li { margin: 0.3rem 0; }

/* End */
.end { max-width: 1500px; margin: 0 auto; padding: 1.5rem; display: grid; gap: 1.2rem; }
.end-head h1 { font-size: 3rem; }
.end-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 1.2rem; align-items: start; }
.chart { width: 100%; height: auto; background: #fff; border: 2px solid var(--line); border-radius: 10px; margin-top: 0.5rem; }
.chart .zero { stroke: var(--muted); stroke-dasharray: 3 4; }
.lines { list-style: none; padding: 0; display: grid; gap: 0.5rem; }
.lines li { padding: 0.5rem 0.8rem; border-radius: 10px; border: 2px solid var(--line); background: #fff; font-weight: 600; }
.lines li.good { background: #e6f6ef; color: var(--ink); }
.lines li.bad { background: #ffe9e4; color: var(--ink); }
.ff { border-top: 2.5px dashed var(--line); margin-top: 1rem; padding-top: 1rem; }
.ff-legend { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem 1rem; }
.sw { display: inline-block; width: 1em; height: 0.5em; border-radius: 3px; margin-right: 0.4em; vertical-align: middle; }

/* Modal + toast */
#modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 1rem; }
#modal[hidden] { display: none; }
.scrim { position: absolute; inset: 0; background: rgba(29, 26, 46, 0.45); }
.dialog { position: relative; background: var(--paper); border: 3px solid var(--line); border-radius: 18px; box-shadow: 8px 8px 0 var(--line); padding: 1.4rem 1.6rem; width: min(44rem, 100%); max-height: 90vh; overflow: auto; }
.dialog h2 { font-size: 1.6rem; }
.dialog .sub { color: var(--muted); }
.qty { display: flex; align-items: center; justify-content: center; gap: 0.4rem; flex-wrap: wrap; margin: 1rem 0; }
.qty-num { min-width: 6.5rem; text-align: center; font-size: 2.2rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.quote { font-size: 1.1rem; text-align: center; min-height: 1.5em; }
.quote.warn { color: var(--bad); }
.inbox { list-style: none; padding: 0; display: grid; gap: 0.5rem; }
.inbox li { padding: 0.6rem 0.8rem; border: 2px solid var(--line); border-radius: 10px; background: #fff; }
.inbox li.bad { background: #ffe9e4; }
.inbox li.good, .inbox li.unlock { background: #e6f6ef; }
#toast { position: fixed; left: 50%; bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 200%); background: var(--ink); color: #fff; font-weight: 800; padding: 0.7em 1.3em; border-radius: 12px; box-shadow: 4px 4px 0 var(--accent); transition: transform 0.2s, opacity 0.2s; z-index: 60; pointer-events: none; opacity: 0; }
#toast.show { transform: translate(-50%, 0); opacity: 1; }
#toast.bad { box-shadow: 4px 4px 0 var(--bad); }
#toast.good { box-shadow: 4px 4px 0 var(--good); }

/* Smaller screens (1366×768 and below) */
@media (max-width: 1400px) {
	.game { grid-template-columns: minmax(15rem, 19rem) 1fr minmax(14rem, 17rem); gap: 0.7rem; padding: 0.7rem; }
	.mkt td { padding: 0.35rem 0.4rem; }
}
@media (max-width: 1000px) {
	.game { height: auto; grid-template-columns: 1fr; }
	.map { min-height: 18rem; }
	.end-grid { grid-template-columns: 1fr; }
	.tab-body { overflow-x: auto; }
}
