:root {
  --deep: #052b46;
  --deep-2: #074d6a;
  --ocean: #008fa8;
  --lagoon: #37d3cf;
  --foam: #ecf8f2;
  --sand: #f3e3b8;
  --paper: #fbf9ed;
  --ink: #183940;
  --muted: #6b8384;
  --p0: #ff5d42;
  --p0-dark: #b72f22;
  --p1: #7657e6;
  --p1-dark: #4930aa;
  --gold: #ffd447;
  --line: rgba(22, 63, 67, .16);
  --shadow: 0 25px 70px rgba(0, 25, 31, .26);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0, rgba(55, 211, 207, .38), transparent 28rem),
    radial-gradient(circle at 92% 88%, rgba(32, 142, 217, .3), transparent 34rem),
    linear-gradient(145deg, #04283d, #075e78 58%, #06384f);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #f4cb60; outline-offset: 3px; }
[hidden] { display: none !important; }
.ocean-grain { position: fixed; inset: 0; pointer-events: none; z-index: -1; opacity: .16; background-image: radial-gradient(rgba(255,255,255,.7) .6px, transparent .7px); background-size: 8px 8px; mask-image: linear-gradient(black, transparent 90%); }

.topbar { height: 70px; padding: 0 clamp(13px, 3vw, 38px); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; color: white; border-bottom: 1px solid rgba(255,255,255,.14); background: rgba(2, 33, 41, .46); backdrop-filter: blur(14px); position: relative; z-index: 20; }
.back-link { color: #c6e5e2; text-decoration: none; font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.brand { display: flex; align-items: center; gap: 11px; color: white; text-decoration: none; }
.brand span { width: 37px; height: 37px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.65); font: 800 17px Georgia, serif; transform: rotate(45deg); }
.brand span { color: transparent; }
.brand span::after { content: "✦"; color: white; transform: rotate(-45deg); }
.brand strong { font: 700 16px Georgia, serif; letter-spacing: .13em; }
.round-button { justify-self: end; width: 37px; height: 37px; color: white; border: 1px solid rgba(255,255,255,.28); border-radius: 50%; background: rgba(255,255,255,.08); font-weight: 900; }
.round-button:hover { background: rgba(255,255,255,.16); }
.eyebrow { margin: 0 0 8px; color: #78908f; font-size: 9px; font-weight: 900; letter-spacing: .21em; }

/* Lobby */
.lobby-shell { width: min(1160px, calc(100% - 30px)); min-height: calc(100vh - 70px); margin: auto; padding: clamp(35px, 7vh, 78px) 0; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(370px, .8fr); align-items: center; gap: clamp(35px, 7vw, 95px); }
.lobby-hero { color: white; }
.lobby-hero .eyebrow { color: #87d5cf; }
.lobby-hero h1 { margin: 0; max-width: 660px; font: 800 clamp(45px, 6.6vw, 82px)/.98 Georgia, "Times New Roman", serif; letter-spacing: -.045em; }
.lobby-hero h1 em { color: #efd27e; font-weight: 400; }
.lobby-hero > p:not(.eyebrow) { max-width: 580px; margin: 24px 0 30px; color: #c2dedc; font: 16px/1.65 Georgia, serif; }
.steps { max-width: 560px; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); list-style: none; }
.steps li { position: relative; display: flex; align-items: center; gap: 10px; }
.steps li:not(:last-child)::after { content: ""; width: 28%; height: 1px; position: absolute; right: 8%; background: rgba(255,255,255,.28); }
.steps b { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.45); border-radius: 50%; font: 700 13px Georgia, serif; }
.steps span { font-size: 11px; font-weight: 800; line-height: 1.2; }
.steps small { color: #8fc3c0; font-size: 8px; font-weight: 600; }
.lobby-panel { padding: clamp(23px, 4vw, 38px); border: 1px solid rgba(255,255,255,.32); border-radius: 24px; background: var(--paper); box-shadow: var(--shadow); }
.panel-heading h2, .rules-dialog h2 { margin: 0; color: var(--deep); font: 800 30px/1.05 Georgia, serif; }
.lobby-tabs { margin: 24px 0 18px; padding: 4px; display: grid; grid-template-columns: 1fr 1fr; border-radius: 12px; background: #e7ece5; }
.lobby-tabs button { height: 39px; border: 0; border-radius: 9px; color: #667b7b; background: transparent; font-size: 11px; font-weight: 900; }
.lobby-tabs button.active { color: white; background: var(--deep-2); box-shadow: 0 5px 14px rgba(3, 52, 62, .22); }
.lobby-form { display: grid; gap: 13px; }
.lobby-form label { color: #617878; font-size: 9px; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }
.lobby-form input { width: 100%; height: 48px; margin-top: 6px; padding: 0 14px; color: var(--ink); border: 1px solid #cbd7cf; border-radius: 10px; background: white; font-size: 15px; text-transform: none; }
.lobby-form input:focus { border-color: var(--ocean); }
.lobby-form .code-input { text-align: center; font: 800 22px Georgia, serif; letter-spacing: .26em; text-transform: uppercase; }
.mode-field { margin: 0; padding: 0; border: 0; }
.mode-field legend { margin-bottom: 6px; color: #617878; font-size: 9px; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }
.mode-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode-choice label { position: relative; cursor: pointer; }
.mode-choice input { position: absolute; opacity: 0; pointer-events: none; }
.mode-choice span { min-height: 61px; padding: 10px 11px; display: flex; flex-direction: column; justify-content: center; border: 1px solid #cbd7cf; border-radius: 10px; background: white; transition: .15s; }
.mode-choice b { color: var(--ink); font-size: 10px; text-transform: none; }
.mode-choice small { margin-top: 3px; color: #82918e; font-size: 7px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.mode-choice input:checked + span { color: white; border-color: var(--ocean); background: #dff3ec; box-shadow: inset 4px 0 var(--ocean); }
.mode-choice input:focus-visible + span { outline: 3px solid #f4cb60; outline-offset: 2px; }
.range-field { position: relative; }
.range-field output { float: right; min-width: 28px; padding: 3px 6px; color: white; border-radius: 999px; background: var(--ocean); text-align: center; font-size: 10px; }
.range-field input[type="range"] { height: 30px; margin-top: 8px; padding: 0; accent-color: var(--ocean); cursor: pointer; }
.range-field > span { display: flex; justify-content: space-between; color: #819391; }
.range-field > span small { font-size: 7px; font-weight: 700; text-transform: none; }
.primary-button { width: 100%; min-height: 49px; margin-top: 3px; padding: 13px 17px; color: white; border: 0; border-radius: 10px; background: var(--deep-2); box-shadow: 0 8px 20px rgba(3,54,63,.19); font-size: 12px; font-weight: 900; text-align: left; text-decoration: none; }
.primary-button:hover { background: #086171; }
.primary-button > i, .primary-button > span:last-child { float: right; font-style: normal; }
.primary-button .button-label { float: none; }
.primary-button:disabled { opacity: .6; }
.open-games { margin-top: 25px; padding-top: 18px; border-top: 1px solid #dbe2da; }
.open-title { margin-bottom: 9px; display: flex; justify-content: space-between; align-items: center; color: #607675; font-size: 9px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.open-title i, .online-pill i { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #4eb98e; box-shadow: 0 0 0 3px rgba(78,185,142,.16); }
.open-title button { border: 0; color: var(--ocean); background: transparent; font-size: 8px; font-weight: 900; text-transform: uppercase; }
.game-list { max-height: 165px; overflow-y: auto; }
.game-row { width: 100%; padding: 9px 4px; display: grid; grid-template-columns: 35px 1fr auto 18px; align-items: center; gap: 9px; text-align: left; color: var(--ink); border: 0; border-bottom: 1px solid #e1e5de; background: transparent; }
.game-row:hover { background: #f1f1e7; }
.game-avatar { width: 32px; height: 32px; display: grid; place-items: center; color: white; border-radius: 50%; background: var(--p0); font: 800 13px Georgia, serif; }
.game-row span:nth-child(2) { min-width: 0; display: flex; flex-direction: column; }
.game-row b { overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.game-row small { color: #859493; font-size: 8px; }
.game-row code { color: #4d777b; font: 800 10px ui-monospace, monospace; letter-spacing: .08em; }
.game-row i { color: #78918e; font-style: normal; }
.empty-line { margin: 12px 0; color: #7d8f8e; font-size: 10px; line-height: 1.45; }
.error-line, .form-error { color: #ad4935; }
.form-error { margin: 12px 0 0; padding: 10px; border-radius: 8px; background: #f9ddd5; font-size: 10px; font-weight: 700; }

/* Game */
.game-shell { width: min(1500px, calc(100% - 26px)); margin: 15px auto 24px; }
.game-heading { height: 64px; padding: 0 10px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; color: white; }
.player-chip { display: flex; align-items: center; gap: 11px; min-width: 0; opacity: .72; }
.player-chip:last-child { justify-self: end; text-align: right; }
.player-chip > span { width: 38px; height: 38px; display: grid; place-items: center; color: white; border: 3px solid white; border-radius: 50%; background: var(--player); box-shadow: 0 0 0 3px var(--player); font: 700 14px Georgia, serif; }
.player-chip.p0 { --player: var(--p0); }
.player-chip.p1 { --player: var(--p1); }
.player-chip.active { opacity: 1; }
.player-chip.active > span { animation: playerPulse 1.7s infinite; }
.player-chip.me strong::after { content: " · VOUS"; color: #f1d88a; font-size: 7px; letter-spacing: .1em; }
.player-chip > div { min-width: 0; display: flex; flex-direction: column; }
.player-chip strong { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.player-chip small { margin-top: 3px; color: #acd3d0; font-size: 9px; }
.player-chip small b { color: white; }
@keyframes playerPulse { 50% { box-shadow: 0 0 0 7px var(--player), 0 0 18px var(--player); } }
.turn-box { min-width: 175px; padding: 8px 18px; text-align: center; border: 1px solid rgba(255,255,255,.14); border-radius: 999px; background: rgba(2, 32, 40, .48); }
.turn-box small { display: block; color: #9ccbc8; font-size: 8px; font-weight: 900; letter-spacing: .12em; }
.turn-box strong { display: block; margin-top: 2px; font: 700 13px Georgia, serif; }
.play-layout { height: calc(100vh - 170px); min-height: 600px; display: grid; grid-template-columns: minmax(0, 1fr) 365px; gap: 13px; }
.board-card, .control-card { overflow: hidden; border-radius: 21px; box-shadow: var(--shadow); }
.board-card {
  min-width: 0;
  padding: 9px;
  display: flex;
  flex-direction: column;
  border: 2px solid #e2ad5a;
  background:
    repeating-linear-gradient(96deg, rgba(255,255,255,.08) 0 2px, transparent 2px 18px),
    linear-gradient(150deg, #9a5a2b, #d49a4c 48%, #7c421f);
  box-shadow: inset 0 0 0 3px rgba(83,40,17,.38), 0 25px 70px rgba(0,25,31,.3);
}
.board-toolbar {
  min-height: 43px;
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #254653;
  border: 1px solid rgba(94,51,20,.38);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background:
    radial-gradient(circle at 16% 0, rgba(255,255,255,.65), transparent 42%),
    linear-gradient(110deg, #f8e6b7, #e8c77c);
  text-shadow: 0 1px rgba(255,255,255,.55);
  font-size: 10px;
  font-weight: 800;
}
.board-meta { margin-left: auto; margin-right: 10px; color: #62766d; font-size: 7px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.board-toolbar .online-pill { color: white; border-color: rgba(255,255,255,.3); background: #087d89; text-shadow: none; }
.online-pill { padding: 5px 8px; border: 1px solid rgba(255,255,255,.15); border-radius: 999px; font-size: 7px; letter-spacing: .12em; }
.board { flex: 1; min-height: 0; position: relative; overflow: hidden; isolation: isolate; background:
  radial-gradient(ellipse at 27% 30%, rgba(152,246,226,.92) 0 6%, rgba(54,214,219,.62) 12%, transparent 24%),
  radial-gradient(ellipse at 68% 69%, rgba(155,246,224,.78) 0 7%, rgba(34,194,211,.52) 14%, transparent 26%),
  radial-gradient(circle at 44% 38%, rgba(255,255,255,.42) 0 1px, transparent 2px),
  repeating-radial-gradient(ellipse at 45% 42%, transparent 0 31px, rgba(255,255,255,.1) 32px 34px),
  linear-gradient(150deg, #20c7d5, #078fbd 48%, #075994 100%);
  background-size: auto, auto, 9px 9px, auto, auto;
  border: 1px solid rgba(48,28,15,.5);
  border-radius: 0 0 10px 10px;
  box-shadow: inset 0 0 45px rgba(0,38,88,.34);
}
.board::before, .board::after { content: ""; position: absolute; z-index: -1; border: 2px solid rgba(206,255,243,.22); border-radius: 50%; transform: rotate(-18deg); }
.board::before { width: 280px; height: 100px; left: 3%; top: 57%; }
.board::after { width: 330px; height: 118px; right: -5%; top: 6%; }
.route-layer, .bridge-button-layer, .island-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.route-layer { overflow: visible; }
.sea-route { stroke: rgba(2, 52, 91, .58); stroke-width: 2.2; stroke-dasharray: 2 7; stroke-linecap: round; vector-effect: non-scaling-stroke; filter: drop-shadow(0 1px rgba(255,255,255,.32)); }
.wooden-bridge { filter: drop-shadow(0 3px 2px rgba(0,31,48,.55)); }
.wooden-bridge line { vector-effect: non-scaling-stroke; }
.bridge-owner-glow { stroke-width: 16; stroke-linecap: round; opacity: .72; }
.wooden-bridge.owner-0 .bridge-owner-glow { stroke: var(--p0); }
.wooden-bridge.owner-1 .bridge-owner-glow { stroke: var(--p1); }
.bridge-core { stroke: #5b371f; stroke-width: 11; stroke-linecap: round; }
.bridge-rope { stroke: #3b281c; stroke-width: 2.4; stroke-linecap: round; }
.bridge-plank { stroke: #e2a24a; stroke-width: 5.8; stroke-linecap: round; }
.bridge-plank.plank-1 { stroke: #c98335; }
.bridge-plank.plank-2 { stroke: #efbc68; }
.bridge-control { position: absolute; z-index: 5; width: 44px; height: 44px; display: grid; place-items: center; transform: translate(-50%, -50%); color: rgba(255,255,255,.68); border: 1px dashed rgba(255,255,255,.43); border-radius: 50%; background: rgba(3, 72, 80, .72); box-shadow: 0 5px 14px rgba(1,33,38,.18); transition: .18s; }
.bridge-control b { font-size: 22px; line-height: 1; }
.bridge-control:disabled { opacity: .43; }
.bridge-control.available { color: var(--deep); border: 3px solid white; background: var(--gold); box-shadow: 0 0 0 6px rgba(237,189,79,.28), 0 8px 20px rgba(1,43,48,.3); animation: bridgePulse 1.25s infinite; opacity: 1; }
.bridge-control.cuttable { color: white; border: 3px solid white; background: #bb3e36; box-shadow: 0 0 0 6px rgba(187,62,54,.25); opacity: 1; }
.bridge-control.occupied { width: 34px; height: 34px; color: white; border: 2px solid rgba(255,255,255,.78); background: var(--owner); opacity: 1; }
.bridge-control.owner-0 { --owner: var(--p0-dark); }
.bridge-control.owner-1 { --owner: var(--p1-dark); }
@keyframes bridgePulse { 50% { transform: translate(-50%, -50%) scale(1.12); box-shadow: 0 0 0 10px rgba(237,189,79,.13), 0 8px 22px rgba(1,43,48,.35); } }
.island { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.island-shape { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 7px 6px rgba(0,39,67,.4)); }
.island-lagoon-halo { fill: none; stroke: color-mix(in srgb, var(--island-color) 22%, #a9fff0); stroke-width: 18px; stroke-linejoin: round; opacity: .42; vector-effect: non-scaling-stroke; }
.island-coast { stroke: color-mix(in srgb, var(--island-color) 72%, #eef2bd); stroke-width: 7px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.island-land { stroke: color-mix(in srgb, var(--island-color) 52%, #4d8b3f); stroke-width: 2.5px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.island-relief { opacity: .78; }
.island-valley { opacity: .58; mix-blend-mode: multiply; }
.terrain-contours path {
  fill: none;
  stroke: color-mix(in srgb, var(--island-color) 22%, #f0efaa);
  stroke-width: 1.15px;
  stroke-linejoin: round;
  opacity: .3;
  vector-effect: non-scaling-stroke;
}
.terrain-contours path:nth-child(2) { opacity: .23; }
.terrain-contours path:nth-child(3) { opacity: .18; }
.island-color-ring { fill: none; stroke: color-mix(in srgb, var(--island-color) 78%, #214e3d); stroke-width: 2px; stroke-linejoin: round; opacity: .95; vector-effect: non-scaling-stroke; }
.island.owned .island-coast { stroke: white; }
.island.owner-0 .island-coast { filter: drop-shadow(0 0 3px var(--p0)); }
.island.owner-1 .island-coast { filter: drop-shadow(0 0 3px var(--p1)); }
.island-cell { position: absolute; display: block; overflow: hidden; border: clamp(2px, .24vw, 4px) solid color-mix(in srgb, var(--island-color) 58%, #dce98f); border-radius: 48% 38% 52% 34%; background:
  radial-gradient(ellipse at 30% 24%, color-mix(in srgb, var(--island-color) 16%, #e4e565) 0 9%, transparent 52%),
  radial-gradient(ellipse at 70% 76%, color-mix(in srgb, var(--island-color) 14%, #0b5e39) 0 11%, transparent 55%),
  linear-gradient(145deg, color-mix(in srgb, var(--island-color) 26%, #cbdc53), color-mix(in srgb, var(--island-color) 22%, #188246) 48%, #075b39);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--island-color) 46%, #e8eca4), 0 6px 13px rgba(1,65,70,.4); transform: scale(1.08) rotate(-1.5deg); }
.island-cell::after { content: ""; position: absolute; inset: 9%; border: 1px solid rgba(235,241,153,.3); border-radius: inherit; opacity: .75; }
.island-cell-1 { border-radius: 35% 53% 39% 49%; transform: scale(1.09) rotate(2deg); }
.island-cell-2 { border-radius: 52% 34% 47% 40%; transform: scale(1.07) rotate(-3deg); }
.island-cell-3 { border-radius: 42% 48% 32% 55%; transform: scale(1.1) rotate(1deg); }
.island.owned .island-cell { border-color: white; box-shadow: 0 0 0 3px var(--owner), 0 6px 12px rgba(1,44,48,.35); }
.island.owner-0 { --owner: var(--p0); }
.island.owner-1 { --owner: var(--p1); }
.island-label {
  position: absolute;
  z-index: 2;
  display: inline-flex;
  min-width: 66px;
  padding: 4px 8px 5px;
  flex-direction: column;
  color: white;
  border: 2px solid rgba(255,255,255,.88);
  border-radius: 8px;
  background: color-mix(in srgb, var(--island-color) 76%, #173a4c);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--island-color) 55%, #382613), 0 5px 10px rgba(0,32,52,.36);
  transform: translate(-50%, -50%) rotate(-1deg);
  text-align: center;
}
.island:nth-child(even) .island-label { transform: translate(-50%, -50%) rotate(1deg); }
.island b { font: 900 10px Georgia, serif; letter-spacing: .09em; text-shadow: 0 1px 1px rgba(0,0,0,.38); }
.island small { color: rgba(255,255,255,.88); font-size: 6px; font-weight: 900; letter-spacing: .07em; white-space: nowrap; }
.island small i, .island-card small i { display: inline-grid; min-width: 13px; height: 13px; padding: 0 3px; place-items: center; color: #263c46; border-radius: 999px; background: var(--gold); font-style: normal; font-weight: 1000; letter-spacing: 0; }
.compass { position: absolute; right: 22px; bottom: 22px; width: 42px; height: 42px; display: grid; place-items: center; color: #f8efbf; border: 2px solid rgba(255,255,255,.64); border-radius: 50%; background: rgba(4,70,106,.32); box-shadow: inset 0 0 0 3px rgba(255,255,255,.09); font: 900 10px Georgia, serif; }
.compass::after { content: ""; width: 1px; height: 15px; position: absolute; top: -8px; background: rgba(255,255,255,.5); }
.control-card { display: flex; flex-direction: column; background: var(--paper); }
.control-card section { padding: 14px 16px; border-bottom: 1px solid #dce3db; }
.section-heading { display: flex; align-items: center; justify-content: space-between; }
.section-heading > span { color: #748887; font-size: 8px; font-weight: 800; }
.section-kicker { margin: 0 0 9px; color: #6e8382; font-size: 8px; font-weight: 900; letter-spacing: .16em; }
.action-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.action-tabs button { min-height: 39px; color: #5d7777; border: 1px solid #ccd7ce; border-radius: 8px; background: white; font-size: 9px; font-weight: 900; }
.action-tabs button b { margin-right: 4px; font-size: 15px; }
.action-tabs button.active { color: white; border-color: var(--deep-2); background: var(--deep-2); }
.action-tabs button:disabled { opacity: .48; }
.instruction { min-height: 54px; margin-top: 9px; padding: 9px; display: flex; align-items: center; gap: 9px; border-radius: 8px; color: #395b5e; background: #e8efe7; }
.instruction > b { flex: 0 0 auto; width: 27px; height: 27px; display: grid; place-items: center; color: white; border-radius: 50%; background: var(--ocean); font: 700 11px Georgia, serif; }
.instruction span { font-size: 9px; font-weight: 800; }
.instruction small { display: block; margin-top: 2px; color: #728584; font-size: 7px; font-weight: 500; line-height: 1.35; }
.secondary-button { width: 100%; margin-top: 8px; padding: 7px; color: #6f5f46; border: 1px solid #dfd0aa; border-radius: 7px; background: #f7edcf; font-size: 8px; font-weight: 800; }
.secondary-button:disabled { opacity: .4; }
.card-row, .market-row { min-height: 77px; display: flex; align-items: center; gap: 7px; overflow-x: auto; scrollbar-width: thin; }
.island-card {
  flex: 0 0 76px;
  width: 76px;
  height: 98px;
  padding: 5px 5px 6px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: color-mix(in srgb, var(--island-color) 72%, #142e40);
  border: 3px solid var(--island-color);
  border-radius: 10px;
  background:
    linear-gradient(155deg, color-mix(in srgb, var(--island-color) 28%, white), rgba(255,255,255,.96) 72%),
    white;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.8), 0 4px 9px rgba(24,54,57,.22);
  transition: .15s;
}
.island-card::before { content: ""; position: absolute; inset: 2px; pointer-events: none; border: 1px dashed color-mix(in srgb, var(--island-color) 55%, white); border-radius: 6px; opacity: .58; }
.mini-map { width: 63px; height: 63px; overflow: visible; border: 1px solid rgba(255,255,255,.7); border-radius: 6px; background: linear-gradient(145deg, #5adce1, #138cbf); box-shadow: inset 0 0 12px rgba(0,63,118,.24); }
.mini-map line { stroke: rgba(5,56,89,.46); stroke-width: .8; stroke-dasharray: .5 1.1; }
.mini-map rect, .mini-map polygon, .mini-map path { fill: rgba(12,89,65,.62); stroke: rgba(244,226,128,.72); stroke-width: .12; }
.mini-map rect.target, .mini-map polygon.target, .mini-map path.target { stroke: white; stroke-width: .28; filter: drop-shadow(0 1px 1px rgba(0,0,0,.48)); }
.island-card b { margin-top: 2px; font: 800 9px Georgia, serif; }
.island-card small { margin-top: 1px; color: #637878; font-size: 5px; font-weight: 900; letter-spacing: .08em; }
.island-card small i { min-width: 11px; height: 11px; padding: 0 2px; font-size: 6px; }
.island-card:hover:not(:disabled), .island-card.selected { transform: translateY(-5px); }
.island-card.selected { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(255,212,71,.42), 0 8px 17px rgba(24,54,57,.25); }
.island-card:disabled { opacity: .58; }
.draw-section { position: relative; }
.draw-section.highlight { background: #fff7d8; box-shadow: inset 4px 0 var(--gold); }
.draw-section.highlight .section-kicker { color: #7a6122; }
.market-row { min-height: 58px; padding-right: 82px; }
.small-card { flex-basis: 59px; width: 59px; height: 72px; padding: 3px; }
.small-card .mini-map { width: 48px; height: 47px; }
.small-card b { font-size: 7px; }
.deck-button { width: 72px; height: 58px; position: absolute; right: 15px; bottom: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: white; border: 2px solid #f3e7ba; border-radius: 7px; background: var(--deep-2); box-shadow: -3px 3px 0 #b4a66e; }
.deck-button span { font-size: 16px; }
.deck-button b { font-size: 6px; }
.deck-button:disabled { opacity: .45; }
.log-section { flex: 1; min-height: 100px; overflow: hidden; border-bottom: 0 !important; }
#gameLog { max-height: 105px; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
#gameLog li { padding: 4px 0 4px 12px; position: relative; color: #647a79; font-size: 8px; line-height: 1.35; }
#gameLog li::before { content: ""; width: 5px; height: 5px; position: absolute; left: 0; top: 8px; border-radius: 50%; background: #9aaba7; }
#gameLog li.important { color: var(--ink); font-weight: 800; }
#gameLog li.important::before { background: var(--gold); }

/* Modals and waiting */
.waiting-overlay { position: fixed; inset: 0; z-index: 100; padding: 18px; display: grid; place-items: center; background: rgba(1,23,29,.8); backdrop-filter: blur(11px); }
.waiting-card { width: min(470px, 100%); padding: clamp(28px, 6vw, 44px); text-align: center; border: 1px solid rgba(255,255,255,.4); border-radius: 23px; background: var(--paper); box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.waiting-emblem { width: 61px; height: 61px; margin: 0 auto 20px; display: grid; place-items: center; color: var(--ocean); border: 2px solid var(--ocean); transform: rotate(45deg); font: 800 25px Georgia, serif; }
.waiting-card h1 { margin: 0; color: var(--deep); font: 800 clamp(28px, 7vw, 39px)/1.04 Georgia, serif; }
.waiting-card > p:not(.eyebrow) { color: #6c7f7d; font: 13px/1.55 Georgia, serif; }
.invite-code { width: 100%; margin: 13px 0 10px; padding: 15px; color: var(--deep); border: 1px dashed #8aa4a1; border-radius: 11px; background: #edf0e8; }
.invite-code span { display: block; font: 900 28px Georgia, serif; letter-spacing: .22em; }
.invite-code small { color: #7d8e8b; font-size: 7px; text-transform: uppercase; letter-spacing: .12em; }
.text-link { display: inline-block; margin-top: 14px; color: var(--ocean); font-size: 10px; font-weight: 800; }
.waiting-dots { height: 18px; margin-top: 18px; display: flex; justify-content: center; align-items: center; gap: 5px; }
.waiting-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--lagoon); animation: dots 1.2s infinite; }
.waiting-dots i:nth-child(2) { animation-delay: .2s; }
.waiting-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dots { 50% { transform: translateY(-6px); opacity: .35; } }
.link-button { display: block; }
.rules-dialog { width: min(510px, calc(100% - 28px)); max-height: calc(100vh - 32px); padding: clamp(25px, 5vw, 40px); color: var(--ink); border: 1px solid rgba(255,255,255,.4); border-radius: 22px; background: var(--paper); box-shadow: var(--shadow); }
.rules-dialog::backdrop { background: rgba(1,22,28,.78); backdrop-filter: blur(9px); }
.dialog-close { position: absolute; right: 12px; top: 12px; width: 34px; height: 34px; color: #5c7776; border: 0; border-radius: 50%; background: #e7ece5; font-size: 21px; }
.rule-list { margin-top: 20px; display: grid; gap: 13px; }
.rule-list article { display: flex; align-items: flex-start; gap: 12px; }
.rule-list article > b { flex: 0 0 30px; height: 30px; display: grid; place-items: center; color: white; border-radius: 50%; background: var(--ocean); font: 700 12px Georgia, serif; }
.rule-list p { margin: 0; color: #657977; font-size: 10px; line-height: 1.45; }
.rule-list strong { display: block; margin-bottom: 2px; color: var(--ink); font: 700 13px Georgia, serif; }
.rule-list mark { padding: 0 4px; color: var(--deep); border-radius: 50%; background: var(--gold); }
.toast { position: fixed; z-index: 300; left: 50%; bottom: 22px; max-width: min(440px, calc(100% - 26px)); padding: 11px 17px; color: white; border-radius: 999px; background: #142f36; box-shadow: 0 9px 25px rgba(0,0,0,.28); font-size: 10px; font-weight: 800; opacity: 0; transform: translate(-50%, 18px); pointer-events: none; transition: .22s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.board.compact .island-label { min-width: 48px; padding: 3px 5px; }
.board.compact .island b { font-size: 8px; }
.board.dense .island-label { min-width: 40px; padding: 2px 4px; }
.board.dense .island b { font-size: 7px; }
.board.dense .island small { font-size: 5px; }

@media (max-width: 930px) {
  .lobby-shell { grid-template-columns: 1fr; max-width: 650px; padding-top: 45px; }
  .lobby-hero { text-align: center; }
  .lobby-hero > p:not(.eyebrow), .steps { margin-left: auto; margin-right: auto; }
  .play-layout { height: auto; grid-template-columns: 1fr; }
  .board-card { height: min(61vh, 590px); min-height: 430px; }
  .control-card { display: grid; grid-template-columns: 1.1fr 1fr; }
  .log-section { display: none; }
  .draw-section { border-bottom: 0 !important; }
}

@media (max-width: 620px) {
  .topbar { height: 59px; padding: 0 10px; }
  .back-link { font-size: 0; }
  .back-link::first-letter { font-size: 20px; }
  .brand span { width: 31px; height: 31px; font-size: 14px; }
  .brand strong { font-size: 12px; }
  .round-button { width: 32px; height: 32px; }
  .lobby-shell { width: calc(100% - 20px); min-height: calc(100vh - 59px); padding: 30px 0; gap: 30px; }
  .lobby-hero h1 { font-size: 44px; }
  .lobby-hero > p:not(.eyebrow) { margin: 17px 0 22px; font-size: 14px; }
  .steps li:not(:last-child)::after { display: none; }
  .steps { gap: 4px; }
  .steps li { flex-direction: column; gap: 6px; text-align: center; }
  .lobby-panel { padding: 22px 17px; border-radius: 18px; }
  .game-shell { width: calc(100% - 10px); margin-top: 4px; }
  .game-heading { height: 60px; padding: 0 2px; }
  .player-chip { max-width: 31%; gap: 5px; }
  .player-chip > span { width: 28px; height: 28px; flex: 0 0 auto; border-width: 2px; font-size: 10px; }
  .player-chip strong { font-size: 10px; }
  .player-chip small { font-size: 7px; }
  .player-chip.me strong::after { display: none; }
  .turn-box { min-width: 126px; padding: 7px 8px; }
  .turn-box small { font-size: 6px; }
  .turn-box strong { font-size: 10px; }
  .board-card { height: 52vh; min-height: 370px; border-radius: 15px; }
  .board-toolbar { min-height: 38px; padding: 0 9px; font-size: 8px; }
  .online-pill { display: none; }
  .board-meta { margin-right: 0; font-size: 6px; }
  .island-label { min-width: 49px; padding: 3px 5px; }
  .island b { font-size: 8px; }
  .bridge-control { width: 39px; height: 39px; }
  .bridge-control.occupied { width: 31px; height: 31px; }
  .control-card { grid-template-columns: 1fr; border-radius: 15px; }
  .control-card section { padding: 12px; }
  .action-section { order: 1; }
  .hand-section { order: 2; }
  .draw-section { order: 3; }
  .waiting-card { padding: 29px 19px; }
}

@media (max-height: 690px) and (min-width: 931px) {
  .play-layout { min-height: 510px; }
  .control-card section { padding-top: 10px; padding-bottom: 10px; }
  .island-card { height: 63px; }
  .card-row { min-height: 66px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
