:root {
  --ink: #2c382f; --muted: #738072; --paper: #f4efdf; --paper-light: #fffbf1;
  --line: #ddd8c7; --sea: #266d78; --sea-deep: #133f4a; --gold: #e9c77b;
  --accent: #a33e2d; --accent-dark: #792c21; --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: -apple-system, 'Hiragino Sans', 'Yu Gothic', sans-serif; background: var(--sea-deep); color: var(--ink); overflow: hidden; }
button { font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; border: 1px solid transparent; border-radius: 8px; padding: 11px 14px; background: var(--accent); color: #fff9e8; transition: background .15s, transform .15s; }
button:hover:not(:disabled) { background: var(--accent-dark); transform: translateY(-1px); }
button:disabled { background: #e5e0d1; color: #9c9c8f; cursor: default; }
button.quiet, button.close { background: transparent; color: var(--ink); border-color: #cbc7b7; }
button.quiet:hover, button.close:hover { background: #e7e2d3; }
button:focus-visible, summary:focus-visible { outline: 3px solid #cb9c40; outline-offset: 3px; }
[hidden] { display: none !important; }
#topbar { height: 80px; padding: 0 28px; background: var(--paper); display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #d4ccb5; }
.brand { display: flex; gap: 12px; align-items: center; }
.brandMark { font-size: 48px; line-height: 1; color: var(--accent); }
h1 { font-family: Georgia, serif; font-size: 29px; letter-spacing: 3px; line-height: 1; color: var(--accent); }
h1 span { font-family: sans-serif; letter-spacing: 2px; font-size: 10px; margin-left: 12px; font-weight: 500; color: var(--muted); }
.brand p { font-size: 9px; letter-spacing: 1px; margin-top: 6px; color: var(--muted); }
.headerActions { display: flex; align-items: center; gap: 10px; }
.matchLabel { color: var(--muted); font-size: 11px; margin-right: 15px; }
#rulesButton { background: var(--ink); }
#app { display: grid; grid-template-columns: minmax(0, 1fr) 352px; height: calc(100dvh - 116px); }
#boardWrap { position: relative; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 38px 12px 58px; background: radial-gradient(ellipse at 50% 44%, #337a81 0%, #205561 68%, #173f4b 100%); overflow: hidden; }
.boardCaption { position: absolute; left: 30px; right: 30px; top: 23px; display: flex; justify-content: space-between; color: #c0d4cf; font-size: 10px; letter-spacing: 2px; }
.boardCaption span:first-child { font-family: Georgia, serif; }
#turnLabel { letter-spacing: 1px; }
#board { width: 100%; height: 100%; max-width: 850px; overflow: visible; }
#boardHint { position: absolute; bottom: 42px; left: 12px; right: 12px; text-align: center; font-size: 12px; color: #ffedb8; letter-spacing: .7px; }
.boardLegend { position: absolute; bottom: 17px; display: flex; align-items: center; gap: 20px; font-size: 10px; color: #a5c5c1; }
.boardLegend span { display: flex; align-items: center; gap: 5px; }
.legendHome { width: 10px; height: 10px; background: #e6cd92; clip-path: polygon(0 40%,50% 0,100% 40%,100% 100%,0 100%); }
.legendCity { width: 14px; height: 10px; background: #e6cd92; clip-path: polygon(0 30%,30% 0,60% 30%,60% 50%,100% 50%,100% 100%,0 100%); }
#side { background: var(--paper); display: flex; flex-direction: column; gap: 12px; padding: 22px 22px 16px; overflow-y: auto; border-left: 1px solid #cebfa0; }
.turnPanel { padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.eyebrow, .sectionLabel { font-size: 10px; letter-spacing: 1.5px; color: var(--muted); font-weight: 600; }
.sectionLabel { display: flex; justify-content: space-between; margin-top: 3px; }
.sectionLabel span { letter-spacing: 0; }
#status { font-size: 16px; font-weight: 700; margin-top: 7px; }
#diceRow { display: flex; align-items: center; gap: 8px; min-height: 30px; margin-top: 10px; }
.diceHint { font-size: 11px; color: var(--muted); }
.die { width: 34px; height: 34px; padding: 6px; display: grid; grid-template-columns: repeat(3,1fr); grid-template-rows: repeat(3,1fr); gap: 2px; background: #fffaf0; border: 1px solid #d6c8aa; border-radius: 7px; box-shadow: 0 2px 0 #c9b993; }
.pip { border-radius: 50%; background: #523f2b; visibility: hidden; }
.die-1 .p4, .die-2 :is(.p0,.p8), .die-3 :is(.p0,.p4,.p8), .die-4 :is(.p0,.p2,.p6,.p8), .die-5 :is(.p0,.p2,.p4,.p6,.p8), .die-6 :is(.p0,.p2,.p3,.p5,.p6,.p8) { visibility: visible; }
.diceTotal { font-size: 11px; color: var(--muted); margin-left: 6px; }
.diceTotal b { font-size: 20px; font-family: Georgia,serif; margin-left: 5px; color: var(--ink); }
#resumeNotice { font-size: 11px; color: #457447; line-height: 1.6; }
#resumeNotice:empty { display: none; }
#players { display: flex; flex-direction: column; }
.pcard { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.pcard.turn .nm::after { content: '手番'; margin-left: 6px; color: var(--accent); font-size: 9px; font-weight: 500; }
.playerPawn { background: var(--player); color: #fff; text-shadow: 0 1px 2px #000b; width: 26px; height: 29px; flex-shrink: 0; border: 1px solid #0002; border-radius: 12px 12px 5px 5px; box-shadow: inset 2px 0 2px #fff5, 0 2px 0 #0003; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; }
.playerInfo { min-width: 0; flex: 1; }
.nm { font-size: 12px; font-weight: 700; }
.playerDetail { font-size: 9px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.playerScore { text-align: right; }
.playerScore strong { font: 25px Georgia,serif; display: block; line-height: 1; }
.playerScore span { font-size: 8px; color: var(--muted); }
.badge { display: inline-block; font-size: 8px; padding: 2px 4px; border-radius: 3px; background: #e9d8a9; color: #796327; margin-left: 3px; }
#handPanel h4 { display: flex; justify-content: space-between; font-size: 11px; margin: 2px 0 11px; }
#handPanel h4 span { font-weight: 400; color: var(--muted); font-size: 10px; }
.resRow { display: grid; grid-template-columns: repeat(5,1fr); gap: 6px; }
.resourceCard { position: relative; background: #fffaf0; border: 1px solid #d8ccb2; border-radius: 5px; min-width: 0; padding: 4px 2px 7px; text-align: center; box-shadow: 0 2px 0 #ded3b9; }
.resourceIcon { width: 36px; height: 30px; display: block; margin: auto; }
.resourceCard span { display: block; font-size: 9px; color: #666d59; }
.resourceCard strong { font: 23px Georgia,serif; display: block; margin-top: 3px; }
.devRow { font-size: 10px; color: var(--muted); margin-top: 11px; line-height: 1.6; }
.handHeading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
#handPanel .handHeading h4 { margin: 0; }
.cardHelp { padding: 6px 8px; font-size: 10px; }
button.resourceCard { color: var(--ink); font-weight: 400; }
button.resourceCard:hover:not(:disabled) { background: #f0e4c9; }
.cardTapHint { color: #747965; font-size: 10px; line-height: 1.7; margin-top: 9px; }
#handPanel .devInfoHeading, .devInfoHeading { margin-top: 18px; }
.ownedDevCards { display: grid; gap: 8px; }
.ownedDevCard { display: block; width: 100%; text-align: left; background: #fffaf0; border: 1px solid #d8ccb2; color: var(--ink); padding: 12px; font-weight: 400; }
.ownedDevCard:hover:not(:disabled) { background: #f0e4c9; }
.ownedDevCard > strong { display: flex; justify-content: space-between; font-size: 13px; }
.devEffect { display: block; font-size: 11px; line-height: 1.7; margin-top: 6px; }
.cardStatus { display: block; font-size: 10px; color: #765729; line-height: 1.7; margin-top: 6px; }
#handDialog { width: min(640px, calc(100vw - 32px)); padding: 0; }
.cardInfo { padding: 14px 0; border-bottom: 1px solid var(--line); scroll-margin: 90px 0; }
.cardInfoHead { display: flex; align-items: center; gap: 10px; }
.cardInfoHead .resourceIcon { margin: 0; }
.cardInfoHead h4 { font-size: 15px; flex: 1; }
.cardInfoHead > strong { font-size: 12px; }
.cardInfo p { margin: 8px 0; }
.cardInfo .cardFootnote { font-size: 11px; }
.ownedCard .cardInfoHead > strong { color: #34764b; }
#handDetails h3 small { font-size: 12px; font-weight: 400; }
.devPlayChoice { display: block; width: 100%; text-align: left; margin-top: 8px; }
.devPlayChoice span { display: block; font-size: 11px; font-weight: 400; line-height: 1.7; margin-top: 6px; }
#actionPanel { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#actionPanel button { font-size: 11px; padding: 10px 6px; min-height: 38px; }
#actionPanel [data-act='roll'], #actionPanel [data-act='end'] { grid-column: 1 / -1; }
#actionPanel [data-act='roll'] { padding: 14px; font-size: 14px; }
#actionPanel [data-act='end'] { background: var(--ink); }
.instr { grid-column: 1 / -1; font-size: 11px; color: #91703d; line-height: 1.7; }
#logWrap { flex: 1; min-height: 72px; overflow-y: auto; }
#log { font-size: 10px; line-height: 1.8; color: #7d8270; }
#log div { padding: 2px 0; }
#log div:last-child { color: #3c5746; }
#savePanel { position: fixed; bottom: 0; left: 0; right: 0; min-height: 36px; padding: 9px 24px; border-top: 1px solid var(--line); font-size: 10px; background: var(--paper); display: flex; justify-content: space-between; align-items: center; gap: 16px; z-index: 5; }
#saveStatus { color: #477b4d; }
#saveStatus::before { content: '●'; margin-right: 5px; font-size: 7px; }
#saveStatus.saveError { color: #a23526; line-height: 1.6; font-size: 11px; }
#offlineStatus { color: #687363; font-size: 9px; flex-shrink: 0; }
/* Physical pieces and illustrated tiles */
.seaRim { fill: #153f4b; stroke: #a2c9bc; stroke-width: 1.5; filter: url(#islandShadow); }
.seaFace { fill: #347884; stroke: #568f96; stroke-width: 1; }
.hexPoly { stroke: #e4cca0; stroke-width: 3.5; stroke-linejoin: round; }
.tileArt, .numTok, .numTxt, .pipTxt, .bldg, .robber, .robberTxt { pointer-events: none; }
.numTok { fill: #fbefd1; stroke: #bb9c68; stroke-width: 1.4; filter: url(#pieceShadow); }
.numTxt { font-family: Georgia,serif; font-size: 18px; font-weight: 700; text-anchor: middle; fill: #453b29; }
.numTxt.hot { fill: #af3729; }
.pipTxt { font-size: 7px; text-anchor: middle; fill: #776341; letter-spacing: .4px; }
.edgeLine { stroke: #735d3433; stroke-width: 1; }
/* Object-bounding-box SVG filters hide vertical lines because their box has zero width. */
.edgeRoad { stroke-width: 7; stroke-linecap: round; }
.edgeValid { stroke: #fff0a0; stroke-width: 6; stroke-linecap: round; stroke-dasharray: 5 4; }
.edgeHit { fill: transparent; stroke: transparent; stroke-width: 2; cursor: pointer; pointer-events: all; }
.edgeHit:hover, .edgeHit:focus-visible { fill: #fff8bf66; stroke: #fff0a0; outline: none; }
.roadPlusBg { fill: #ffedac; stroke: #9f7b35; stroke-width: 1; pointer-events: none; }
.roadPlus { fill: #674f24; font: bold 12px sans-serif; text-anchor: middle; pointer-events: none; }
.roadTarget:hover .roadPlusBg, .roadTarget:focus-within .roadPlusBg { fill: #fffce2; }
#actionPanel button[aria-pressed='true'] { background: #68432a; box-shadow: inset 0 0 0 2px #d8ad61; }
.buildInstruction { color: #704f21; }
.vtxHit { fill: transparent; cursor: pointer; }
.vtxHit:hover { fill: #fff8bf99; }
.vtxDot { fill: #735d3488; }
.vtxValid { fill: #fff0a044; stroke: #fff1a4; stroke-width: 2; stroke-dasharray: 3 3; }
.bldg { stroke: #4b3626; stroke-width: 1.5; filter: url(#pieceShadow); }
.robber { fill: #313a38; stroke: #e9dec0; stroke-width: 1.4; filter: url(#pieceShadow); }
.robberTxt { fill: #faf0ce; font-size: 11px; font-weight: 700; text-anchor: middle; }
.portDock { stroke: #c7b285; stroke-width: 4; stroke-linecap: round; pointer-events: none; }
.portBg, .portTxt, .portBoat { pointer-events: none; }
.portBg { fill: #f2e7c8; stroke: #ab9468; stroke-width: .8; }
.portTxt { font-size: 8px; font-weight: 700; text-anchor: middle; fill: #554832; }
.hexValid { stroke: #ffe996; stroke-width: 4; stroke-dasharray: 7 3; cursor: pointer; }
.hexValid:hover { filter: brightness(1.12); }
/* Dialogs */
#modalOverlay { position: fixed; inset: 0; background: #0e282bd0; display: flex; align-items: center; justify-content: center; z-index: 10; }
#modalOverlay.hidden { display: none; }
#modal, dialog { background: var(--paper-light); color: var(--ink); border: 1px solid #c9ba99; border-radius: 14px; padding: 24px; max-height: calc(100dvh - 32px); overflow-y: auto; }
#modal { width: min(440px,calc(100vw - 32px)); }
#modal h3, dialog h2 { font-size: 19px; margin-bottom: 12px; }
#modal p, dialog p { font-size: 13px; line-height: 1.8; margin: 10px 0; color: #6c715f; }
#modal .resbtn { margin: 3px; min-height: 40px; border: 1px solid #0003; }
.btnRow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
#modal .sel { outline: 3px solid #b88024; }
#tradeInfo, #pickInfo, #discInfo { font-size: 12px; line-height: 1.8; margin-top: 12px; }
dialog { margin: auto; width: min(560px,calc(100vw - 32px)); }
dialog::backdrop { background: #0e282bc9; }
#rulesDialog { width: min(640px,calc(100vw - 32px)); padding: 0; }
.rulesHeader { position: sticky; top: 0; background: var(--paper-light); display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 24px; border-bottom: 1px solid var(--line); z-index: 1; }
.rulesHeader h2 { font-size: 20px; margin: 0; }
.rulesHeader form { flex-shrink: 0; }
.rulesHeader button { white-space: nowrap; }
#newGameDialog { width: min(560px, calc(100vw - 32px)); }
.optGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 14px 0 6px; }
.optGrid label { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--muted); font-weight: 700; }
.optGrid select { font: inherit; font-size: 13px; font-weight: 400; color: var(--ink); padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper-light); }
.rulesBody { padding: 22px 24px; font-size: 13px; line-height: 1.9; }
.rulesBody h3 { color: var(--accent); font-size: 18px; }
.rulesBody p { margin: 10px 0 16px; }
.rulesBody details { padding: 14px 0; border-bottom: 1px solid var(--line); }
.rulesBody summary { cursor: pointer; font-weight: 700; }
.rulesBody ul, .rulesBody ol { padding-left: 22px; margin: 10px 0; }
.rulesBody table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 12px; }
.rulesBody th, .rulesBody td { padding: 8px; text-align: left; border-bottom: 1px solid var(--line); }
.rulesBody th[scope='row'] { white-space: nowrap; }
.rulesNote { font-size: 11px !important; }
#sessionGate { position: fixed; inset: 80px 0 36px; z-index: 20; background: #153f4bec; display: grid; place-items: center; padding: 20px; }
#sessionGate > div { background: var(--paper); border-radius: 14px; padding: 28px; max-width: 450px; }
#sessionGate h2 { font-size: 20px; }
#sessionMessage { margin: 16px 0; line-height: 1.8; font-size: 13px; }
@media (min-width: 1400px) { #app { grid-template-columns: minmax(0,1fr) 380px; } #side { padding: 26px; gap: 15px; } .pcard { padding: 12px 0; } }
@media (max-height: 800px) and (min-width: 801px) { #side { gap: 8px; padding: 14px 20px; } .pcard { padding: 6px 0; } .resourceIcon { height: 23px; } .resourceCard strong { font-size: 20px; } .turnPanel { padding-bottom: 9px; } #diceRow { margin-top: 6px; } }
@media (max-width: 800px) { body { overflow: auto; } #topbar { height: auto; min-height: 74px; padding: 14px 16px; gap: 10px; } h1 { font-size: 24px; } h1 span, .brand p, .matchLabel, .brandMark { display: none; } .headerActions { gap: 5px; } .headerActions button { font-size: 10px; padding: 10px; } #app { display: flex; flex-direction: column; height: auto; } #boardWrap { height: min(92vw,630px); min-height: 355px; padding: 28px 6px 52px; } .boardCaption { top: 14px; left: 18px; right: 18px; font-size: 9px; } #side { padding: 20px; overflow: visible; border: none; gap: 15px; } #players { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; } .playerDetail { font-size: 8px; } #logWrap { height: 110px; flex: auto; } .resourceIcon { height: 38px; width: 45px; } #sessionGate { inset: 0; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 800px) { body { padding-bottom: 44px; } #boardWrap { height: min(92vw, calc(100svh - 115px)); min-height: 320px; } #savePanel { padding: 10px 14px; font-size: 9px; gap: 8px; } #offlineStatus { font-size: 8px; } }

/* --- conversation & negotiation --- */
#chatWrap { height: 150px; overflow-y: auto; background: #12313852; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.chatRow { display: flex; gap: 6px; margin: 5px 0; align-items: flex-start; }
.chatWho { font-size: 9px; font-weight: 800; white-space: nowrap; padding-top: 3px; min-width: 38px; }
.chatBubble { background: var(--paper-light); border-radius: 9px; padding: 5px 9px; font-size: 11px; line-height: 1.5; flex: 1; }
.chat-me .chatBubble { background: #31435c; color: #e8eef5; }
.chat-live .chatBubble { background: transparent; border: 1px dashed var(--line); color: var(--muted); font-style: italic; }
.chat-live .chatWho { color: var(--accent); }
.offerRow { display: flex; gap: 6px; margin-top: 6px; }
.offerRow button { font-size: 11px; padding: 4px 10px; }
.offerStatus { font-size: 10px; color: var(--muted); margin-top: 4px; }

/* --- ships & fog --- */
.edgeShip { stroke-width: 5; stroke-linecap: round; stroke-dasharray: 7 5; opacity: .95; }
.shipSail { stroke: #0c2830; stroke-width: .7; pointer-events: none; }
.shipHull { fill: #543c2e; pointer-events: none; }
.hexFog { stroke: #1d3039; stroke-width: 1.5; }
.fogMark { fill: #7e93a5; font-size: 22px; font-weight: 700; text-anchor: middle; pointer-events: none; }
.hexSea { pointer-events: none; }

/* --- series scoreboard --- */
#matchPanel:empty { display: none; }
.matchHead { font-size: 11px; font-weight: 800; color: var(--accent); margin-bottom: 4px; }
.matchTable { width: 100%; border-collapse: collapse; font-size: 11px; margin-bottom: 4px; }
.matchTable th, .matchTable td { padding: 3px 6px; text-align: left; border-bottom: 1px solid var(--line); }
.matchTable th { color: var(--muted); font-size: 9px; }
.optGrid small { font-weight: 400; color: var(--muted); line-height: 1.5; }
