@import url('https://fonts.googleapis.com/css2?family=Fira+Sans+Condensed:wght@400;600;700&family=Kurale&display=swap');

:root {
  color-scheme: dark;
  --ink: #f6e5bd;
  --muted: #b9c7be;
  --sea: #062d34;
  --sea-deep: #03191f;
  --panel: rgba(8, 37, 42, .92);
  --parchment: #dfbf83;
  --gold: #d4a54d;
  --coral: #e05338;
  --line: rgba(229, 197, 130, .28);
  --shadow: 0 24px 70px rgba(0, 0, 0, .42);
  font-family: "Fira Sans Condensed", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(rgba(2, 22, 27, .6), rgba(2, 22, 27, .88)),
    url('/assets/pirate-map-v3.png') center / cover fixed,
    var(--sea-deep);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

.shell { min-height: 100vh; padding: clamp(18px, 4vw, 48px); }
.brand { display: flex; align-items: center; gap: 12px; color: var(--parchment); font-family: Kurale, serif; font-size: 1.15rem; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: #092f35; }
.eyebrow { margin: 0 0 8px; color: var(--gold); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; font-size: .8rem; }
h1, h2, h3 { margin: 0; font-family: Kurale, Georgia, serif; font-weight: 400; }
h1 { max-width: 750px; font-size: clamp(2.65rem, 7vw, 6.2rem); line-height: .92; letter-spacing: -.045em; }
h2 { font-size: clamp(1.7rem, 3vw, 2.65rem); }
p { line-height: 1.55; }

.home { max-width: 1200px; margin: 0 auto; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); gap: clamp(28px, 6vw, 80px); align-items: center; min-height: calc(100vh - 130px); }
.home-copy p:not(.eyebrow) { max-width: 600px; color: var(--muted); font-size: 1.12rem; }
.feature-line { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; }
.feature-line span { padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: #dce3d8; background: rgba(3, 29, 34, .55); }

.panel { border: 1px solid var(--line); border-radius: 22px; background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.create-card { padding: clamp(22px, 4vw, 34px); }
.create-card h2 { margin-bottom: 22px; }
.field { display: grid; gap: 8px; margin: 16px 0; }
.field label { color: #e8d4a8; font-size: .94rem; font-weight: 600; }
.field input, .field select {
  width: 100%; min-height: 46px; padding: 0 13px; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; background: rgba(1, 20, 24, .7); outline: none;
}
.field input:focus, .field select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212,165,77,.13); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn { min-height: 46px; padding: 10px 18px; border: 1px solid transparent; border-radius: 10px; color: #071d20; background: var(--gold); font-weight: 700; transition: transform .15s, filter .15s, background .15s; }
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.btn.secondary { color: var(--ink); border-color: var(--line); background: rgba(255,255,255,.04); }
.btn.danger { color: #fff; background: var(--coral); }
.btn.full { width: 100%; margin-top: 10px; }
.create-note { margin: 12px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.4; }

.ship-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ship-option { position: relative; min-height: 92px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #061f24; overflow: hidden; }
.ship-option:hover { border-color: rgba(212,165,77,.7); }
.ship-option.selected { border-color: var(--gold); box-shadow: inset 0 0 0 2px var(--gold); }
.ship-option.occupied { position: relative; filter: grayscale(.82) brightness(.5); opacity: .62; cursor: not-allowed; }
.ship-option.occupied .ship-sprite { opacity: .55; }
.occupied-badge { position: absolute; inset: 50% auto auto 50%; padding: 3px 8px; color: #ffe4d4; border: 1px solid rgba(255,205,182,.65); border-radius: 999px; background: rgba(91,28,22,.92); font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; transform: translate(-50%,-50%) rotate(-7deg); }
.ship-sprite { display: block; width: 100%; aspect-ratio: 1.5; background-image: url('/assets/ships.png'); background-size: 300% 200%; background-repeat: no-repeat; border-radius: 8px; }
.ship-option small { display: block; padding: 3px 2px 5px; color: #d8c59b; text-align: center; }
.ship-black { background-position: 0 0; }
.ship-crimson { background-position: 50% 0; }
.ship-blue { background-position: 100% 0; }
.ship-emerald { background-position: 0 100%; }
.ship-ivory { background-position: 50% 100%; }
.ship-violet { background-position: 100% 100%; }

.room-shell { max-width: 1180px; margin: 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 28px; }
.home-top { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.topbar-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 14px; }
.room-code { color: var(--muted); text-align: right; }
.room-code strong { display: block; color: var(--gold); letter-spacing: .12em; font-size: 1.15rem; }
.btn.compact { min-height: 38px; padding: 7px 13px; }
.trade-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 7px; padding: 0 5px; color: #08252a; border-radius: 999px; background: var(--gold); font-size: .75rem; }
.lobby-grid { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 24px; }
.captains { padding: 26px; }
.captains-head { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 20px; }
.captains-head span { color: var(--muted); }
.player-list { display: grid; gap: 10px; }
.player-card { display: grid; grid-template-columns: 84px 1fr auto; gap: 14px; align-items: center; min-height: 88px; padding: 8px 14px 8px 8px; border: 1px solid var(--line); border-radius: 14px; background: rgba(0,0,0,.15); }
.player-ship { width: 84px; height: 60px; }
.player-card h3 { font-family: inherit; font-size: 1.1rem; font-weight: 700; }
.player-card p { margin: 4px 0 0; color: var(--muted); font-size: .87rem; }
.player-card-actions { display: grid; justify-items: end; gap: 6px; }
.remove-bot, .add-bot { min-height: 30px; padding: 4px 9px; color: #f1d28f; border: 1px solid rgba(222,185,107,.35); border-radius: 8px; background: rgba(255,255,255,.04); font-weight: 700; }
.remove-bot { color: #e8aaa0; border-color: rgba(210,105,88,.35); }
.remove-bot:hover, .add-bot:hover { border-color: currentColor; background: rgba(255,255,255,.09); }
.status { padding: 5px 9px; border-radius: 999px; border: 1px solid var(--line); color: #d2d9d1; font-size: .8rem; }
.status.ready { color: #9fe1ae; border-color: rgba(80,180,100,.4); background: rgba(40,120,60,.16); }
.status.offline { color: #dda69b; }
.waiting-slot { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border: 1px dashed var(--line); border-radius: 14px; color: #829a92; }
.waiting-slot small { margin-left: auto; }
.lobby-actions { padding: 25px; height: max-content; }
.lobby-actions h2 { margin-bottom: 14px; }
.lobby-actions p { color: var(--muted); }
.share-box { display: flex; gap: 8px; margin: 18px 0; }
.share-box input { width: 100%; min-width: 0; padding: 0 11px; color: #c8d5ce; border: 1px solid var(--line); border-radius: 9px; background: #041b20; }
.hint { min-height: 42px; color: #dcc693; font-size: .9rem; }

.join-card { max-width: 500px; margin: 9vh auto 0; padding: 28px; }
.join-card .brand { margin-bottom: 28px; }
.join-card h1 { font-size: clamp(2.2rem, 7vw, 4rem); }

.game-shell { max-width: 1800px; margin: 0 auto; }
.game-layout { display: grid; grid-template-columns: 300px minmax(900px, 1fr) 300px; gap: 18px; align-items: start; }
.board-wrap { position: relative; aspect-ratio: 1; min-width: 0; padding: 14px; border: 1px solid rgba(232,203,145,.4); border-radius: 24px; background: rgba(3,25,30,.85); box-shadow: var(--shadow); }
.board { position: relative; width: 100%; height: 100%; overflow: visible; border: 3px solid #3a2516; border-radius: 12px; background: linear-gradient(rgba(226,190,121,.01), rgba(10,29,31,.06)), url('/assets/pirate-map-v3.png') center / cover; box-shadow: inset 0 0 65px rgba(2,18,21,.42); }
.sea-route { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 2px 1px rgba(37,20,9,.7)); pointer-events: none; }
.sea-route polyline { fill: none; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.sea-route .route-shadow { stroke: rgba(16,31,29,.68); stroke-width: 7; }
.sea-route .route-dashes { stroke: #f1c86f; stroke-width: 3.5; stroke-dasharray: 2 9; }
.tile { position: absolute; z-index: 2; display: grid; place-items: center; width: clamp(48px, 4.25vw, 58px); height: clamp(48px, 4.25vw, 58px); min-height: 0; padding: 3px; border: 3px solid rgba(77,43,20,.88); border-radius: 50%; color: #2b1a10; background: rgba(238,207,145,.97); text-align: center; line-height: 1; overflow: visible; transform: translate(-50%,-50%); box-shadow: 0 3px 9px rgba(13,25,22,.62), inset 0 0 0 2px rgba(255,239,195,.38); transition: transform .15s, filter .15s, box-shadow .15s; }
.tile.port, .tile.route, .tile.utility { padding: 3px; border: 5px solid var(--owner, #5b4631); box-shadow: 0 0 0 2px rgba(15,25,24,.82), 0 3px 9px rgba(13,25,22,.62), inset 0 0 0 2px rgba(255,239,195,.25); }
.tile:hover, .tile:focus-visible { z-index: 8; filter: brightness(1.08); transform: translate(-50%,-50%) scale(1.08); box-shadow: 0 6px 15px rgba(41,22,10,.55); outline: 2px solid rgba(255,232,174,.85); outline-offset: 2px; }
.tile.has-token { z-index: 5; }
.tile.tile-highlight { z-index: 19; animation: radial-tile-pulse .72s ease-out; }
.tile-name { max-width: 100%; max-height: 100%; overflow: hidden; }
.tile.corner { width: clamp(58px, 5.3vw, 72px); height: clamp(58px, 5.3vw, 72px); font-family: "Fira Sans Condensed", system-ui, sans-serif; background: rgba(213,168,91,.98); box-shadow: inset 0 0 0 3px rgba(80,42,19,.2), 0 4px 12px rgba(10,24,22,.58); }
.tile.event { background: rgba(225,175,91,.95); }
.tile.port { background: color-mix(in srgb, var(--group) 76%, #d9bd83); }
.tile.route { color: #f5e5bb; background: radial-gradient(circle at 35% 30%, #62757a, #25383d 72%); }
.tile.route .tile-icon, .tile.route .tile-price { color: #fff0bd; }
.tile.utility { background: radial-gradient(circle at 35% 30%, #f0d989, #a88c34 75%); }
.tile.tax { background: rgba(206,119,79,.94); }
.tile.rest { background: rgba(119,175,159,.94); }
.tile.jail { background: rgba(154,139,118,.98); }
.tile.goto-jail { color: #f8e7bd; background: rgba(123,49,42,.97); }
.tile-icon { display: block; color: #38200f; font-size: 1.25rem; font-weight: 800; }
.tile-price { display: block; margin-top: -1px; font-size: .55rem; font-weight: 700; opacity: .78; }
.tile.port .tile-icon { color: #fff3cf; text-shadow: -1px -1px 0 rgba(24,20,15,.9), 1px -1px 0 rgba(24,20,15,.9), -1px 1px 0 rgba(24,20,15,.9), 1px 1px 0 rgba(24,20,15,.9), 0 2px 4px rgba(0,0,0,.65); }
.tile.port .tile-price { padding: 2px 4px; color: #fff5d8; border-radius: 99px; background: rgba(4,24,27,.7); box-shadow: 0 1px 3px rgba(0,0,0,.38); font-weight: 800; opacity: 1; }
.tile-number { position: absolute; z-index: 5; top: -7px; left: -7px; display: grid; place-items: center; width: 20px; height: 20px; color: #f6e5bd; border: 1px solid rgba(255,232,174,.7); border-radius: 50%; background: #173e40; font-size: .66rem; font-weight: 700; box-shadow: 0 2px 4px rgba(0,0,0,.5); }
.tile-label { position: absolute; z-index: 11; width: 94px; padding: 3px 5px; color: #fff1c9; border: 1px solid rgba(235,202,133,.32); border-radius: 6px; background: rgba(3,30,34,.9); box-shadow: 0 2px 7px rgba(0,0,0,.42); font-size: clamp(.52rem, .53vw, .62rem); font-weight: 700; line-height: 1.12; overflow-wrap: anywhere; pointer-events: none; }
.tile-label.label-up { left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); }
.tile-label.label-up.far { bottom: calc(100% + 24px); }
.tile-label.label-down { left: 50%; top: calc(100% + 6px); transform: translateX(-50%); }
.tile-label.label-down.far { top: calc(100% + 24px); }
.tile-label.label-left { right: calc(100% + 6px); top: 50%; transform: translateY(-50%); }
.tile-label.label-left.far { right: calc(100% + 24px); }
.tile-label.label-right { left: calc(100% + 6px); top: 50%; transform: translateY(-50%); }
.tile-label.label-right.far { left: calc(100% + 24px); }
.corner-label { display: grid; place-items: center; gap: 1px; width: 100%; line-height: 1; }
.corner-label b { font-size: clamp(1rem, 1.2vw, 1.35rem); }
.corner-label strong { max-width: 54px; font-size: clamp(.5rem, .58vw, .67rem); letter-spacing: .04em; }
.tokens { position: absolute; inset: auto -10px -13px; z-index: 6; display: flex; flex-wrap: wrap; justify-content: center; min-height: 40px; pointer-events: none; }
.houses { position: absolute; z-index: 4; left: 5px; right: 5px; bottom: 3px; display: flex; justify-content: center; gap: 2px; pointer-events: none; }
.houses i { width: 9px; height: 7px; border: 1px solid #fff0c2; border-radius: 2px 2px 1px 1px; background: #8f2f26; box-shadow: 0 0 0 1px rgba(36,15,12,.78), 0 1px 3px rgba(0,0,0,.55); }
.token { width: clamp(44px, 4.2vw, 62px); height: clamp(32px, 3.1vw, 46px); margin: -9px; border: 0; border-radius: 0; box-shadow: none; filter: saturate(1.2) drop-shadow(1px 0 0 #fff0c2) drop-shadow(-1px 0 0 #fff0c2) drop-shadow(0 1px 0 #fff0c2) drop-shadow(0 -1px 0 #fff0c2) drop-shadow(0 3px 2px rgba(0,13,16,.95)); }
.token.player-highlight { z-index: 19; animation: radial-player-pulse .72s ease-out; }
.tile.owner-business-highlight { z-index: 18; animation: owner-business-pulse .82s ease-in-out infinite alternate; }
.token-hidden { visibility: hidden; }
.moving-token { position: absolute; z-index: 20; margin: 0; pointer-events: none; will-change: left, top, opacity, transform; }
.moving-token.is-sailing { transition: left 55ms linear, top 55ms linear, opacity 120ms ease, transform 120ms ease; }
.moving-token.is-captured { opacity: 0; transform: scale(.55) rotate(-8deg); }
.moving-token.has-arrived { transform: translateY(-5px) scale(1.08); filter: saturate(1.3) drop-shadow(1px 0 0 #fff0c2) drop-shadow(-1px 0 0 #fff0c2) drop-shadow(0 1px 0 #fff0c2) drop-shadow(0 -1px 0 #fff0c2) drop-shadow(0 7px 5px rgba(0,0,0,.65)); }
.map-turn { position: absolute; z-index: 12; left: 50%; top: 50%; display: grid; place-items: center; color: #f7e4b6; transform: translate(-50%,-50%); pointer-events: none; }
.map-turn > small { margin-bottom: 7px; color: #f0c56c; font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; text-shadow: 0 2px 5px rgba(0,0,0,.8); }
.map-turn > strong { width: 260px; height: 48px; display: grid; place-items: center; padding: 0 14px; overflow: hidden; color: #fff0c6; border: 1px solid rgba(239,204,130,.65); border-radius: 12px; background: rgba(4,32,36,.9); box-shadow: 0 8px 24px rgba(0,0,0,.35); font-family: Kurale, serif; font-size: 1.35rem; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.map-dice { display: flex; gap: 12px; margin-top: 12px; }
.map-die { width: 58px; height: 58px; display: grid; place-items: center; color: #2c1d12; border: 0; border-radius: 12px; background: var(--parchment); box-shadow: inset 0 -6px rgba(80,45,18,.18), 0 7px 16px rgba(0,0,0,.34); font-style: normal; font-size: 1.8rem; font-weight: 800; transition: transform .15s, color .15s; }
.turn-timer { min-width: 112px; display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 10px; color: #f7e4b6; font-size: 1.05rem; font-weight: 800; letter-spacing: .08em; text-shadow: 0 2px 5px rgba(0,0,0,.8); }
.turn-timer.warning { color: #ffb283; animation: timer-warning 1s ease-in-out infinite; }
.turn-timer button { width: 27px; height: 27px; padding: 0; color: #173b3c; border: 1px solid #fff0bd; border-radius: 50%; background: #f0ca76; box-shadow: 0 3px 8px rgba(0,0,0,.35); font: inherit; line-height: 1; cursor: pointer; pointer-events: auto; }
.turn-timer button[hidden] { display: none; }
@keyframes timer-warning { 50% { transform: scale(1.05); } }
.map-turn.is-rolling .map-die { animation: dice-rattle .13s linear infinite; }
.map-turn.is-result .map-die { color: #743b20; transform: scale(1.1); }
.map-turn.has-winner > strong { color: #fff1ad; border-color: #f2cb6d; box-shadow: 0 0 0 3px rgba(242,203,109,.16), 0 8px 28px rgba(0,0,0,.48); }
.map-debt { margin: 8px 0 2px; padding: 5px 10px; color: #fff0d5; border: 1px solid rgba(234,105,77,.8); border-radius: 999px; background: rgba(112,35,29,.92); box-shadow: 0 3px 12px rgba(0,0,0,.35); font-size: .72rem; font-weight: 800; }
.map-paused { margin: 8px 0 2px; padding: 6px 12px; color: #173b3c; border: 1px solid #f4d489; border-radius: 999px; background: #eac873; box-shadow: 0 3px 12px rgba(0,0,0,.35); font-size: .72rem; font-weight: 900; letter-spacing: .03em; }
.map-turn.is-covered { visibility: hidden; opacity: 0; }
@keyframes dice-rattle { 50% { transform: rotate(5deg) scale(.94); } }
@keyframes radial-tile-pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,222,126,.9), 0 3px 9px rgba(13,25,22,.62); }
  70% { box-shadow: 0 0 0 19px rgba(255,222,126,0), 0 3px 9px rgba(13,25,22,.62); }
  100% { box-shadow: 0 3px 9px rgba(13,25,22,.62); }
}
@keyframes radial-player-pulse {
  0% { filter: saturate(1.2) drop-shadow(0 0 2px rgba(105,225,239,.95)) drop-shadow(0 3px 2px rgba(0,13,16,.95)); transform: scale(1); }
  65% { filter: saturate(1.35) drop-shadow(0 0 11px rgba(105,225,239,.9)) drop-shadow(0 4px 3px rgba(0,13,16,.95)); transform: scale(1.13); }
  100% { filter: saturate(1.2) drop-shadow(1px 0 0 #fff0c2) drop-shadow(-1px 0 0 #fff0c2) drop-shadow(0 1px 0 #fff0c2) drop-shadow(0 -1px 0 #fff0c2) drop-shadow(0 3px 2px rgba(0,13,16,.95)); transform: scale(1); }
}
@keyframes owner-business-pulse {
  from { box-shadow: 0 0 0 2px var(--owner, #ffe08a), 0 3px 9px rgba(13,25,22,.62); transform: translate(-50%,-50%) scale(1); }
  to { box-shadow: 0 0 0 7px color-mix(in srgb, var(--owner, #ffe08a) 58%, transparent), 0 0 19px var(--owner, #ffe08a); transform: translate(-50%,-50%) scale(1.1); }
}
.game-panel { display: grid; gap: 14px; }
.turn-card, .roster, .log, .chat { padding: 18px; }
.turn-card h2 { font-size: 1.5rem; }
.turn-card p { margin: 6px 0 15px; color: var(--muted); }
.winner-card { border-color: rgba(242,203,109,.6); background: linear-gradient(145deg, rgba(115,73,20,.3), rgba(5,34,38,.94)); }
.winner-card h2 { color: #fff1ad; }
.personal-roll { padding-top: 11px; border-top: 1px solid var(--line); }
.personal-roll > small { color: #e8c779; font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.personal-roll .dice { margin: 9px 0 16px; }
.dice { display: flex; gap: 8px; margin: 16px 0; }
.die { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 10px; color: #2c1d12; background: var(--parchment); box-shadow: inset 0 -5px rgba(80,45,18,.18); font-size: 1.5rem; font-weight: 700; }
.purchase { padding-top: 12px; border-top: 1px solid var(--line); }
.purchase-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.turn-actions, .jail-actions { display: grid; gap: 8px; }
.turn-actions .btn.full, .jail-actions .btn.full { margin-top: 0; }
.debt-card { display: grid; gap: 8px; padding: 12px; border: 1px solid rgba(222,91,67,.62); border-radius: 11px; background: rgba(108,35,29,.24); }
.debt-card > strong { color: #ffb397; font-family: Kurale, serif; font-size: 1.15rem; }
.debt-card p { margin: 0 0 4px; }
.debt-card .btn.full { margin-top: 0; }
.roster-list { display: grid; gap: 7px; margin-top: 12px; }
.roster-row { width: 100%; display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; padding: 5px 6px; color: var(--ink); border: 0; border-radius: 7px; background: transparent; font: inherit; font-size: .94rem; text-align: left; }
.roster-row:hover, .roster-row:focus-visible { background: rgba(239,198,109,.11); outline: 1px solid rgba(239,198,109,.28); }
.roster-row.bankrupt { opacity: .55; }
.roster-row.bankrupt strong { color: #c58f82; font-size: .72rem; text-transform: uppercase; }
.color-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dot); }
.log ol { max-height: 230px; margin: 12px 0 0; padding-left: 20px; overflow: auto; color: var(--muted); }
.log li { margin-bottom: 6px; }
.my-businesses { padding: 16px; }
.my-businesses > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.my-businesses > header span { min-width: 25px; padding: 2px 7px; color: #f2d28a; border: 1px solid var(--line); border-radius: 99px; text-align: center; font-size: .75rem; }
.my-businesses > div { display: grid; gap: 6px; max-height: 220px; margin-top: 10px; overflow-y: auto; }
.my-businesses > div > button { width: 100%; display: grid; grid-template-columns: 7px 1fr auto; gap: 8px; align-items: center; padding: 7px; color: var(--ink); border: 1px solid rgba(230,198,132,.15); border-radius: 8px; background: rgba(255,255,255,.035); text-align: left; }
.my-businesses > div > button:hover { border-color: var(--group); background: rgba(239,198,109,.1); }
.my-businesses > div > button > i { width: 7px; height: 100%; min-height: 30px; border-radius: 5px; background: var(--group); }
.my-businesses > div > button > span { display: grid; min-width: 0; font-size: .8rem; }
.my-businesses > div > button small { overflow: hidden; color: var(--muted); font-size: .62rem; text-overflow: ellipsis; white-space: nowrap; }
.my-businesses > div > button strong { color: #f0cf82; font-size: .72rem; }
.my-businesses > div > p { margin: 0; color: var(--muted); font-size: .8rem; }
.chat { display: grid; gap: 12px; min-height: 340px; }
.chat > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chat > header .eyebrow { margin-bottom: 2px; }
.chat-count { min-width: 28px; padding: 3px 7px; color: #f2d28a; border: 1px solid var(--line); border-radius: 99px; text-align: center; font-size: .78rem; }
.chat-feed { display: flex; flex-direction: column; gap: 9px; height: 310px; padding-right: 4px; overflow-y: auto; overscroll-behavior: contain; }
.chat-empty { margin: auto 0; color: var(--muted); line-height: 1.4; text-align: center; }
.chat-message { align-self: flex-start; width: min(92%, 310px); padding: 9px 11px; border: 1px solid rgba(222,193,132,.2); border-radius: 4px 13px 13px 13px; background: rgba(255,255,255,.045); }
.chat-message.mine { align-self: flex-end; border-radius: 13px 4px 13px 13px; background: rgba(190,137,50,.15); }
.chat-message.bot { border-color: rgba(224,166,70,.42); background: rgba(89,55,20,.28); }
.chat-message header { display: flex; align-items: center; gap: 7px; color: #f2d28a; font-size: .78rem; }
.chat-author { padding: 0; color: inherit; border: 0; background: transparent; font: inherit; font-weight: 700; }
.chat-author:hover, .chat-author:focus-visible { color: #fff0bd; text-decoration: underline; }
.chat-message header span { padding: 1px 5px; border: 1px solid rgba(224,166,70,.35); border-radius: 99px; color: var(--muted); font-size: .68rem; text-transform: uppercase; }
.chat-message p { margin: 4px 0 0; color: var(--ink); font-size: .88rem; line-height: 1.35; overflow-wrap: anywhere; }
.chat-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.chat-input-wrap { position: relative; min-width: 0; }
.chat-form input { min-width: 0; height: 40px; padding: 0 10px; color: var(--ink); border: 1px solid var(--line); border-radius: 9px; background: rgba(2,21,25,.75); }
.chat-input-wrap input { width: 100%; }
.chat-form .btn { min-height: 40px; }
.mention-menu { position: absolute; z-index: 80; left: 0; right: 0; bottom: calc(100% + 7px); max-height: 290px; padding: 5px; overflow-y: auto; border: 1px solid rgba(234,200,129,.58); border-radius: 11px; background: #061f24; box-shadow: 0 14px 38px rgba(0,0,0,.62); }
.mention-menu[hidden] { display: none; }
.mention-option { width: 100%; display: grid; grid-template-columns: 24px 1fr; gap: 7px; align-items: center; padding: 7px; color: var(--ink); border: 0; border-radius: 7px; background: transparent; text-align: left; }
.mention-option:hover, .mention-option.active { background: rgba(222,177,81,.17); }
.mention-option > i { width: 8px; height: 30px; justify-self: center; border-radius: 4px; background: var(--group); }
.mention-icon { color: var(--gold); text-align: center; }
.mention-option > span:last-child { min-width: 0; display: grid; }
.mention-option strong { overflow: hidden; font-size: .86rem; text-overflow: ellipsis; white-space: nowrap; }
.mention-option small { overflow: hidden; color: var(--muted); font-size: .69rem; text-overflow: ellipsis; white-space: nowrap; }
.entity-link { display: inline; margin: 0; padding: 0; color: #f0cf82; border: 0; border-bottom: 1px dashed currentColor; background: transparent; font: inherit; line-height: inherit; }
.entity-link:hover, .entity-link:focus-visible { color: #fff0bd; border-bottom-style: solid; outline: 0; }
.captain-danger, .captain-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding-top: 12px; border-top: 1px solid rgba(197,93,72,.35); }
.business-owner-actions { display: flex; align-items: center; gap: 6px; }
.business-owner-actions button { margin: 0; padding: 0; color: #f0cf82; border: 0; border-bottom: 1px dashed currentColor; background: transparent; font: inherit; font-weight: 700; text-align: left; }
.business-owner-actions .mini-trade { width: 25px; height: 25px; display: grid; place-items: center; color: #173b3c; border: 1px solid #f0cf82; border-radius: 50%; background: #e5be68; line-height: 1; }
.spectator-badge { padding: 7px 10px; color: #f0cf82; border: 1px solid rgba(240,207,130,.38); border-radius: 99px; background: rgba(5,33,37,.76); font-size: .78rem; font-weight: 700; }
.spectator-card, .spectator-note { color: var(--muted); line-height: 1.4; }
.spectator-card { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.035); }
.spectator-card.pause-card { color: #f4d489; border-color: rgba(234,200,115,.55); background: rgba(234,200,115,.08); }
.pause-button { min-width: 112px; }
.spectator-note { margin: 0; font-size: .8rem; text-align: center; }
.help-dialog { width: min(900px, calc(100vw - 28px)); max-height: min(760px, calc(100vh - 28px)); padding: 0; color: var(--ink); border: 1px solid var(--line); border-radius: 20px; background: #08272c; box-shadow: 0 28px 90px rgba(0,0,0,.7); }
.tile-dialog { width: min(460px, 52%); }
.tile-card { padding: 18px 20px 20px; }
.tile-card > header { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-top: 13px; }
.tile-card > header::before { content: ''; position: absolute; inset: 0 56px auto 0; height: 6px; border-radius: 99px; background: var(--group); }
.tile-description { margin: 10px 0 12px; color: var(--muted); font-size: .9rem; line-height: 1.35; }
.business-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.business-stats.single { grid-template-columns: 1fr; }
.business-stats > div { display: grid; gap: 3px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 11px; background: rgba(0,0,0,.13); }
.business-stats small, .development small { color: var(--muted); }
.development { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; align-items: center; margin: 11px 0; padding: 10px; border: 1px solid var(--line); border-radius: 11px; }
.development > small { grid-column: 1 / -1; }
.house-meter { display: flex; gap: 5px; }
.house-meter i { width: 21px; height: 17px; border: 1px solid rgba(255,255,255,.15); border-radius: 4px 4px 2px 2px; background: rgba(255,255,255,.05); }
.house-meter i.built { border-color: #fff0c2; background: #8f2f26; box-shadow: 0 0 0 1px rgba(36,15,12,.78), 0 0 10px rgba(255,202,117,.25); }
.tile-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.tile-actions .btn { flex: 1 1 150px; }
.trade-dialog { width: min(470px, 54%); }
.board > .tile-dialog, .board > .trade-dialog, .board > .player-dialog, .board > .test-dialog { position: absolute; z-index: 30; inset: auto; left: 50%; top: 50%; max-height: 54%; margin: 0; padding: 0; overflow: auto; color: var(--ink); border: 1px solid rgba(230,198,132,.76); border-radius: 16px; background: rgba(4,31,35,.9); box-shadow: 0 16px 42px rgba(0,0,0,.58); transform: translate(-50%,-50%); }
.board > .tile-dialog::backdrop, .board > .trade-dialog::backdrop, .board > .player-dialog::backdrop, .board > .test-dialog::backdrop { background: transparent; backdrop-filter: none; }
.player-dialog { width: min(470px, 54%); }
.test-dialog { width: min(660px, 72%); }
.test-card { padding: 18px 20px 20px; }
.test-card > header { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.test-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.test-grid form { display: grid; align-content: start; gap: 8px; padding: 12px; border: 1px solid rgba(230,198,132,.2); border-radius: 11px; background: rgba(255,255,255,.035); }
.test-grid h3 { margin: 0; color: var(--parchment); font-family: inherit; font-size: .95rem; }
.test-grid label { display: grid; gap: 4px; color: var(--muted); font-size: .72rem; }
.test-grid input, .test-grid select { width: 100%; min-width: 0; height: 35px; padding: 0 8px; color: var(--ink); border: 1px solid var(--line); border-radius: 7px; background: #08272c; }
.test-dice, .test-actions { display: flex; gap: 8px; }
.test-dice > label { flex: 1; }
.test-target { grid-column: 1 / -1; }
.test-target p { margin: 0; color: var(--muted); font-size: .75rem; line-height: 1.35; }
.test-menu-button { opacity: .72; }
.player-details { padding: 18px 20px 20px; }
.player-details > header { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 12px; }
.player-details h3 { margin: 15px 0 8px; color: var(--parchment); font-family: inherit; font-size: 1rem; }
.captain-summary { display: grid; grid-template-columns: 95px 1fr; gap: 13px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 13px; background: rgba(0,0,0,.14); }
.captain-summary .player-ship { width: 95px; height: 66px; }
.captain-summary > div { display: grid; gap: 2px; }
.captain-summary small, .captain-summary span, .captain-businesses small { color: var(--muted); }
.captain-summary strong { color: #f3d58e; font-size: 1.35rem; }
.captain-businesses { display: grid; gap: 5px; max-height: 165px; overflow-y: auto; }
.captain-businesses > button { width: 100%; display: grid; grid-template-columns: 8px minmax(0,1fr) auto; gap: 8px; align-items: center; padding: 7px 8px; color: var(--ink); border: 1px solid rgba(232,203,145,.15); border-radius: 8px; background: rgba(255,255,255,.035); text-align: left; }
.captain-businesses > button:hover, .captain-businesses > button:focus-visible { border-color: rgba(232,203,145,.5); background: rgba(232,203,145,.1); }
.captain-businesses i { width: 8px; height: 34px; border-radius: 4px; background: var(--group); }
.captain-businesses span { min-width: 0; display: grid; }
.captain-businesses small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.captain-businesses p { margin: 0; color: var(--muted); }
.captain-journal { max-height: 125px; margin: 0; padding-left: 20px; overflow-y: auto; color: var(--muted); }
.captain-journal li { margin-bottom: 5px; }
.trade-card { padding: 18px 20px 20px; }
.trade-card > header { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.trade-layout { display: grid; grid-template-columns: 1fr; gap: 14px; }
.trade-layout h3 { margin-bottom: 12px; color: var(--parchment); font-family: inherit; font-weight: 700; }
.trade-list { display: grid; gap: 8px; max-height: 120px; overflow: auto; }
.trade-offer { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(0,0,0,.14); }
.trade-offer > header { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.trade-offer > header strong { color: var(--ink); }
.trade-sides { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.trade-sides p { margin: 12px 0; color: var(--ink); }
.trade-holding { display: inline; color: #f0cf82; border-bottom: 1px dashed currentColor; cursor: default; }
.trade-holding:hover, .trade-holding:focus-visible { color: #fff4c9; border-bottom-style: solid; outline: 0; }
.trade-sides small { display: block; margin-bottom: 3px; color: var(--muted); }
.trade-sides > span, .trade-arrow { color: var(--gold); font-size: 1.35rem; }
.trade-actions { display: flex; gap: 8px; }
.trade-actions .btn { min-height: 38px; padding: 7px 12px; }
.empty-trades, .trade-port-list p, .trade-note { color: var(--muted); }
.new-trade select, .new-trade input { width: 100%; min-height: 42px; margin-top: 6px; padding: 0 10px; color: var(--ink); border: 1px solid var(--line); border-radius: 9px; background: #041b20; }
.new-trade > form > label { display: grid; color: #e8d4a8; font-weight: 600; }
.trade-builder { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin-top: 10px; }
.trade-builder fieldset { min-width: 0; min-height: 160px; padding: 9px; border: 1px solid var(--line); border-radius: 12px; }
.trade-builder legend { padding: 0 5px; color: var(--parchment); font-weight: 700; }
.trade-builder fieldset > label { display: grid; margin-top: 12px; color: var(--muted); }
.trade-port-list { display: grid; gap: 4px; max-height: 105px; overflow: auto; }
.trade-port-list label { display: grid; grid-template-columns: 18px 7px 1fr; gap: 6px; align-items: center; padding: 5px; border-radius: 7px; color: var(--ink); background: rgba(255,255,255,.035); }
.trade-port-list label:hover, .trade-port-list label:focus-within, .trade-port-list label:focus-visible { color: #fff4c9; background: rgba(239,198,109,.13); outline: 1px solid rgba(239,198,109,.32); }
.trade-port-list input { width: 16px; min-height: 16px; margin: 0; }
.trade-port-list i { width: 7px; height: 24px; border-radius: 3px; background: var(--group); }
.trade-note { margin: 10px 0 0; font-size: .88rem; }
.help-dialog::backdrop { background: rgba(0,15,18,.78); backdrop-filter: blur(5px); }
.help-card { padding: clamp(20px, 4vw, 34px); }
.help-card > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.help-card h3 { margin-bottom: 12px; color: var(--parchment); font-family: inherit; font-size: 1.05rem; font-weight: 700; }
.icon-btn { width: 40px; height: 40px; flex: 0 0 auto; color: var(--ink); border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.04); font-size: 1.6rem; line-height: 1; }
.tile-card > header, .trade-card > header, .player-details > header, .test-card > header, .help-card > header { position: sticky; z-index: 45; top: 0; background: #08272c; box-shadow: 0 9px 12px -12px rgba(0,0,0,.9); }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.monopoly-help, .turn-help { grid-column: 1 / -1; padding-top: 20px; border-top: 1px solid var(--line); }
.monopoly-help > p { margin: -4px 0 14px; color: var(--muted); }
.group-legend { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 22px; }
.group-legend > div { display: grid; grid-template-columns: 12px 1fr; gap: 9px; align-items: start; }
.group-legend i { width: 12px; height: 100%; min-height: 38px; border-radius: 4px; background: var(--group); box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.group-legend span { display: grid; gap: 2px; }
.group-legend strong { color: var(--ink); }
.group-legend small { color: var(--muted); line-height: 1.25; }
.rules-list { display: grid; gap: 9px; margin: 0; }
.rules-list div { display: grid; grid-template-columns: 125px 1fr; gap: 9px; }
.rules-list dt { color: #f0d59b; font-weight: 700; }
.rules-list dd { margin: 0; color: var(--muted); line-height: 1.35; }
.legend { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.legend li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; color: var(--muted); line-height: 1.35; }
.legend strong { color: var(--ink); }
.legend-swatch { width: 20px; height: 20px; margin-top: 1px; border: 1px solid rgba(255,255,255,.22); border-radius: 5px; background: var(--parchment); }
.legend-swatch.event { background: rgb(225,175,91); }
.legend-swatch.port { border: 4px solid #4a9ac4; background: rgb(226,194,133); }
.legend-swatch.route { background: #354a50; }
.legend-swatch.utility { background: #c2a646; }
.legend-swatch.tax { background: rgb(206,119,79); }
.legend-swatch.rest { background: rgb(119,175,159); }
.turn-help ol { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin: 0; padding-left: 22px; color: var(--muted); }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 22px; transform: translate(-50%, 30px); max-width: min(90vw, 500px); padding: 11px 16px; border: 1px solid var(--line); border-radius: 10px; color: #fff; background: #8d3528; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.editor-shell { max-width: 1600px; margin: 0 auto; }
.editor-shell .topbar h1 { max-width: none; font-size: clamp(2.3rem, 4vw, 4.6rem); }
.editor-layout { display: grid; grid-template-columns: minmax(900px, 1fr) 340px; gap: 18px; align-items: start; }
.editor-board-wrap { min-width: 900px; }
.editor-board { touch-action: none; }
.editor-tile { cursor: grab; user-select: none; }
.editor-tile.dragging { z-index: 20; cursor: grabbing; filter: brightness(1.14); transform: translate(-50%,-50%) scale(1.12); }
.editor-tile.selected { outline: 3px solid #fff1ad; outline-offset: 4px; }
.editor-panel { position: sticky; top: 16px; padding: 22px; }
.editor-panel h2 { font-size: 1.7rem; }
.editor-panel hr { margin: 24px 0; border: 0; border-top: 1px solid var(--line); }
.editor-panel ol { display: grid; gap: 8px; padding-left: 21px; color: var(--muted); line-height: 1.35; }
.editor-meta { color: var(--muted); }
.editor-meta strong { color: var(--ink); }
.editor-saved { color: #86cca0; opacity: .7; transition: .2s; }
.editor-saved.flash { opacity: 1; transform: translateY(-2px); }
.editor-error { max-width: 600px; margin: 15vh auto; padding: 30px; }

@media (max-width: 980px) {
  .home-grid, .lobby-grid { grid-template-columns: 1fr; }
  .home-grid { padding-top: 7vh; }
  .game-layout { grid-template-columns: 1fr; }
  .game-board-scroll { order: -2; }
  .right-panel { order: -1; }
  .board-wrap { min-width: 900px; }
  .game-board-scroll { overflow-x: auto; padding-bottom: 8px; }
  .game-panel { grid-template-columns: repeat(3, 1fr); }
  .chat { grid-column: 1 / -1; }
  .editor-layout { grid-template-columns: 1fr; }
  .editor-panel { position: static; }
  .turn-help ol { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .shell { padding: 14px; }
  .topbar { align-items: flex-start; }
  .home-top { align-items: flex-start; }
  .brand span:last-child { display: none; }
  .ship-grid { grid-template-columns: repeat(2, 1fr); }
  .field-row { grid-template-columns: 1fr; }
  .player-card { grid-template-columns: 70px 1fr; }
  .player-ship { width: 70px; height: 50px; }
  .player-card .status { grid-column: 2; width: max-content; }
  .game-panel { grid-template-columns: 1fr; }
  .chat { grid-column: auto; }
  .topbar-actions { align-items: flex-end; }
  .help-grid { grid-template-columns: 1fr; }
  .trade-layout { grid-template-columns: 1fr; }
  .trade-builder { grid-template-columns: 1fr; }
  .test-grid { grid-template-columns: 1fr; }
  .test-target { grid-column: 1; }
  .trade-arrow { justify-self: center; transform: rotate(90deg); }
  .monopoly-help, .turn-help { grid-column: 1; }
  .group-legend { grid-template-columns: 1fr; }
  .turn-help ol { grid-template-columns: 1fr; }
  .rules-list div { grid-template-columns: 110px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  *:not(.moving-token):not(.map-die):not(.tile) { transition: none !important; animation: none !important; }
}
