:root {
  --ink: #173b35;
  --muted: #6b7f79;
  --green: #0e745e;
  --green-dark: #095444;
  --mint: #dff3e9;
  --paper: #fbfaf5;
  --white: #ffffff;
  --red: #ef5b55;
  --red-soft: #f9d2ce;
  --green-piece: #26a874;
  --green-soft: #c9edd9;
  --yellow: #f4c847;
  --yellow-soft: #f9eabc;
  --blue: #4d75d5;
  --blue-soft: #d4def6;
  --line: #dbe3de;
  --shadow: 0 24px 70px rgba(37, 68, 59, .12);
  --radius: 24px;
  --page-background:
    radial-gradient(circle at 75% 5%, rgba(255,255,255,.9), transparent 27rem),
    linear-gradient(135deg, #f8f6ee 0%, #f3f8f0 100%);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--paper); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--page-background);
  overflow-x: hidden;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(14,116,94,.25); outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(2px);
  opacity: .58;
  pointer-events: none;
}
.ambient-one { width: 30rem; height: 30rem; right: -14rem; top: 7rem; background: #d9eee5; }
.ambient-two { width: 26rem; height: 26rem; left: -15rem; bottom: -10rem; background: #f5e8b7; }

.site-header {
  width: min(1240px, calc(100% - 40px));
  height: 76px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.7px;
}
.brand b { color: var(--green); }
.brand-mark {
  width: 38px; height: 38px; padding: 7px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px;
  border-radius: 11px; background: var(--green); box-shadow: 0 6px 15px rgba(14,116,94,.22);
}
.brand-mark i { border-radius: 50%; background: white; }
.brand-mark i:nth-child(2) { background: var(--yellow); }
.brand-mark i:nth-child(3) { background: var(--red); }
.brand-mark i:nth-child(4) { background: #82d6b5; }

.header-tools { display: flex; align-items: center; gap: 9px; }
.creator-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid #dfe9e4;
  border-radius: 999px;
  background: rgba(255,255,255,.55);
  color: var(--ink);
  text-decoration: none;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: -.1px;
  backdrop-filter: blur(8px);
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.creator-link .ui-icon { width: 12px; height: 12px; fill: currentColor; stroke: none; }
.creator-link:hover { transform: translateY(-1px); border-color: #a9c8bb; background: rgba(255,255,255,.9); }
.creator-link:focus-visible { outline: 3px solid rgba(14,116,94,.25); outline-offset: 2px; }

.connection-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 13px;
  border: 1px solid #dfe9e4; border-radius: 999px;
  background: rgba(255,255,255,.72); color: var(--muted); font-size: 12px; font-weight: 700;
  backdrop-filter: blur(8px);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #55b988; box-shadow: 0 0 0 4px rgba(85,185,136,.12); }
.connection-pill.offline .status-dot { background: #d6a54a; box-shadow: 0 0 0 4px rgba(214,165,74,.12); }

main { width: min(1240px, calc(100% - 40px)); margin: 0 auto; }

.welcome-view {
  width: 100%;
  height: min(calc(100dvh - 76px), 720px);
  min-height: 620px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  grid-template-rows: 1fr auto;
  gap: 26px 64px;
  align-items: center;
  padding: 22px 4% 28px;
}

.hero-copy { max-width: 620px; align-self: center; }
.eyebrow {
  margin: 0 0 16px;
  color: var(--green); text-transform: uppercase; letter-spacing: 2.4px; font-weight: 800; font-size: 11px;
}
.eyebrow span { color: #d9a91e; margin-right: 6px; }
.hero-copy h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(50px, 5.3vw, 74px);
  line-height: .97;
  letter-spacing: -4.4px;
  font-weight: 600;
}
.hero-copy h1 em { color: var(--green); font-weight: inherit; }
.hero-copy > p {
  max-width: 555px;
  margin: 20px 0 19px;
  color: var(--muted); font-size: 15px; line-height: 1.65;
}
.hero-points { display: flex; gap: 26px; color: var(--muted); font-size: 12px; }
.hero-points span { display: flex; gap: 5px; align-items: baseline; }
.hero-points b { color: var(--ink); font-size: 15px; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ui-icon { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.download-cluster { width: fit-content; margin-top: 17px; }
.download-edition { width: fit-content; display: inline-flex; align-items: center; gap: 11px; padding: 10px 14px 10px 11px; border: 1px solid #d5e3dc; border-radius: 12px; background: rgba(255,255,255,.7); color: var(--green); text-decoration: none; box-shadow: 0 7px 18px rgba(35,64,56,.06); }
.download-edition > span:first-child { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 9px; background: var(--mint); font-size: 18px; font-weight: 900; }
.download-edition .download-icon .ui-icon { width: 17px; height: 17px; }
.download-edition b,.download-edition small { display: block; }
.download-edition b { font-size: 11px; }
.download-edition small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.download-edition:hover { border-color: #8ab6a5; background: white; transform: translateY(-1px); }
.android-install-note { max-width: 280px; display: block; margin-top: 8px; color: #e4bfc0; font-size: 9px; line-height: 1.45; }
.platform-downloads { position: relative; margin-top: 8px; color: var(--muted); font-size: 10px; }
.platform-downloads summary { width: fit-content; cursor: pointer; list-style: none; font-weight: 750; }
.platform-downloads summary::-webkit-details-marker { display: none; }
.platform-downloads summary::after { content: ' +'; color: var(--green); }
.platform-downloads[open] summary::after { content: ' −'; }
.platform-download-menu { position: absolute; z-index: 8; width: 292px; margin-top: 8px; padding: 10px 14px; border: 1px solid #d8e3dd; border-radius: 13px; background: rgba(255,255,255,.98); box-shadow: 0 15px 35px rgba(35,64,56,.14); }
.platform-download-menu p { display: flex; justify-content: space-between; gap: 18px; margin: 0; padding: 8px 0; border-bottom: 1px solid #edf1ee; }
.platform-download-menu p:last-child { border: 0; }
.platform-download-menu span { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 11px; }
.platform-download-menu a { color: var(--green); font-weight: 750; text-decoration: none; }
.platform-download-menu a:hover { text-decoration: underline; }
.platform-download-menu .source-download { color: #87968f; }

.room-card {
  position: relative;
  width: 100%;
  padding: 28px;
  border: 1px solid rgba(212,222,216,.95);
  border-radius: 28px;
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(16px);
}
.card-accent { position: absolute; left: 0; top: 0; width: 100%; height: 5px; background: linear-gradient(90deg,var(--red) 0 25%,var(--green-piece) 25% 50%,var(--yellow) 50% 75%,var(--blue) 75%); }
.card-kicker { margin: 0 0 7px; color: var(--muted); text-transform: uppercase; font-size: 10px; font-weight: 800; letter-spacing: 1.8px; }
.room-card h2 { margin: 0; font-family: Georgia, serif; font-size: 29px; letter-spacing: -1px; }

.tab-list { display: grid; grid-template-columns: 1fr 1fr; margin: 19px 0 18px; padding: 4px; background: #f2f5f1; border-radius: 12px; }
.tab { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 9px; background: transparent; padding: 11px; color: var(--muted); font-size: 12px; font-weight: 800; cursor: pointer; }
.tab .ui-icon { width: 15px; height: 15px; }
.tab.active { background: white; color: var(--green); box-shadow: 0 3px 12px rgba(35,64,56,.08); }

.room-form label { display: block; margin: 0 0 7px; color: #425d56; font-size: 11px; font-weight: 800; }
.input-shell { height: 49px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid var(--line); border-radius: 11px; background: #fcfdfb; transition: border-color .2s, box-shadow .2s; }
.input-shell:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(14,116,94,.09); }
.input-shell svg { width: 19px; fill: none; stroke: #90a29d; stroke-width: 1.8; }
.input-shell input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.input-shell input::placeholder { color: #a2aea9; }

.player-profile-setup { display: grid; gap: 11px; margin-top: 13px; }
.color-picker { min-width: 0; margin: 0; padding: 0; border: 0; }
.color-picker legend { margin-bottom: 7px; color: #425d56; font-size: 11px; font-weight: 800; }
.color-options { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px; }
.color-options label { min-width: 0; min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 5px; margin: 0; padding: 6px 4px; border: 1px solid #dbe3de; border-radius: 10px; background: #fff; color: #72817c; cursor: pointer; transition: border-color .16s,box-shadow .16s,background .16s; }
.color-options input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.color-options label > span { width: 14px; height: 14px; flex: 0 0 auto; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px #cbd6d1; }
.color-options label.red > span { background: var(--red); }
.color-options label.green > span { background: var(--green-piece); }
.color-options label.yellow > span { background: var(--yellow); }
.color-options label.blue > span { background: var(--blue); }
.color-options label > b { overflow: hidden; text-overflow: ellipsis; font-size: 8px; white-space: nowrap; }
.color-options label:has(input:checked) { border-color: var(--green); background: #f1faf6; color: var(--ink); box-shadow: 0 0 0 2px rgba(14,116,94,.09); }
.color-options label:has(input:focus-visible) { outline: 3px solid rgba(14,116,94,.18); outline-offset: 1px; }
.photo-picker { position: relative; }
.photo-picker > label { min-height: 50px; display: grid; grid-template-columns: 36px minmax(0,1fr) 24px; align-items: center; gap: 10px; margin: 0; padding: 6px 9px; border: 1px dashed #cbd9d3; border-radius: 11px; background: #f9fbf8; cursor: pointer; }
.photo-picker > label:hover { border-color: #7daf9c; background: #f3faf6; }
.photo-preview { width: 36px; height: 36px; display: grid; place-items: center; overflow: hidden; border-radius: 10px; background: linear-gradient(145deg,#d9eee5,#b9dccd); color: #155b4c; font-family: Georgia,serif; font-size: 16px; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-picker label > span:nth-child(2) { min-width: 0; }
.photo-picker label > span:nth-child(2) > b,.photo-picker label > span:nth-child(2) > small { display: block; }
.photo-picker label > span:nth-child(2) > b { color: var(--ink); font-size: 10px; }
.photo-picker label > span:nth-child(2) > small { margin-top: 2px; color: #87958f; font-size: 8px; }
.photo-picker label > i { color: var(--green); font-size: 17px; font-style: normal; text-align: center; }
.photo-picker.has-photo > label { border-style: solid; border-color: #a7cbbd; background: #f1f9f5; }
.photo-remove { position: absolute; right: -6px; top: -6px; z-index: 2; width: 24px; height: 24px; display: grid; place-items: center; border: 2px solid white; border-radius: 50%; background: #244a41; color: white; cursor: pointer; font-size: 15px; line-height: 1; }

.primary-button, .roll-button {
  width: 100%; min-height: 50px; margin-top: 16px; padding: 0 18px;
  border: 0; border-radius: 11px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--green); color: white; font-weight: 800; font-size: 13px;
  cursor: pointer; box-shadow: 0 8px 18px rgba(14,116,94,.2); transition: transform .15s, background .15s;
}
.primary-button-label { min-width: 0; display: inline-flex; align-items: center; gap: 8px; }
.primary-button .ui-icon { width: 17px; height: 17px; }
.primary-button .button-trailing { width: 16px; height: 16px; opacity: .78; }
.primary-button:hover, .roll-button:hover:not(:disabled) { background: var(--green-dark); transform: translateY(-1px); }
.primary-button:disabled, .roll-button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.form-hint { margin: 12px 0 0; text-align: center; color: #98a6a1; font-size: 10px; }
.form-error { min-height: 16px; margin: 12px 0 -6px; color: #bd3e3a; text-align: center; font-size: 11px; font-weight: 700; }

.native-shell .download-cluster { display: none; }
.native-shell .site-header {
  height: calc(70px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
}
.native-shell main { padding-bottom: env(safe-area-inset-bottom); }
.native-connection {
  min-height: 52px;
  margin-top: 14px;
  display: grid;
  grid-template-columns: 34px minmax(0,1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border: 1px solid #dce7e1;
  border-radius: 13px;
  background: #f5f9f6;
}
.native-connection-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--mint);
  color: var(--green);
}
.native-connection-icon svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.native-connection small,.native-connection b { display: block; }
.native-connection small { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .7px; text-transform: uppercase; }
.native-connection b { margin-top: 2px; overflow: hidden; color: var(--ink); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.native-connection > button {
  min-width: 64px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid #cdded6;
  border-radius: 10px;
  background: white;
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
}

.code-inputs { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-bottom: 17px; }
.code-inputs input { min-width: 0; height: 52px; border: 1px solid var(--line); border-radius: 11px; background: #fcfdfb; color: var(--ink); text-align: center; text-transform: uppercase; font-weight: 900; font-size: 22px; outline: 0; }
.code-inputs input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(14,116,94,.09); }

.network-guide { grid-column: 1 / -1; display: flex; align-items: center; gap: 13px; justify-self: center; color: var(--muted); }
.guide-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: white; box-shadow: 0 5px 15px rgba(35,64,56,.08); }
.guide-icon svg { width: 19px; fill: none; stroke: var(--green); stroke-width: 1.7; stroke-linecap: round; }
.network-guide div { display: flex; flex-direction: column; gap: 3px; font-size: 10px; }
.network-guide b { color: var(--ink); font-size: 11px; }

/* Game screen */
.game-view { padding: 5px 0 28px; }
.game-topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-bottom: 14px; }
.eyebrow.compact { margin: 0 0 5px; font-size: 9px; }
.room-code-button { display: inline-flex; align-items: center; gap: 8px; border: 0; padding: 0; background: transparent; cursor: pointer; font-weight: 900; letter-spacing: 4px; font-size: 19px; }
.room-code-button svg, .network-address svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.game-heading { text-align: center; }
.game-heading p { margin: 0 0 4px; color: var(--muted); text-transform: uppercase; font-size: 9px; font-weight: 900; letter-spacing: 1.8px; }
.game-heading h1 { margin: 0; font-family: Georgia, serif; font-size: 25px; letter-spacing: -.5px; }
.game-actions { justify-self: end; display: flex; gap: 8px; }
.ghost-button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: rgba(255,255,255,.66); color: var(--muted); white-space: nowrap; font-size: 10px; font-weight: 800; cursor: pointer; }
.ghost-button .ui-icon { width: 14px; height: 14px; }
.ghost-button:hover { border-color: #b9c9c2; color: var(--green); }
.ghost-button.muted { color: #a35b57; background: #fff7f5; }
.ghost-button.danger { color: #a34f49; border-color: #ebd1cd; background: rgba(255,248,246,.8); }
.ghost-button.danger:hover { color: #8f332e; border-color: #dca8a2; background: #fff3f0; }
.camera-button.live,.microphone-button.live { color: #0a7259; border-color: #8bc8b1; background: #edf9f4; }
.camera-button.busy,.microphone-button.busy { opacity: .62; cursor: wait; }

.game-layout { display: grid; grid-template-columns: 220px minmax(440px,650px) 230px; gap: 18px; align-items: start; justify-content: center; }
.panel { border: 1px solid rgba(215,224,218,.9); border-radius: 20px; background: rgba(255,255,255,.86); box-shadow: 0 15px 45px rgba(37,68,59,.08); backdrop-filter: blur(12px); }
.players-panel { padding: 18px 15px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; padding: 0 2px 16px; border-bottom: 1px solid #edf0ed; }
.panel-heading h2, .turn-status h2 { margin: 0; font-family: Georgia, serif; font-size: 21px; }
.count-badge { padding: 5px 8px; border-radius: 999px; background: #edf5f1; color: var(--green); font-size: 10px; font-weight: 900; }
.players-list { padding: 8px 0 3px; }
.player-row { position: relative; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 9px; min-height: 50px; padding: 6px 3px; border-bottom: 1px solid #f0f2f0; }
.player-row:last-child { border-bottom: 0; }
.player-token { width: 31px; height: 31px; display: grid; place-items: center; overflow: hidden; border: 3px solid white; border-radius: 50%; color: white; font-family: Georgia,serif; font-weight: 900; box-shadow: 0 2px 8px rgba(25,45,39,.16), inset 0 -3px 4px rgba(0,0,0,.12); text-transform: uppercase; }
.player-token img { width: 100%; height: 100%; display: block; object-fit: cover; }
.player-row.red .player-token { background: var(--red); }
.player-row.green .player-token { background: var(--green-piece); }
.player-row.yellow .player-token { background: var(--yellow); color: #59450b; }
.player-row.blue .player-token { background: var(--blue); }
.player-info b { display: block; max-width: 105px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.player-info span { color: #94a29e; text-transform: capitalize; font-size: 9px; }
.host-badge { padding: 3px 6px; border-radius: 5px; background: #f0f3f1; color: #82908b; font-size: 8px; font-weight: 900; text-transform: uppercase; }
.active-turn::before { content: ''; position: absolute; left: -18px; top: 14px; width: 3px; height: 28px; border-radius: 0 4px 4px 0; background: currentColor; }
.player-row.red { color: var(--red); }.player-row.green { color: var(--green-piece); }.player-row.yellow { color: #bd951d; }.player-row.blue { color: var(--blue); }
.player-info, .host-badge { color: var(--ink); }
.empty-seat { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 5px 3px; color: #a3afab; font-size: 10px; }
.empty-seat i { width: 30px; height: 30px; border: 1px dashed #cbd4d0; border-radius: 50%; }

.lobby-action { margin-top: 14px; }
.lobby-action .primary-button { margin: 0; }
.configure-rules-button { width: 100%; min-height: 39px; display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 8px; margin-top: 7px; padding: 0 12px; border: 1px solid #dce7e2; border-radius: 10px; background: #f7faf8; color: var(--green); text-align: left; cursor: pointer; }
.configure-rules-button:hover { border-color: #a9cdbd; background: #eef8f3; }
.configure-rules-button span { font-size: 9px; font-weight: 900; }
.configure-rules-button i { font-style: normal; font-weight: 900; }
.waiting-message { margin: 0; padding: 13px; border-radius: 10px; background: #f2f7f4; color: var(--muted); font-size: 10px; line-height: 1.5; text-align: center; }
.network-address { margin-top: 16px; padding-top: 15px; border-top: 1px solid #edf0ed; }
.network-address > span { display: block; margin-bottom: 6px; color: #9aa8a3; text-transform: uppercase; font-size: 8px; letter-spacing: 1.2px; font-weight: 900; }
.network-address button { width: 100%; display: flex; justify-content: space-between; gap: 6px; align-items: center; border: 0; padding: 0; color: var(--green); background: transparent; font-size: 9px; font-weight: 800; cursor: pointer; }
.network-address button span { overflow: hidden; text-overflow: ellipsis; }

.board-column { min-width: 0; }
.board-frame {
  position: relative;
  isolation: isolate;
  padding: 12px;
  border: 1px solid rgba(199,213,205,.92);
  border-radius: 23px;
  background: linear-gradient(145deg,rgba(255,255,255,.98),rgba(235,242,238,.9));
  box-shadow:
    0 30px 74px rgba(24,57,48,.15),
    0 8px 0 rgba(37,72,62,.06),
    inset 0 1px 0 rgba(255,255,255,.95);
}
.board-frame::before {
  content: '';
  position: absolute;
  z-index: 8;
  inset: 12px;
  border-radius: 13px;
  background:
    linear-gradient(118deg,rgba(255,255,255,.34) 0%,rgba(255,255,255,.11) 18%,transparent 34%,transparent 70%,rgba(255,255,255,.09) 100%),
    radial-gradient(ellipse at 18% 5%,rgba(255,255,255,.28),transparent 31%),
    linear-gradient(180deg,rgba(255,255,255,.05),rgba(24,56,48,.035));
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.5),
    inset 0 0 28px rgba(255,255,255,.08);
  pointer-events: none;
}
.board-frame::after {
  content: '';
  position: absolute;
  z-index: 9;
  inset: 6px;
  border: 1px solid rgba(255,255,255,.74);
  border-radius: 18px;
  box-shadow: inset 0 0 0 1px rgba(36,70,61,.06);
  pointer-events: none;
}
.ludo-board { position: relative; z-index: 1; width: 100%; aspect-ratio: 1; overflow: hidden; border-radius: 12px; background: #fbfcf9; border: 2px solid #294d44; box-shadow: inset 0 0 28px rgba(34,66,57,.05); }
.base {
  position: absolute;
  width: 40%;
  height: 40%;
  padding: 1.35%;
  overflow: hidden;
  border: clamp(4px,.62vw,9px) solid;
  background: #f7f7f2;
  box-shadow: inset 0 0 0 1px rgba(30,46,41,.22);
}
.base.red { left: 0; top: 0; border-color: var(--red); background: #f9dedb; }
.base.green { right: 0; top: 0; border-color: var(--green-piece); background: #d8eee3; }
.base.blue { left: 0; bottom: 0; border-color: var(--blue); background: #dbe3f5; }
.base.yellow { right: 0; bottom: 0; border-color: var(--yellow); background: #faedbd; }
.base-nest {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 1px solid rgba(27,47,40,.42);
  border-radius: 2%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18%;
  padding: 16%;
  background:
    linear-gradient(rgba(255,255,255,.88),rgba(255,255,255,.88)),
    repeating-linear-gradient(45deg,transparent 0 12px,rgba(24,61,51,.035) 12px 13px);
  box-shadow: inset 0 0 22px rgba(25,53,45,.08);
}
.base-photo { position: absolute; z-index: 0; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: saturate(.92) contrast(1.02); }
.base-nest.has-photo::after { content: ''; position: absolute; z-index: 0; inset: 0; background: linear-gradient(180deg,rgba(10,34,28,0) 54%,rgba(10,34,28,.3)); pointer-events: none; }
.base-nest.has-photo .nest-spot { opacity: 0; }
.base.occupied::after {
  content: attr(data-player-name);
  position: absolute;
  z-index: 3;
  left: 4%;
  bottom: 4%;
  max-width: 70%;
  overflow: hidden;
  padding: 3px 6px;
  border: 1px solid rgba(255,255,255,.48);
  border-radius: 4px;
  background: rgba(18,43,36,.72);
  color: #fff;
  font-size: clamp(5px,.72vw,10px);
  font-weight: 900;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 1px rgba(0,0,0,.24);
  pointer-events: none;
}
.nest-spot { position: relative; z-index: 1; border-radius: 50%; background: rgba(255,255,255,.76); border: 1px solid rgba(38,62,54,.18); box-shadow: 0 2px 7px rgba(16,48,39,.12); }
.board-cell { position: absolute; width: calc(100% / 15); height: calc(100% / 15); border: .75px solid rgba(44,54,50,.62); background: #fffefa; display: grid; place-items: center; box-shadow: inset 0 0 0 .5px rgba(255,255,255,.7); }
.board-cell.lane-red, .board-cell.start-red { background: var(--red); }.board-cell.lane-green, .board-cell.start-green { background: var(--green-piece); }
.board-cell.lane-yellow, .board-cell.start-yellow { background: var(--yellow); }.board-cell.lane-blue, .board-cell.start-blue { background: var(--blue); }
.board-cell.safe::after { content: '✦'; color: rgba(255,255,255,.92); font-size: clamp(7px, 1.2vw, 14px); text-shadow: 0 1px 1px rgba(0,0,0,.15); }
.board-cell.neutral-safe::after { content: '✦'; color: #afbab6; font-size: clamp(7px, 1.2vw, 14px); }
.board-cell.flow-arrow::after {
  content: attr(data-arrow);
  color: #46524e;
  font-family: ui-sans-serif,system-ui,sans-serif;
  font-size: clamp(7px,1.12vw,16px);
  font-weight: 950;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255,255,255,.7);
}
.center-home {
  position: absolute;
  left: 40%;
  top: 40%;
  width: 20%;
  height: 20%;
  border: 1px solid #294d44;
  background: conic-gradient(from -45deg, var(--green-piece) 0 25%, var(--yellow) 0 50%, var(--blue) 0 75%, var(--red) 0);
  clip-path: none;
}
.center-home::after {
  content: '🏁';
  position: absolute;
  inset: 28%;
  display: grid;
  place-items: center;
  border: 2px solid #315148;
  border-radius: 50%;
  background: linear-gradient(145deg,#fffefb,#eef3ef);
  color: #173f35;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.92),0 2px 7px rgba(8,43,36,.26);
  font-size: clamp(8px,1.18vw,16px);
  line-height: 1;
}

.piece { position: absolute; z-index: 5; width: 5.3%; aspect-ratio: 1; border: clamp(1px,.3vw,3px) solid rgba(255,255,255,.92); border-radius: 50%; transform: translate(-50%,-50%); cursor: default; box-shadow: 0 2px 0 rgba(18,35,30,.28),0 4px 7px rgba(23,44,38,.24),inset 0 -2px 2px rgba(0,0,0,.12); transition: left .28s ease, top .28s ease, transform .18s; }
.piece::after { content: ''; position: absolute; width: 28%; height: 20%; left: 24%; top: 17%; border-radius: 50%; background: rgba(255,255,255,.4); transform: rotate(-25deg); }
.piece.red { background: var(--red); }.piece.green { background: var(--green-piece); }.piece.yellow { background: var(--yellow); }.piece.blue { background: var(--blue); }
.piece.movable { cursor: pointer; animation: piecePulse 1.25s infinite; }
.piece.movable:hover { transform: translate(-50%,-50%) scale(1.18); }
@keyframes piecePulse { 0%,100% { box-shadow: 0 2px 5px rgba(23,44,38,.34),0 0 0 0 rgba(14,116,94,.28); } 50% { box-shadow: 0 2px 5px rgba(23,44,38,.34),0 0 0 7px rgba(14,116,94,0); } }

.turn-panel { padding: 18px 15px; }
.turn-status { display: flex; align-items: center; gap: 11px; padding-bottom: 17px; border-bottom: 1px solid #edf0ed; }
.turn-color-dot { width: 12px; height: 12px; border: 3px solid white; border-radius: 50%; background: #adb9b5; box-shadow: 0 0 0 1px #d8dfdc; }
.turn-status p { margin: 0 0 3px; color: #99a5a1; text-transform: uppercase; font-size: 8px; letter-spacing: 1px; font-weight: 900; }
.turn-status.red .turn-color-dot { background: var(--red); }.turn-status.green .turn-color-dot { background: var(--green-piece); }.turn-status.yellow .turn-color-dot { background: var(--yellow); }.turn-status.blue .turn-color-dot { background: var(--blue); }
.dice-stage { position: relative; min-height: 142px; padding: 19px 0 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.dice { width: 68px; height: 68px; display: grid; grid-template: repeat(3,1fr)/repeat(3,1fr); gap: 5px; padding: 10px; border: 1px solid #d5ded9; border-radius: 16px; background: white; box-shadow: 0 8px 18px rgba(32,61,53,.12); transform: rotate(-2deg); }
.pip { align-self: center; justify-self: center; width: 9px; height: 9px; border-radius: 50%; background: var(--ink); }
.dice.rolling { animation: diceRoll .48s ease; }
@keyframes diceRoll { 0% { transform: rotate(-2deg) scale(1); } 40% { transform: rotate(22deg) scale(.85); } 75% { transform: rotate(-14deg) scale(1.09); } 100% { transform: rotate(-2deg) scale(1); } }
.dice-stage p { margin: 14px 0 0; color: #98a6a1; font-size: 9px; }
.roll-series { max-width: 100%; display: flex; align-items: center; justify-content: center; gap: 5px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.roll-series::-webkit-scrollbar { display: none; }
.roll-chip { position: relative; min-width: 28px; height: 27px; display: grid; place-items: center; border: 1px solid #d6e0db; border-radius: 8px; background: #f8faf8; color: #70807a; font-size: 10px; font-weight: 900; }
.roll-chip > i { position: absolute; right: -3px; top: -5px; min-width: 14px; height: 14px; display: grid; place-items: center; border-radius: 7px; background: #dfe7e3; color: #63736d; font-size: 6px; font-style: normal; }
.roll-chip.active { border-color: var(--green); background: #e8f6ef; color: var(--green); box-shadow: 0 0 0 2px rgba(14,116,94,.1); }
.roll-chip.active > i { background: var(--green); color: white; }
.roll-chip.done { border-color: #dce3df; background: #edf1ef; color: #a1ada8; text-decoration: line-through; }
.roll-button { margin-top: 0; justify-content: center; gap: 9px; }
.turn-controls { min-width: 0; }
.mini-die { width: 18px; height: 18px; }
.roll-button kbd { margin-left: 5px; padding: 3px 6px; border: 1px solid rgba(255,255,255,.38); border-bottom-width: 2px; border-radius: 5px; background: rgba(255,255,255,.12); color: white; font: 800 8px/1 system-ui,sans-serif; }
.count-sixes-button { width: 100%; min-height: 38px; margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid #80bca7; border-radius: 10px; background: #e8f6ef; color: var(--green); font-size: 9px; font-weight: 900; cursor: pointer; }
.count-sixes-button:hover { border-color: var(--green); background: #dff2e8; }
.count-sixes-button:disabled { cursor: wait; opacity: .55; }
.undo-button { width: 100%; min-height: 38px; margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid #d7e2dd; border-radius: 10px; background: #f7faf8; color: var(--green); font-size: 9px; font-weight: 900; cursor: pointer; }
.undo-button:hover { border-color: #8ab6a5; background: #edf7f2; }
.undo-button:disabled { cursor: wait; opacity: .55; }
.move-hint { min-height: 30px; margin: 10px 0 5px; color: var(--muted); text-align: center; font-size: 9px; line-height: 1.55; }
.activity { margin-top: 12px; padding-top: 12px; border-top: 1px solid #edf0ed; }
.activity-heading { display: flex; justify-content: space-between; align-items: center; }
.activity-heading h3 { margin: 0; font-size: 10px; text-transform: uppercase; letter-spacing: .9px; }
.activity-heading span { color: #72a890; font-size: 8px; font-weight: 900; }
.game-log { max-height: 172px; margin: 10px 0 0; padding: 0; list-style: none; overflow: auto; scrollbar-width: thin; }
.game-log li { position: relative; margin: 0; padding: 7px 0 7px 14px; border-bottom: 1px solid #f1f3f1; color: #768681; font-size: 9px; line-height: 1.4; }
.game-log li::before { content: ''; position: absolute; left: 1px; top: 12px; width: 5px; height: 5px; border-radius: 50%; background: #c2ccc8; }
.game-log li.capture::before,.game-log li.start-kick::before,.game-log li.forward-kick::before,.game-log li.back-kick::before,.game-log li.line-kick::before,.game-log li.home-kick::before { background: var(--red); }.game-log li.winner::before { background: var(--yellow); }.game-log li.turn::before,.game-log li.success::before { background: var(--green-piece); }
.mobile-turn-card { display: none; }

.camera-rail { position: fixed; z-index: 18; right: 18px; bottom: 18px; width: 238px; max-height: calc(100vh - 36px); padding: 10px; overflow: auto; border-radius: 18px; box-shadow: 0 18px 55px rgba(25,57,48,.2); transition: width .2s ease,box-shadow .2s ease; }
.camera-rail[data-count="2"],.camera-rail[data-count="3"],.camera-rail[data-count="4"] { width: min(430px,calc(100vw - 36px)); }
.camera-rail-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; padding: 1px 2px 9px; border-bottom: 1px solid #edf0ed; }
.camera-rail-heading > div { min-width: 0; display: flex; align-items: center; gap: 7px; }
.camera-rail-heading > div > i { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #55b988; box-shadow: 0 0 0 3px rgba(85,185,136,.12); }
.camera-rail-heading h2 { margin: 0; font-family: Georgia,serif; font-size: 16px; line-height: 1; }
.camera-rail-heading span { color: #72a890; white-space: nowrap; font-size: 8px; font-weight: 900; }
.camera-rail-heading button { width: 28px; height: 28px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid #dce5e0; border-radius: 9px; background: rgba(255,255,255,.82); color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; }
.camera-rail.collapsed { width: auto; padding: 7px 8px; overflow: hidden; }
.camera-rail.collapsed .camera-rail-heading { margin: 0; padding: 0; border: 0; }
.camera-rail.collapsed .video-grid { display: none; }
.video-grid { width: 100%; min-width: 0; display: grid; grid-template-columns: minmax(0,1fr); justify-content: center; gap: 10px; }
.camera-rail[data-count="2"] .video-grid,.camera-rail[data-count="3"] .video-grid,.camera-rail[data-count="4"] .video-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.video-grid:empty { display: none; }
.camera-tile { position: relative; width: 100%; min-width: 0; max-width: 100%; margin: 0; aspect-ratio: 16/10; overflow: hidden; border: 2px solid var(--tile-color,#aab8b3); border-radius: 15px; background: #18332d; box-shadow: 0 8px 20px rgba(22,53,45,.18); transition: box-shadow .2s ease; }
.media-avatar { position: absolute; z-index: 1; inset: 0; display: none; place-items: center; background: radial-gradient(circle at 50% 38%,color-mix(in srgb,var(--tile-color) 52%,#f6faf7),color-mix(in srgb,var(--tile-color) 58%,#173b35)); color: white; font-family: Georgia,serif; font-size: clamp(38px,8vw,68px); font-weight: 900; text-shadow: 0 3px 15px rgba(5,25,20,.28); }
.camera-tile video { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center 62%; background: #18332d; transform: scale(1.12); transition: transform .25s ease; }
.camera-tile.local video { transform: scaleX(-1) scale(1.12); }
.camera-tile.audio-only .media-avatar { display: grid; }
.camera-tile.audio-only video { opacity: 0; }
.camera-tile.audio-only .camera-expand { display: none; }
.camera-tile figcaption { position: absolute; z-index: 2; inset: auto 0 0; display: flex; align-items: center; justify-content: space-between; gap: 7px; min-height: 38px; padding: 13px 11px 8px; background: linear-gradient(transparent,rgba(7,28,23,.9)); color: white; font-size: 10px; font-weight: 800; }
.camera-tile figcaption .media-status { display: flex; align-items: center; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.media-status i { color: #a9f1d2; font-size: 8px; font-style: normal; font-weight: 900; }
.media-status .video-indicator { color: #d8e6e1; }
.camera-expand { position: absolute; z-index: 4; top: 8px; right: 8px; width: 29px; height: 29px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.4); border-radius: 9px; background: rgba(8,31,26,.65); color: white; font-size: 15px; line-height: 1; cursor: pointer; backdrop-filter: blur(5px); opacity: .78; }
.camera-expand:hover,.camera-expand:focus-visible { opacity: 1; background: rgba(8,31,26,.86); }
.camera-tile.waiting::after { content: attr(data-status); position: absolute; z-index: 1; inset: 0; display: grid; place-items: center; padding: 15px; background: linear-gradient(135deg,rgba(18,55,47,.82),rgba(24,51,45,.92)); color: #d3e2dd; text-align: center; font-size: 10px; font-weight: 800; }
.camera-tile.play-blocked { cursor: pointer; }
.camera-live-mark,.microphone-live-mark,.labourer-mark { margin-left: 4px; color: var(--green); font-size: 9px; font-style: normal; }
.microphone-live-mark { color: #178a70; }
.labourer-mark { color: #9a6b10; }
.camera-focus { position: fixed; z-index: 45; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(8,31,26,.72); backdrop-filter: blur(8px); }
.camera-focus-card { position: relative; width: min(760px,calc(100vw - 32px)); aspect-ratio: 16/10; overflow: hidden; border: 3px solid var(--focus-color,#6cdeb0); border-radius: 24px; background: #173b35; box-shadow: 0 32px 95px rgba(5,25,20,.5); }
.camera-focus video { width: 100%; height: 100%; display: block; object-fit: contain; background: #173b35; }
.camera-focus.local video { transform: scaleX(-1); }
.camera-focus-card > p { position: absolute; inset: 0; display: none; place-items: center; margin: 0; color: #d7e5e0; font-size: 13px; font-weight: 800; }
.camera-focus.waiting .camera-focus-card > p { display: grid; }
.camera-focus-card > button { position: absolute; z-index: 3; right: 14px; top: 14px; width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.45); border-radius: 12px; background: rgba(8,31,26,.72); color: white; font-size: 27px; line-height: 1; cursor: pointer; backdrop-filter: blur(5px); }
.camera-focus-caption { position: absolute; inset: auto 0 0; display: flex; align-items: center; justify-content: space-between; padding: 34px 20px 16px; background: linear-gradient(transparent,rgba(5,25,20,.92)); color: white; font-size: 14px; }
.camera-focus-caption > span { display: flex; align-items: center; gap: 7px; font-size: 10px; font-weight: 900; }
.camera-focus-caption i { width: 7px; height: 7px; border-radius: 50%; background: #6cdeb0; box-shadow: 0 0 0 4px rgba(108,222,176,.14); }

.toast { position: fixed; z-index: 30; left: 50%; bottom: 24px; transform: translate(-50%,20px); max-width: min(90vw,400px); padding: 11px 16px; border-radius: 10px; background: #173b35; color: white; box-shadow: 0 10px 30px rgba(20,50,43,.25); font-size: 11px; font-weight: 700; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.toast.error { background: #a8423e; }
.toast.kick { bottom: 34px; padding: 15px 21px; border: 2px solid rgba(255,255,255,.35); background: linear-gradient(135deg,#b9443d,#df6b47); font-family: Georgia,serif; font-size: 14px; box-shadow: 0 14px 38px rgba(120,43,35,.32); animation: kickToast .38s ease both; }
@keyframes kickToast { 0% { opacity: 0; transform: translate(-50%,24px) scale(.82) rotate(-2deg); } 70% { transform: translate(-50%,-3px) scale(1.04) rotate(1deg); } 100% { opacity: 1; transform: translate(-50%,0) scale(1); } }

.modal-backdrop { position: fixed; z-index: 25; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(15,43,36,.55); backdrop-filter: blur(7px); }
.modal-card { position: relative; width: min(100%,540px); max-height: min(88vh,720px); overflow: auto; padding: 30px; border: 1px solid rgba(255,255,255,.45); border-radius: 24px; background: #fffef9; box-shadow: 0 28px 80px rgba(10,38,31,.3); }
.modal-card h2 { margin: 0; font-family: Georgia,serif; font-size: 31px; letter-spacing: -.8px; }
.modal-close { position: absolute; right: 18px; top: 17px; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: white; color: var(--muted); font-size: 21px; cursor: pointer; }
.modal-intro { margin: 9px 0 21px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.native-server-card { width: min(100%,500px); }
.android-host-panel { margin: 0 0 18px; padding: 15px; border: 1px solid #add9c7; background: #f3fbf7; }
.android-host-heading { display: grid; grid-template-columns: 38px minmax(0,1fr) auto; align-items: center; gap: 11px; }
.android-host-heading .card-kicker { margin: 0 0 2px; }
.android-host-heading h3 { margin: 0; color: var(--ink); font-size: 13px; }
.android-host-badge { padding: 5px 8px; border-radius: 999px; background: #e3ebe7; color: #6b7f78; font-size: 8px; font-weight: 900; text-transform: uppercase; letter-spacing: .5px; }
.android-host-panel.running { border-color: #61b995; background: #effaf5; box-shadow: inset 3px 0 0 var(--green); }
.android-host-panel.running .android-host-badge { background: #d7f2e5; color: var(--green); }
.android-host-description { margin: 11px 0 13px; color: var(--muted); font-size: 9px; line-height: 1.55; }
.android-host-address { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; padding: 8px 9px 8px 11px; border: 1px solid #d5e7df; background: white; }
.android-host-address span { min-width: 0; }
.android-host-address small,.android-host-address b { display: block; }
.android-host-address small { margin-bottom: 3px; color: #82948d; font-size: 8px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; }
.android-host-address b { overflow: hidden; color: var(--green); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.android-host-address button,.android-host-stop { min-width: 58px; min-height: 38px; border: 1px solid #bfd7cd; background: #f9fcfa; color: var(--green); font-size: 9px; font-weight: 900; cursor: pointer; }
.android-host-actions { display: flex; gap: 8px; }
.android-host-actions .primary-button { min-height: 46px; flex: 1; }
.android-host-stop { min-width: 105px; color: #a34d47; border-color: #e4c4c0; background: #fff8f6; }
.android-host-error { margin: 9px 0 0; text-align: left; }
.native-online-choice {
  width: 100%;
  min-height: 64px;
  display: grid;
  grid-template-columns: 38px minmax(0,1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid #b9d9ca;
  border-radius: 14px;
  background: #f0f9f5;
  color: var(--green);
  text-align: left;
  cursor: pointer;
}
.native-online-choice > span:nth-child(2) b,.native-online-choice > span:nth-child(2) small { display: block; }
.native-online-choice b { font-size: 12px; }
.native-online-choice small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.native-choice-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--green); color: white; font-size: 20px; }
.native-choice-divider { display: flex; align-items: center; gap: 10px; margin: 17px 0; color: #93a19c; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; }
.native-choice-divider::before,.native-choice-divider::after { content: ''; height: 1px; flex: 1; background: #e2e9e5; }
.native-lan-form label { display: block; margin-bottom: 7px; color: #425d56; font-size: 11px; font-weight: 800; }
.native-lan-help { margin: 8px 2px 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.native-server-error { margin-bottom: 0; text-align: left; }
.native-lan-form .primary-button { min-height: 48px; }
@media (max-width: 520px) {
  .native-server-card { padding: 22px 18px; }
  .android-host-panel { padding: 13px; }
  .android-host-actions { flex-direction: column; }
  .android-host-actions button { width: 100%; min-height: 44px; }
}
.rules-modal-card { width: min(100%,820px); max-height: min(90vh,820px); }
.rules-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-right: 35px; }
.rules-mode { flex: 0 0 auto; padding: 7px 10px; border: 1px solid #dce6e1; border-radius: 999px; background: #f3f6f4; color: #667d76; font-size: 8px; font-weight: 900; letter-spacing: .7px; text-transform: uppercase; }
.rules-mode.editable { border-color: #a8d9c5; background: #eaf8f1; color: var(--green); }
.rule-options { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.rule-group { min-width: 0; }
.rule-group:first-child,.rule-group:last-child { grid-column: 1 / -1; }
.rule-group h3 { margin: 0 0 7px; color: #6f827c; font-size: 8px; font-weight: 900; letter-spacing: 1.5px; text-transform: uppercase; }
.rule-group-list { display: grid; grid-template-columns: 1fr; gap: 7px; }
.rule-group:first-child .rule-group-list,.rule-group:last-child .rule-group-list { grid-template-columns: repeat(3,minmax(0,1fr)); }
.rule-group:last-child .rule-group-list { grid-template-columns: repeat(2,minmax(0,1fr)); }
.rule-option { position: relative; min-height: 67px; display: grid; grid-template-columns: 34px minmax(0,1fr) 31px; align-items: center; gap: 10px; padding: 10px 11px; border: 1px solid #e1e9e5; border-radius: 14px; background: #fafcf9; cursor: pointer; transition: border-color .16s ease,background .16s ease,box-shadow .16s ease; }
.rule-option:hover { border-color: #b8d4c8; background: white; box-shadow: 0 7px 18px rgba(21,67,55,.07); }
.rule-option:has(input:checked) { border-color: #b7dcca; background: #f1faf5; }
.rule-option:has(input:disabled) { cursor: default; }
.rule-option input { position: absolute; opacity: 0; pointer-events: none; }
.rule-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: white; box-shadow: 0 3px 10px rgba(30,60,52,.08); font-size: 15px; }
.rule-copy { min-width: 0; }
.rule-copy b,.rule-copy small { display: block; }
.rule-copy b { color: var(--ink); font-size: 10px; line-height: 1.25; }
.rule-copy small { margin-top: 3px; color: var(--muted); font-size: 8px; line-height: 1.4; }
.rule-switch { position: relative; width: 31px; height: 18px; border-radius: 999px; background: #cbd5d0; box-shadow: inset 0 0 0 1px rgba(34,66,57,.08); transition: background .16s ease; }
.rule-switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(16,48,39,.25); transition: transform .16s ease; }
.rule-option input:checked ~ .rule-switch { background: var(--green); }
.rule-option input:checked ~ .rule-switch::after { transform: translateX(13px); }
.rule-option input:focus-visible ~ .rule-switch { outline: 3px solid rgba(21,132,101,.2); outline-offset: 2px; }
.rules-save-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 20px; padding-top: 16px; border-top: 1px solid #e4ebe7; }
.rules-save-row p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.45; }
.compact-button { width: auto; min-width: 145px; min-height: 43px; margin: 0; padding: 0 17px; }
.move-options { display: grid; gap: 9px; }
.move-option { width: 100%; display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid #dfe7e2; border-radius: 13px; background: white; text-align: left; cursor: pointer; }
.move-option:hover { border-color: #8ab6a5; background: #f4faf7; transform: translateY(-1px); }
.move-option > span { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px; background: #eef6f2; font-size: 18px; }
.move-option b { display: block; color: var(--ink); font-size: 12px; }
.move-option small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.move-option i { color: var(--green); font-style: normal; font-weight: 900; }
.move-option kbd { min-width: 25px; display: inline-grid; place-items: center; padding: 5px 6px; border: 1px solid #cfdcd6; border-bottom-width: 2px; border-radius: 6px; background: white; color: var(--green); font: 900 9px/1 system-ui,sans-serif; }
.move-option.start-kick,.move-option.forward-kick,.move-option.back-kick,.move-option.line-kick,.move-option.home-kick { border-color: #f1c6bc; background: #fffaf7; }
.move-option.start-kick > span,.move-option.forward-kick > span,.move-option.back-kick > span,.move-option.line-kick > span,.move-option.home-kick > span { background: #fce7df; }
.move-decline { width: 100%; min-height: 42px; margin-top: 12px; border: 1px solid var(--line); border-radius: 11px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 900; cursor: pointer; }
.move-decline:hover { border-color: #8ab6a5; background: #f4faf7; color: var(--green); }
.camera-modal-card { width: min(100%,590px); }
.camera-setup-steps { display: grid; gap: 9px; }
.camera-setup-steps > div { display: grid; grid-template-columns: 31px 1fr; align-items: start; gap: 11px; padding: 12px; border: 1px solid #e3eae6; border-radius: 12px; background: #f8faf8; }
.camera-setup-steps > div > span { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: white; font-size: 10px; font-weight: 900; }
.camera-setup-steps p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.camera-setup-steps b { display: block; margin-bottom: 2px; color: var(--ink); font-size: 11px; }
.camera-setup-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 17px; }
.camera-setup-actions a { min-height: 43px; display: flex; align-items: center; justify-content: center; padding: 0 12px; border-radius: 10px; text-decoration: none; font-size: 10px; font-weight: 900; }
.secondary-link { border: 1px solid var(--line); background: white; color: var(--green); }
.primary-link { background: var(--green); color: white; box-shadow: 0 7px 16px rgba(14,116,94,.17); }
.camera-error { min-height: 14px; margin: 10px 0 0; color: #af433e; font-size: 10px; font-weight: 700; }
.end-game-card { width: min(100%,470px); }
.end-game-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.end-game-actions button { min-height: 45px; border: 1px solid var(--line); border-radius: 11px; background: white; color: var(--muted); font-size: 11px; font-weight: 900; cursor: pointer; }
.end-game-actions .confirm-end { border-color: #b84d46; background: #b84d46; color: white; box-shadow: 0 8px 18px rgba(184,77,70,.2); }
.end-game-actions .confirm-end:hover { background: #963b35; }
.end-game-actions .confirm-restart { border-color: var(--green); background: var(--green); color: white; box-shadow: 0 8px 18px rgba(14,116,94,.18); }
.end-game-actions .confirm-restart:hover { background: #095f4d; }

.confetti-layer {
  position: fixed;
  z-index: 10000;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.confetti-piece {
  position: absolute;
  top: -24px;
  left: var(--confetti-x);
  width: 9px;
  height: 16px;
  border-radius: 2px;
  background: var(--confetti-color);
  box-shadow: 0 1px 2px rgba(20,45,37,.12);
  animation: confetti-fall var(--confetti-duration) cubic-bezier(.18,.72,.36,1) var(--confetti-delay) forwards;
}
.confetti-piece:nth-child(3n) { width: 12px; height: 12px; border-radius: 50%; }
.confetti-piece:nth-child(4n) { width: 7px; height: 20px; }
@keyframes confetti-fall {
  0% { transform: translate3d(0,-3vh,0) rotate(0); opacity: 0; }
  8% { opacity: 1; }
  100% { transform: translate3d(var(--confetti-drift),108vh,0) rotate(var(--confetti-rotation)); opacity: .95; }
}
@media (prefers-reduced-motion: reduce) {
  .confetti-piece { animation-duration: .01ms; opacity: 0; }
}

@media (min-width: 1181px) {
  body:has(.game-view:not(.hidden)) main {
    width: min(1940px,calc(100% - 32px));
  }

  .game-view {
    min-height: calc(100dvh - 76px);
    padding-top: 0;
  }

  .game-topbar {
    grid-template-columns: 220px minmax(240px,1fr) auto;
    gap: 20px 24px;
    min-height: 64px;
    margin-bottom: 12px;
  }

  .game-heading { min-width: 0; }
  .game-heading h1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .game-actions {
    max-width: 680px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .game-layout {
    grid-template-columns: 220px auto 240px;
    gap: 24px;
  }

  .board-column {
    width: min(1340px,calc(100dvh - 145px),calc(100vw - 560px));
    min-width: 620px;
  }

  .players-panel,.turn-panel {
    position: sticky;
    top: 12px;
    max-height: calc(100dvh - 100px);
    overflow: auto;
    scrollbar-width: thin;
  }

  .board-frame { padding: 14px; border-radius: 27px; }
  .board-frame::before { inset: 14px; border-radius: 14px; }
  .board-frame::after { inset: 7px; border-radius: 21px; }
  .ludo-board { border-radius: 13px; }
  .piece { width: 5.55%; }
}

@media (min-width: 1181px) and (max-width: 1399px) {
  .game-topbar { grid-template-columns: 205px minmax(210px,1fr) auto; }
  .game-actions { gap: 6px; }
  .game-actions .ghost-button {
    width: 42px;
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 12px;
  }
  .game-actions .ghost-button span { display: none; }
  .game-layout { grid-template-columns: 205px auto 225px; gap: 20px; }
}

@media (min-width: 1600px) {
  .game-topbar { grid-template-columns: 230px minmax(280px,1fr) auto; }
  .game-layout { grid-template-columns: 230px auto 260px; gap: 28px; }
  .players-panel { padding: 21px 18px; }
  .turn-panel { padding: 21px 18px; }
  .panel-heading h2,.turn-status h2 { font-size: 23px; }
  .player-row { min-height: 55px; }
}

@media (max-width: 1450px) {
  .camera-rail { right: 12px; bottom: 12px; }
}

@media (min-width: 1000px) and (max-width: 1180px) {
  .game-topbar { grid-template-columns: auto minmax(0,1fr); gap: 8px 18px; margin-bottom: 12px; }
  .game-heading { grid-column: 2; text-align: right; }
  .game-actions { width: 100%; grid-column: 1 / -1; justify-self: stretch; justify-content: flex-end; overflow-x: auto; scrollbar-width: none; }
  .game-actions::-webkit-scrollbar { display: none; }
  .game-actions .ghost-button { min-height: 44px; white-space: nowrap; }
}

@media (min-width: 1000px) and (max-height: 850px) {
  .game-layout { grid-template-columns: 210px minmax(440px,min(650px,calc(100dvh - 170px),calc(100vw - 512px))) 225px; gap: 18px; }
}

@media (min-width: 1000px) and (max-width: 1180px) and (max-height: 850px) {
  .game-layout { grid-template-columns: 210px minmax(440px,min(650px,calc(100dvh - 210px),calc(100vw - 512px))) 225px; }
}

@media (max-width: 949px) {
  .welcome-view { width: min(100%,680px); height: auto; min-height: calc(100dvh - 76px); grid-template-columns: 1fr; grid-template-rows: auto; gap: 24px; margin: 0 auto; padding: 22px 0 30px; }
  .hero-copy { max-width: 650px; justify-self: center; text-align: center; }
  .hero-copy .eyebrow { margin-bottom: 10px; }
  .hero-copy h1 { font-size: clamp(44px,7vw,54px); letter-spacing: -2.8px; }
  .hero-copy h1 em { display: block; }
  .hero-copy > p { max-width: 580px; margin: 14px auto 13px; font-size: 13px; line-height: 1.55; }
  .hero-points { justify-content: center; }
  .download-cluster { display: none; }
  .download-cluster.android-download { display: block; margin-right: auto; margin-left: auto; }
  .room-card { width: min(100%,480px); justify-self: center; }
  .network-guide { grid-column: auto; }
}

@media (max-width: 999px) {
  .game-actions .ghost-button { min-height: 44px; }
  .game-layout { grid-template-columns: 190px minmax(400px,min(560px,calc(100vw - 246px))); gap: 16px; }
  .turn-panel { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 130px 200px; align-items: center; gap: 14px; padding: 16px; }
  .turn-panel .turn-status { padding: 0; border: 0; }
  .dice-stage { min-height: auto; padding: 0; flex-direction: row; gap: 12px; }
  .dice-stage .dice { width: 52px; height: 52px; padding: 8px; }
  .dice-stage p { margin: 0; }
  .turn-controls { grid-column: 3; }
  .activity { display: none; }
  .move-hint { grid-column: 3; margin: 4px 0 0; }
}

@media (min-width: 900px) and (max-width: 999px) {
  .game-layout { grid-template-columns: 180px minmax(390px,min(520px,calc(100vw - 474px))) 200px; gap: 12px; }
  .players-panel { padding: 14px 12px; }
  .player-row { grid-template-columns: 31px minmax(0,1fr) auto; gap: 6px; }
  .player-info b { max-width: 84px; }
  .host-badge { display: none; }
  .turn-panel { grid-column: auto; display: block; padding: 14px 12px; }
  .turn-panel .turn-status { padding-bottom: 14px; border-bottom: 1px solid #edf0ed; }
  .turn-panel .dice-stage { min-height: 126px; padding: 16px 0 8px; flex-direction: column; gap: 0; }
  .turn-panel .dice-stage .dice { width: 58px; height: 58px; padding: 9px; }
  .turn-panel .dice-stage p { margin: 11px 0 0; }
  .turn-panel .turn-controls { grid-column: auto; }
  .turn-panel .move-hint { grid-column: auto; margin: 8px 0 4px; }
}

@media (min-width: 761px) and (max-width: 999px) and (max-height: 760px) {
  .board-column { width: min(100%,calc(100dvh - 170px)); justify-self: center; }
}

@media (max-width: 760px) {
  html { scroll-padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  body { background: linear-gradient(145deg,#f9f7ef 0%,#f2f8f3 100%); }
  .ambient-one { width: 18rem; height: 18rem; right: -11rem; top: 3rem; }
  .ambient-two { width: 16rem; height: 16rem; left: -10rem; }

  .site-header, main { width: min(calc(100% - 24px),620px); }
  .site-header { height: calc(58px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
  .brand { gap: 8px; font-size: 17px; letter-spacing: -.5px; }
  .brand-mark { width: 32px; height: 32px; padding: 6px; border-radius: 9px; }
  .header-tools { gap: 6px; }
  .creator-link { width: 32px; min-height: 32px; justify-content: center; padding: 0; }
  .creator-link span { display: none; }
  .connection-pill { gap: 6px; padding: 7px 10px; font-size: 10px; }
  .status-dot { width: 7px; height: 7px; box-shadow: 0 0 0 3px rgba(85,185,136,.12); }

  .welcome-view { width: 100%; height: auto; min-height: calc(100dvh - 58px - env(safe-area-inset-top)); grid-template-columns: 1fr; grid-template-rows: auto; gap: 18px; padding: 14px 0 calc(24px + env(safe-area-inset-bottom)); }
  .hero-copy { max-width: 470px; justify-self: center; text-align: center; }
  .hero-copy .eyebrow { margin-bottom: 8px; font-size: 9px; letter-spacing: 2px; }
  .hero-copy h1 { font-size: clamp(38px,10.5vw,48px); line-height: .96; letter-spacing: -2.2px; }
  .hero-copy h1 em { display: block; }
  .hero-copy > p { max-width: 420px; margin: 13px auto 12px; font-size: 13px; line-height: 1.55; }
  .hero-points { justify-content: center; flex-wrap: nowrap; gap: 16px; font-size: 10px; }
  .hero-points b { font-size: 13px; }
  .download-cluster { display: none; }
  .room-card { max-width: 480px; justify-self: center; padding: 19px 18px 17px; border-radius: 19px; box-shadow: 0 15px 40px rgba(37,68,59,.1); }
  .card-accent { height: 4px; }
  .card-kicker { margin-bottom: 5px; font-size: 8px; }
  .room-card h2 { font-size: 27px; }
  .tab-list { margin: 15px 0 14px; }
  .tab { min-height: 44px; padding: 9px; }
  .input-shell { height: 48px; }
  .code-inputs { gap: 8px; margin-bottom: 13px; }
  .code-inputs input { height: 48px; }
  .primary-button { min-height: 48px; margin-top: 13px; }
  .form-hint { margin-top: 9px; }
  .form-error { margin-top: 8px; }
  .network-guide { grid-column: auto; gap: 10px; padding: 0 6px; }
  .guide-icon { width: 34px; height: 34px; flex: 0 0 auto; }
  .network-guide div span { max-width: 290px; }

  .game-view { padding: 2px 0 calc(18px + env(safe-area-inset-bottom)); }
  .game-topbar { grid-template-columns: auto minmax(0,1fr); gap: 8px 12px; margin-bottom: 10px; }
  .game-topbar > div:first-child { min-width: 92px; }
  .room-code-button { gap: 5px; font-size: 16px; letter-spacing: 3px; }
  .room-code-button svg { width: 14px; }
  .game-heading { min-width: 0; grid-column: 2; grid-row: 1; margin: 0; text-align: right; }
  .game-heading p { margin-bottom: 2px; font-size: 7px; letter-spacing: 1.35px; }
  .game-heading h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; }
  .game-actions { width: 100%; grid-column: 1 / -1; grid-row: 2; justify-self: stretch; display: flex; justify-content: flex-start; gap: 6px; padding: 1px 0 3px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
  .game-actions::-webkit-scrollbar { display: none; }
  .game-actions .ghost-button { min-width: 76px; min-height: 44px; flex: 1 0 auto; padding: 0 11px; white-space: nowrap; font-size: 9px; }

  .game-layout { display: flex; flex-direction: column; gap: 10px; }
  .board-column { order: 0; width: 100%; }
  .board-frame { padding: 6px; border-radius: 15px; box-shadow: 0 13px 35px rgba(33,62,54,.11); }
  .board-frame::before { inset: 6px; border-radius: 9px; }
  .board-frame::after { inset: 3px; border-radius: 12px; }
  .ludo-board { border-width: 1.5px; border-radius: 8px; }
  .piece { width: 7%; }
  .piece.movable::before { content: ''; position: absolute; inset: -8px; border-radius: 50%; }

  .turn-panel { position: sticky; z-index: 12; bottom: calc(8px + env(safe-area-inset-bottom)); order: 1; width: 100%; display: grid; grid-template-columns: minmax(0,.9fr) 54px minmax(136px,1.35fr); align-items: center; gap: 8px; padding: 10px; border-radius: 16px; background: rgba(255,255,255,.96); box-shadow: 0 12px 35px rgba(28,63,53,.18); }
  .turn-panel .turn-status { min-width: 0; gap: 7px; padding: 0; border: 0; }
  .turn-panel .turn-status > div { min-width: 0; }
  .turn-panel .turn-status p { margin-bottom: 2px; font-size: 7px; }
  .turn-panel .turn-status h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
  .turn-color-dot { width: 10px; height: 10px; flex: 0 0 auto; border-width: 2px; }
  .turn-panel .dice-stage { min-height: 0; grid-column: 2; grid-row: 1; padding: 0; }
  .turn-panel .dice-stage .dice { width: 48px; height: 48px; gap: 3px; padding: 7px; border-radius: 12px; }
  .turn-panel .dice-stage p { display: none; }
  .turn-panel .roll-series { position: absolute; left: 50%; top: -18px; max-width: 154px; margin: 0; padding: 3px 5px; border: 1px solid #dbe5e0; border-radius: 9px; background: rgba(255,255,255,.97); box-shadow: 0 4px 12px rgba(28,63,53,.1); transform: translateX(-50%); }
  .turn-panel .roll-chip { min-width: 22px; width: 22px; height: 20px; border-radius: 6px; font-size: 8px; }
  .turn-panel .roll-chip > i { min-width: 11px; height: 11px; top: -4px; font-size: 5px; }
  .pip { width: 7px; height: 7px; }
  .turn-panel .turn-controls { min-width: 0; grid-column: 3; grid-row: 1; }
  .turn-panel .roll-button { min-height: 48px; margin: 0; padding: 0 10px; border-radius: 11px; gap: 5px; font-size: 10px; }
  .turn-panel .roll-button kbd { display: none; }
  .mini-die { font-size: 16px; }
  .undo-button { min-height: 44px; margin-top: 5px; }
  .turn-panel .move-hint { min-height: 0; max-height: 2.7em; grid-column: 1 / -1; grid-row: 2; display: -webkit-box; margin: -1px 2px 0; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; text-align: left; font-size: 8px; line-height: 1.35; }
  .turn-panel .activity { display: none; }

  .players-panel { order: 2; width: 100%; padding: 12px; border-radius: 16px; }
  .panel-heading { align-items: center; padding: 0 1px 8px; }
  .panel-heading .eyebrow { display: none; }
  .panel-heading h2 { font-size: 17px; }
  .count-badge { padding: 4px 7px; font-size: 9px; }
  .players-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 8px; padding: 4px 0 0; }
  .player-row { grid-template-columns: 30px minmax(0,1fr) auto; gap: 7px; min-height: 46px; padding: 5px 2px; }
  .player-token { width: 29px; height: 29px; }
  .player-info b { max-width: 100%; font-size: 10px; }
  .player-info span { font-size: 8px; }
  .host-badge { padding: 2px 4px; font-size: 6px; }
  .empty-seat { display: none; }
  .active-turn::before { left: -13px; top: 10px; height: 26px; }
  .lobby-action { margin-top: 9px; }
  .lobby-action .primary-button { min-height: 48px; }
  .network-address { margin-top: 9px; padding-top: 9px; text-align: center; }
  .game-view[data-status="playing"] .network-address { display: none; }

  .camera-rail { right: 12px; bottom: calc(88px + env(safe-area-inset-bottom)); width: calc(100vw - 24px); max-width: 430px; max-height: 48dvh; padding: 9px; border-radius: 16px; }
  .camera-rail.collapsed { width: auto; padding: 5px 6px; }
  .camera-rail-heading button { width: 44px; height: 44px; border-radius: 12px; }
  .camera-rail.collapsed .camera-rail-heading button { margin-left: 4px; }
  .camera-rail[data-count="1"] .video-grid { grid-template-columns: 1fr; }
  .video-grid { gap: 8px; }
  .camera-tile { min-height: 0; aspect-ratio: 16/9; border-radius: 12px; }
  .camera-expand { width: 44px; height: 44px; }

  .toast { bottom: calc(92px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); }
  .toast.kick { bottom: calc(102px + env(safe-area-inset-bottom)); }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal-card { width: 100%; max-height: min(88dvh,720px); padding: 24px 18px calc(20px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; }
  .modal-card h2 { padding-right: 42px; font-size: 26px; }
  .modal-close { right: 14px; top: 13px; width: 44px; height: 44px; }
  .modal-intro { margin: 7px 0 15px; font-size: 11px; }
  .rules-heading { align-items: flex-start; }
  .rules-mode { margin-top: 4px; }
  .rule-options { grid-template-columns: 1fr; gap: 15px; }
  .rule-group:first-child,.rule-group:last-child { grid-column: auto; }
  .rule-group:first-child .rule-group-list,.rule-group:last-child .rule-group-list { grid-template-columns: 1fr; }
  .rule-option { min-height: 62px; }
  .rules-save-row { position: sticky; bottom: calc(-20px - env(safe-area-inset-bottom)); z-index: 2; margin: 17px -18px calc(-20px - env(safe-area-inset-bottom)); padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); background: rgba(255,254,249,.96); box-shadow: 0 -10px 24px rgba(23,52,44,.08); }
  .rules-save-row p { max-width: 52%; }
  .compact-button { min-width: 135px; }
  .move-option { min-height: 58px; grid-template-columns: 44px minmax(0,1fr); padding: 9px; }
  .move-option > span { width: 44px; height: 44px; }
  .move-option > i { display: none; }
  .move-decline { min-height: 46px; }
  .camera-setup-actions { grid-template-columns: 1fr; }
  .camera-setup-actions a { min-height: 46px; }
  .end-game-actions button { min-height: 48px; }
  .camera-focus { padding: 12px; }
  .camera-focus-card { width: calc(100vw - 24px); border-radius: 18px; }
}

@media (max-width: 430px) {
  .site-header, main { width: calc(100% - 16px); }
  .native-shell .site-header { height: calc(60px + env(safe-area-inset-top)); }
  .brand { font-size: 16px; }
  .brand-mark { width: 30px; height: 30px; }
  .connection-pill { padding: 6px 8px; font-size: 9px; }
  .welcome-view { gap: 15px; padding-top: 9px; }
  .hero-copy .eyebrow { margin-bottom: 6px; }
  .hero-copy h1 { font-size: 38px; }
  .hero-copy > p { margin: 10px auto; font-size: 12px; }
  .hero-points { gap: 12px; }
  .room-card { padding: 17px 15px 15px; }
  .native-connection { margin-top: 10px; }
  .network-guide { align-items: flex-start; padding: 0 4px; }
  .network-guide div span { max-width: 250px; }

  .game-heading h1 { font-size: 17px; }
  .game-actions .ghost-button { min-width: 72px; padding: 0 9px; }
  .game-layout { gap: 8px; }
  .board-frame { padding: 4px; border-radius: 12px; }
  .board-frame::before { inset: 4px; border-radius: 7px; }
  .board-frame::after { inset: 2px; border-radius: 9px; }
  .piece { width: 7.6%; }
  .turn-panel { grid-template-columns: minmax(0,.82fr) 46px minmax(132px,1.4fr); gap: 6px; padding: 8px; }
  .turn-panel .turn-status { gap: 5px; }
  .turn-panel .turn-status h2 { font-size: 13px; }
  .turn-panel .dice-stage .dice { width: 44px; height: 44px; padding: 6px; }
  .turn-panel .roll-button { min-height: 46px; padding: 0 8px; }
  .turn-panel .mini-die { display: none; }
  .players-panel { padding: 10px; }
  .players-list { gap: 0 5px; }
  .player-row { grid-template-columns: 28px minmax(0,1fr) auto; gap: 5px; }
  .player-token { width: 27px; height: 27px; }
  .host-badge { display: none; }
  .camera-rail[data-count="1"] .video-grid { grid-template-columns: 1fr; }
  .end-game-actions { grid-template-columns: 1fr; gap: 8px; }
}

@media (max-width: 360px) {
  .brand > span:last-child { font-size: 15px; }
  .game-topbar > div:first-child { min-width: 84px; }
  .game-heading h1 { font-size: 15px; }
  .turn-panel { grid-template-columns: minmax(0,.75fr) 44px minmax(124px,1.45fr); }
  .turn-panel .turn-status p { display: none; }
  .turn-panel .turn-status h2 { font-size: 12px; }
  .turn-color-dot { width: 8px; height: 8px; }
}

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

/* Landing page — a tactile, editorial game-table composition. */
.welcome-view {
  width: 100%;
  height: auto;
  min-height: calc(100dvh - 76px);
  display: block;
  padding: 12px 0 42px;
}

.landing-hero {
  position: relative;
  min-height: 596px;
  display: grid;
  grid-template-columns: minmax(330px,1.08fr) minmax(285px,.84fr) 354px;
  align-items: center;
  gap: 26px;
  padding: 42px 38px 42px 46px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 34px;
  background: #0c4339;
  box-shadow: 0 28px 80px rgba(18,53,45,.2);
  isolation: isolate;
}

.landing-hero::before {
  content: '';
  position: absolute;
  z-index: -2;
  inset: 0;
  opacity: .36;
  background-image:
    radial-gradient(circle at 1px 1px,rgba(255,255,255,.22) 1px,transparent 0);
  background-size: 22px 22px;
  mask-image: linear-gradient(110deg,black,transparent 52%);
}

.landing-hero::after {
  content: '';
  position: absolute;
  z-index: -1;
  width: 540px;
  height: 540px;
  left: 38%;
  top: 7%;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 50%;
  box-shadow: 0 0 0 70px rgba(255,255,255,.025),0 0 0 140px rgba(255,255,255,.018);
}

.hero-copy { position: relative; z-index: 2; max-width: 470px; align-self: center; }
.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 20px;
  color: #c6e6d8;
  text-transform: uppercase;
  letter-spacing: 2.25px;
  font-size: 10px;
  font-weight: 850;
}
.hero-kicker i { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 5px rgba(244,200,71,.12); }
.hero-copy h1 {
  max-width: 500px;
  margin: 0;
  color: #fffaf0;
  font-family: Georgia,"Times New Roman",serif;
  font-size: clamp(52px,4.55vw,67px);
  line-height: .94;
  letter-spacing: -4.4px;
  font-weight: 600;
}
.hero-copy h1 em { color: #f5cf58; font-weight: inherit; font-style: italic; }
.hero-copy > p {
  max-width: 445px;
  margin: 22px 0 22px;
  color: rgba(244,250,246,.7);
  font-size: 14px;
  line-height: 1.7;
}
.hero-actions { display: flex; align-items: center; gap: 18px; }
.hero-primary {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  gap: 22px;
  padding: 0 18px 0 20px;
  border-radius: 12px;
  background: #f4c847;
  color: #173b35;
  text-decoration: none;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 10px 25px rgba(4,27,22,.2);
  transition: transform .18s ease,box-shadow .18s ease,background .18s ease;
}
.hero-primary:hover { transform: translateY(-2px); background: #ffdc67; box-shadow: 0 14px 30px rgba(4,27,22,.26); }
.hero-secondary { color: #fffaf0; text-underline-offset: 5px; text-decoration-color: rgba(255,255,255,.35); font-size: 11px; font-weight: 800; }
.hero-secondary:hover { text-decoration-color: #f4c847; }
.hero-points { display: flex; align-items: stretch; gap: 0; margin-top: 28px; color: rgba(255,255,255,.62); }
.hero-points span { min-width: 82px; display: flex; flex-direction: column; gap: 2px; padding: 0 20px; border-left: 1px solid rgba(255,255,255,.13); }
.hero-points span:first-child { padding-left: 0; border-left: 0; }
.hero-points b { color: #fffaf0; font-family: Georgia,serif; font-size: 20px; font-weight: 600; }
.hero-points small { text-transform: uppercase; letter-spacing: 1px; font-size: 8px; font-weight: 800; }

.hero-copy .download-cluster { margin-top: 24px; }
.hero-copy .download-edition { border-color: rgba(255,255,255,.15); background: rgba(255,255,255,.07); color: #fffaf0; box-shadow: none; }
.hero-copy .download-edition:hover { border-color: rgba(255,255,255,.32); background: rgba(255,255,255,.11); }
.hero-copy .download-edition > span:first-child { background: rgba(255,255,255,.1); color: #f4c847; }
.hero-copy .download-edition small,.hero-copy .platform-downloads { color: rgba(255,255,255,.55); }
.hero-copy .platform-downloads summary { color: rgba(255,255,255,.7); }
.hero-copy .platform-download-menu { color: var(--muted); }

.hero-scene { position: relative; z-index: 1; width: 100%; height: 450px; align-self: center; }
.scene-orbit { position: absolute; border-radius: 50%; border: 1px dashed rgba(255,255,255,.16); }
.orbit-one { width: 400px; height: 400px; left: -52px; top: 22px; }
.orbit-two { width: 300px; height: 300px; left: -2px; top: 74px; border-style: solid; border-color: rgba(255,255,255,.08); }
.hero-board-wrap {
  position: absolute;
  width: min(29vw,310px);
  max-width: 310px;
  min-width: 270px;
  left: 1px;
  top: 71px;
  padding: 9px;
  border-radius: 28px;
  background: #fffdf5;
  box-shadow: 0 26px 48px rgba(0,24,18,.32),0 0 0 1px rgba(255,255,255,.18);
  transform: rotate(-5.5deg);
  animation: board-breathe 7s ease-in-out infinite;
}
.hero-board { display: block; width: 100%; height: auto; border-radius: 21px; }
.live-table-badge {
  position: absolute;
  z-index: 3;
  right: -7px;
  top: 31px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 13px;
  background: rgba(7,47,39,.9);
  color: white;
  box-shadow: 0 12px 30px rgba(0,24,18,.24);
  backdrop-filter: blur(12px);
}
.live-table-badge i { width: 9px; height: 9px; border-radius: 50%; background: #6fe0a8; box-shadow: 0 0 0 5px rgba(111,224,168,.12); }
.live-table-badge span { display: flex; flex-direction: column; gap: 2px; color: rgba(255,255,255,.55); font-size: 8px; }
.live-table-badge b { color: #a8f0cb; letter-spacing: 1.2px; font-size: 7px; }
.floating-die {
  position: absolute;
  z-index: 4;
  width: 67px;
  height: 67px;
  right: -4px;
  bottom: 74px;
  border-radius: 18px;
  background: #f8cc49;
  box-shadow: 0 17px 32px rgba(0,23,17,.27),inset 0 0 0 1px rgba(255,255,255,.35);
  transform: rotate(10deg);
  animation: dice-float 4.8s ease-in-out infinite;
}
.floating-die i { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: #18473d; }
.floating-die i:nth-child(1) { left: 16px; top: 16px; }.floating-die i:nth-child(2) { right: 16px; top: 16px; }
.floating-die i:nth-child(3) { left: 30px; top: 30px; }.floating-die i:nth-child(4) { left: 16px; bottom: 16px; }.floating-die i:nth-child(5) { right: 16px; bottom: 16px; }
.player-stack { position: absolute; z-index: 5; left: 2px; bottom: 9px; display: flex; align-items: center; }
.player-stack span,.player-stack b { width: 32px; height: 32px; display: grid; place-items: center; margin-left: -7px; border: 3px solid #0c4339; border-radius: 50%; color: white; font-size: 9px; font-weight: 900; box-shadow: 0 5px 12px rgba(0,20,15,.2); }
.player-stack span:first-child { margin-left: 0; background: #ef5b55; }.player-stack span:nth-child(2) { background: #20a873; }.player-stack span:nth-child(3) { background: #4d75d5; }
.player-stack b { background: #f4c847; color: #173b35; }
.scene-caption { position: absolute; left: 106px; bottom: 3px; display: flex; flex-direction: column; gap: 1px; margin: 0; }
.scene-caption span { color: #92c9b3; text-transform: uppercase; letter-spacing: 1.4px; font-size: 7px; font-weight: 900; }
.scene-caption b { color: #fffaf0; font-family: Georgia,serif; font-size: 15px; font-weight: 600; }
.scene-caption small { color: rgba(255,255,255,.48); font-size: 8px; }

.landing-hero .room-card {
  z-index: 2;
  width: 100%;
  max-width: 354px;
  justify-self: end;
  padding: 27px 25px 23px;
  border-color: rgba(255,255,255,.72);
  border-radius: 24px;
  background: #fffdf8;
  box-shadow: 0 24px 60px rgba(0,30,22,.32);
  backdrop-filter: none;
  scroll-margin-top: 18px;
}
.landing-hero .room-card::after { content: ''; position: absolute; width: 82px; height: 82px; right: -38px; bottom: -42px; border: 18px solid rgba(244,200,71,.18); border-radius: 50%; pointer-events: none; }
.landing-hero .card-accent { height: 6px; }
.landing-hero .card-kicker { color: #799088; letter-spacing: 1.7px; }
.landing-hero .room-card h2 { color: #153c34; font-size: 30px; letter-spacing: -1.2px; }
.landing-hero .tab-list { margin-top: 18px; background: #eef2ed; }
.landing-hero .input-shell,.landing-hero .code-inputs input { border-color: #d8e0db; background: white; }
.landing-hero .primary-button { min-height: 52px; border-radius: 12px; box-shadow: 0 9px 20px rgba(14,116,94,.2); }
.landing-hero .form-hint { display: flex; justify-content: center; align-items: center; gap: 6px; color: #879890; }
.landing-hero .form-hint i { width: 5px; height: 5px; border-radius: 50%; background: #54b786; }

.landing-lan-share {
  min-height: 74px;
  display: grid;
  grid-template-columns: 42px minmax(0,1fr) auto;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 13px 15px;
  border: 1px solid #b9d8ca;
  border-radius: 17px;
  background: #eaf6f0;
  color: var(--ink);
  box-shadow: 0 10px 28px rgba(37,68,59,.07);
}
.lan-share-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: #0e745e; color: white; box-shadow: 0 7px 16px rgba(14,116,94,.18); }
.lan-share-icon svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.lan-share-copy { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.lan-share-copy span { color: #667c75; text-transform: uppercase; letter-spacing: 1.3px; font-size: 8px; font-weight: 900; }
.lan-share-copy b { overflow: hidden; color: #0b6652; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.landing-lan-share button { min-height: 44px; display: inline-flex; align-items: center; gap: 9px; padding: 0 15px; border: 1px solid #8ebfa9; border-radius: 11px; background: white; color: #0e745e; font-size: 10px; font-weight: 900; cursor: pointer; }
.landing-lan-share button:hover { border-color: #0e745e; background: #f9fffc; }
.landing-lan-share button svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.landing-proof {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr)) minmax(235px,.85fr);
  gap: 0;
  margin-top: 18px;
  border: 1px solid #dce3dd;
  border-radius: 20px;
  background: rgba(255,255,255,.62);
  box-shadow: 0 12px 35px rgba(37,68,59,.06);
  overflow: hidden;
}
.landing-proof article { min-height: 104px; display: grid; grid-template-columns: 35px 1fr; gap: 11px; align-items: center; padding: 20px 22px; border-right: 1px solid #e3e8e4; }
.landing-proof article > span { align-self: start; padding-top: 2px; color: #c19619; font-family: Georgia,serif; font-size: 11px; font-style: italic; }
.landing-proof article b { display: block; margin-bottom: 5px; color: var(--ink); font-family: Georgia,serif; font-size: 15px; }
.landing-proof article p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.55; }
.landing-proof .network-guide { grid-column: auto; justify-self: stretch; padding: 20px; background: #f0f5f1; }
.landing-proof .guide-icon { flex: 0 0 auto; box-shadow: none; }
.landing-proof .network-guide div { line-height: 1.4; }

@keyframes board-breathe { 0%,100% { transform: rotate(-5.5deg) translateY(0); } 50% { transform: rotate(-4deg) translateY(-7px); } }
@keyframes dice-float { 0%,100% { transform: rotate(10deg) translateY(0); } 50% { transform: rotate(5deg) translateY(-9px); } }

@media (max-width: 1150px) {
  .landing-hero { grid-template-columns: minmax(0,1fr) 370px; gap: 48px; padding: 44px 52px; }
  .hero-scene { display: none; }
  .landing-hero .room-card { max-width: 370px; }
  .landing-proof { grid-template-columns: repeat(3,1fr); }
  .landing-proof .network-guide { grid-column: 1 / -1; justify-content: center; border-top: 1px solid #e3e8e4; }
}

@media (max-width: 760px) {
  .welcome-view { width: 100%; min-height: calc(100dvh - 58px - env(safe-area-inset-top)); padding: 8px 0 calc(24px + env(safe-area-inset-bottom)); }
  .landing-hero { min-height: 0; display: grid; grid-template-columns: 1fr; gap: 28px; padding: 34px 22px 22px; border-radius: 25px; }
  .landing-hero::after { width: 420px; height: 420px; left: 28%; top: -4%; }
  .hero-copy { max-width: 530px; justify-self: center; text-align: left; }
  .hero-kicker { margin-bottom: 16px; font-size: 9px; }
  .hero-copy h1 { font-size: clamp(42px,11vw,55px); line-height: .96; letter-spacing: -3px; }
  .hero-copy h1 em { display: inline; }
  .hero-copy > p { margin: 17px 0 18px; font-size: 13px; line-height: 1.6; }
  .hero-actions { gap: 16px; }
  .hero-primary { min-height: 48px; gap: 18px; }
  .hero-points { justify-content: flex-start; margin-top: 23px; }
  .hero-points span { min-width: 74px; padding: 0 15px; }
  .hero-points b { font-size: 18px; }
  .hero-copy .download-cluster { display: none; }
  .hero-copy .download-cluster.android-download { display: block; margin: 20px 0 0; }
  .hero-copy .android-download .download-edition { width: 100%; justify-content: center; }
  .hero-copy .android-download .android-install-note { max-width: none; color: rgba(255,255,255,.68); text-align: center; }
  .hero-copy .android-download .platform-downloads { display: none; }
  .landing-hero .room-card { max-width: 530px; justify-self: center; padding: 22px 19px 19px; border-radius: 19px; box-shadow: 0 18px 44px rgba(0,25,18,.3); }
  .landing-hero .room-card h2 { font-size: 28px; }
  .landing-hero .tab { min-height: 44px; }
  .player-profile-setup { gap: 9px; margin-top: 11px; }
  .landing-proof { grid-template-columns: 1fr; margin-top: 12px; border-radius: 17px; }
  .landing-lan-share { grid-template-columns: 38px minmax(0,1fr) auto; gap: 10px; margin-top: 12px; padding: 11px 12px; }
  .lan-share-icon { width: 38px; height: 38px; border-radius: 11px; }
  .landing-lan-share button { min-width: 44px; padding: 0 12px; }
  .landing-lan-share button span { display: none; }
  .landing-proof article { min-height: 84px; grid-template-columns: 30px 1fr; padding: 16px 18px; border-right: 0; border-bottom: 1px solid #e3e8e4; }
  .landing-proof article b { font-size: 14px; }
  .landing-proof .network-guide { grid-column: auto; justify-content: flex-start; border-top: 0; padding: 16px 18px; }
}

@media (max-width: 430px) {
  .welcome-view { gap: 0; padding-top: 5px; }
  .landing-hero { gap: 24px; padding: 29px 17px 17px; border-radius: 21px; }
  .hero-kicker { letter-spacing: 1.65px; }
  .hero-copy h1 { font-size: 39px; letter-spacing: -2.5px; }
  .hero-copy > p { font-size: 12px; }
  .hero-actions { align-items: stretch; flex-direction: column; gap: 12px; }
  .hero-primary { justify-content: space-between; }
  .hero-secondary { align-self: flex-start; }
  .hero-points { gap: 0; }
  .hero-points span { min-width: 68px; padding: 0 12px; }
  .landing-hero .room-card { padding: 20px 15px 16px; }
  .landing-hero .room-card h2 { font-size: 26px; }
  .landing-proof article { min-height: 78px; }
  .lan-share-copy b { font-size: 12px; }
}

/* Game table refresh — playful, compact and locked to the viewport. */
body:has(.game-view:not(.hidden)) {
  --game-surface: rgba(255,255,255,.88);
  --game-surface-solid: #ffffff;
  --game-border: #d8e3dd;
  --game-shadow: rgba(37,68,59,.1);
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: var(--page-background);
}
body:has(.game-view:not(.hidden)) .ambient { opacity: .58; }
body:has(.game-view:not(.hidden)) .site-header {
  width: min(1800px,calc(100% - 28px));
  height: 58px;
}
body:has(.game-view:not(.hidden)) main {
  width: min(1900px,calc(100% - 28px));
  height: calc(100dvh - 58px);
}

.game-view {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 0 10px;
}
.game-topbar {
  min-height: 54px;
  flex: 0 0 auto;
  grid-template-columns: 205px minmax(220px,1fr) auto;
  gap: 14px;
  justify-content: center;
  margin: 0 0 8px;
}
.game-topbar > div:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
}
.game-topbar > div:first-child .eyebrow { margin: 0; }
.room-code-button {
  padding: 7px 10px;
  border: 1px solid var(--game-border);
  border-radius: 11px;
  background: var(--game-surface);
  color: var(--green);
  box-shadow: 0 3px 0 #cbd9d3;
  font-size: 16px;
  letter-spacing: 3px;
}
.game-heading p { color: var(--muted); font-size: 8px; }
.game-heading h1,
.panel-heading h2,
.turn-status h2,
.camera-rail-heading h2 {
  font-family: ui-rounded,"Arial Rounded MT Bold","Trebuchet MS",sans-serif;
  font-weight: 850;
  letter-spacing: -.45px;
}
.game-heading h1 { color: var(--ink); font-size: 22px; }
.game-actions { max-width: none; flex-wrap: nowrap; gap: 6px; }
.ghost-button {
  min-height: 36px;
  padding: 7px 10px;
  border-color: var(--game-border);
  border-radius: 11px;
  background: var(--game-surface);
  color: var(--muted);
  box-shadow: 0 3px 0 #ccd9d3;
  transition: transform .14s ease,box-shadow .14s ease,background .14s ease;
}
.ghost-button:hover {
  border-color: #9ebdaf;
  background: var(--game-surface-solid);
  color: var(--green);
  transform: translateY(-1px);
  box-shadow: 0 4px 0 #c1d2ca;
}
.ghost-button:active { transform: translateY(2px); box-shadow: 0 1px 0 #c1d2ca; }
.ghost-button.muted { border-color: #e6c2b6; background: #fff1e9; }
.camera-button.live,.microphone-button.live { border-color: #83bda6; background: #e6f7ed; }

.game-layout {
  min-height: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 205px minmax(0,1fr) 225px;
  gap: 16px;
  align-items: center;
  justify-content: center;
}
.panel {
  border: 1px solid var(--game-border);
  border-radius: 17px;
  background:
    linear-gradient(150deg,rgba(255,255,255,.85),transparent 32%),
    var(--game-surface-solid);
  box-shadow: 0 6px 0 #cedbd5,0 14px 30px var(--game-shadow);
  backdrop-filter: blur(10px);
}
.players-panel,.turn-panel {
  position: static;
  top: auto;
  max-height: 100%;
  overflow: hidden;
  padding: 14px 12px;
}
.players-panel { border-top: 5px solid #ef736a; }
.turn-panel { border-top: 5px solid #55b68b; }
.panel-heading { padding: 0 1px 10px; border-color: var(--game-border); }
.panel-heading h2,.turn-status h2 { font-size: 18px; }
.count-badge { background: var(--mint); color: var(--green); }
.players-list { padding: 5px 0 0; }
.player-row { min-height: 44px; padding: 4px 2px; border-color: #e4ebe7; }
.player-token { width: 30px; height: 30px; border-width: 2px; }
.player-info b { font-size: 11px; }
.player-info span { font-size: 8px; }
.empty-seat { min-height: 38px; }
.empty-seat i { width: 27px; height: 27px; }
.lobby-action { margin-top: 9px; }
.configure-rules-button,.waiting-message { background: rgba(255,255,255,.55); }
.network-address { margin-top: 10px; padding-top: 10px; border-color: var(--game-border); }

.board-column {
  width: min(calc(100dvh - 130px),calc(100vw - 500px),940px);
  min-width: 0;
  max-width: 100%;
  justify-self: center;
}
.board-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: clamp(16px,1.35vw,24px);
  border: 1px solid #cbd1d3;
  border-radius: 5px;
  background:
    linear-gradient(135deg,#ffffff 0 49.2%,#d8dddf 49.7% 50.3%,#f1f3f3 50.8%) top left / 50% 50% no-repeat,
    linear-gradient(225deg,#ffffff 0 49.2%,#d8dddf 49.7% 50.3%,#e8ebec 50.8%) top right / 50% 50% no-repeat,
    linear-gradient(45deg,#f7f8f8 0 49.2%,#cfd5d7 49.7% 50.3%,#ffffff 50.8%) bottom left / 50% 50% no-repeat,
    linear-gradient(315deg,#eef0f1 0 49.2%,#cfd5d7 49.7% 50.3%,#ffffff 50.8%) bottom right / 50% 50% no-repeat,
    #f6f7f7;
  box-shadow:
    inset 0 0 0 3px rgba(255,255,255,.95),
    inset 0 0 0 7px rgba(199,207,210,.42),
    inset 0 9px 12px rgba(255,255,255,.84),
    inset 0 -9px 14px rgba(104,118,122,.13),
    0 5px 0 #c5cbcd,
    0 13px 28px rgba(35,53,51,.2);
}
.board-frame::before {
  inset: clamp(16px,1.35vw,24px);
  border-radius: 1px;
  background: linear-gradient(118deg,rgba(255,255,255,.3),rgba(255,255,255,.06) 27%,transparent 44%);
  box-shadow:
    inset 0 0 0 2px rgba(95,109,108,.24),
    inset 0 0 12px rgba(67,82,79,.12);
}
.board-frame::after {
  inset: 5px;
  border: 1px solid rgba(255,255,255,.96);
  border-radius: 2px;
  box-shadow:
    inset 0 0 0 1px rgba(154,165,168,.3),
    0 0 0 1px rgba(196,203,205,.34);
}
.ludo-board {
  border: 2px solid #7e8b89;
  border-radius: 1px;
  background: #fbfcf9;
  box-shadow: inset 0 0 32px rgba(42,65,59,.06),0 0 0 2px rgba(191,199,200,.72);
}
.base-nest { background: rgba(255,253,244,.84); }
.board-cell { background: #fbfcf9; border-color: rgba(62,44,29,.4); }

.turn-status { padding-bottom: 11px; border-color: var(--game-border); }
.dice-stage { min-height: 118px; padding: 13px 0 8px; }
.dice {
  width: 62px;
  height: 62px;
  border: 2px solid #ce9e2e;
  border-radius: 17px;
  background: linear-gradient(145deg,#ffe47d,#f4c847);
  box-shadow: 0 7px 0 #c99a2b,0 12px 20px rgba(99,66,9,.18),inset 0 1px 0 rgba(255,255,255,.62);
}
.pip { background: #3d3526; }
.dice-stage p { margin-top: 11px; color: var(--muted); }
.roll-button {
  min-height: 45px;
  border-radius: 12px;
  background: linear-gradient(180deg,#1b8f70,#0e745e);
  box-shadow: 0 5px 0 #075443,0 10px 18px rgba(14,116,94,.18);
}
.roll-button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 0 #075443,0 12px 20px rgba(14,116,94,.2); }
.roll-button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 #075443; }
.move-hint { min-height: 25px; margin: 8px 0 3px; font-size: 8px; }
.activity { margin-top: 8px; padding-top: 8px; border-color: var(--game-border); }
.game-log { max-height: min(142px,18dvh); margin-top: 6px; }
.game-log li { padding-top: 5px; padding-bottom: 5px; border-color: #e5ece8; font-size: 8px; }

@media (max-width: 1399px) and (min-width: 1000px) {
  .game-topbar { grid-template-columns: 185px minmax(190px,1fr) auto; }
  .game-actions .ghost-button {
    width: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
  }
  .game-actions .ghost-button span { display: none; }
  .game-layout { grid-template-columns: 185px minmax(0,1fr) 205px; gap: 13px; }
  .board-column { width: min(calc(100dvh - 128px),calc(100vw - 432px),860px); }
  .host-badge { width: 16px; overflow: hidden; padding: 2px 0; color: transparent; text-align: center; }
  .host-badge::after { content: 'H'; color: #6f7d77; font-size: 7px; }
}

@media (max-width: 999px) and (min-width: 761px) {
  body:has(.game-view:not(.hidden)) .site-header { height: 52px; }
  body:has(.game-view:not(.hidden)) main { height: calc(100dvh - 52px); }
  .game-topbar { min-height: 50px; grid-template-columns: 165px minmax(0,1fr) auto; gap: 10px; margin-bottom: 6px; }
  .game-heading { grid-column: auto; text-align: center; }
  .game-actions { width: auto; grid-column: auto; justify-self: end; overflow: visible; }
  .game-actions .ghost-button { width: 36px; min-width: 36px; min-height: 36px; padding: 0; }
  .game-actions .ghost-button span { display: none; }
  .game-layout {
    grid-template-columns: 155px minmax(0,1fr);
    grid-template-rows: minmax(0,1fr) auto;
    gap: 10px;
    align-items: center;
  }
  .players-panel { align-self: stretch; padding: 11px 9px; }
  .player-row { grid-template-columns: 27px minmax(0,1fr); gap: 6px; }
  .player-token { width: 27px; height: 27px; }
  .host-badge { display: none; }
  .board-column {
    width: min(100%,calc(100dvh - 190px));
    min-width: 0;
  }
  .board-frame { padding: 10px; border-radius: 20px; }
  .board-frame::before { inset: 10px; }
  .turn-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(150px,1fr) 128px 190px minmax(160px,1fr);
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
  }
  .turn-panel .turn-status { padding: 0; border: 0; }
  .turn-panel .dice-stage { min-height: 0; padding: 0; flex-direction: row; gap: 8px; }
  .turn-panel .dice-stage .dice { width: 48px; height: 48px; padding: 7px; border-radius: 13px; }
  .turn-panel .dice-stage p { display: none; }
  .turn-panel .turn-controls { grid-column: 3; }
  .turn-panel .roll-button { min-height: 44px; }
  .turn-panel .move-hint { grid-column: 4; margin: 0; text-align: left; }
  .turn-panel .activity { display: none; }
}

@media (max-width: 760px) {
  body:has(.game-view:not(.hidden)) .site-header {
    width: calc(100% - 14px);
    height: calc(48px + env(safe-area-inset-top));
  }
  body:has(.game-view:not(.hidden)) .site-header .creator-link { display: none; }
  body:has(.game-view:not(.hidden)) main {
    width: calc(100% - 14px);
    height: calc(100dvh - 48px - env(safe-area-inset-top));
  }
  .game-view { padding: 0 0 calc(6px + env(safe-area-inset-bottom)); }
  .game-topbar {
    min-height: 72px;
    grid-template-columns: auto minmax(0,1fr);
    grid-template-rows: 29px 39px;
    gap: 3px 8px;
    margin: 0 0 4px;
  }
  .game-topbar > div:first-child { min-width: 0; gap: 5px; }
  .game-topbar > div:first-child .eyebrow { display: none; }
  .room-code-button { padding: 5px 8px; border-radius: 9px; font-size: 14px; letter-spacing: 2px; }
  .game-heading { grid-column: 2; grid-row: 1; text-align: right; }
  .game-heading p { display: none; }
  .game-heading h1 { font-size: 16px; }
  .game-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    justify-content: center;
    gap: 5px;
    padding: 0;
    overflow: visible;
  }
  .game-actions .ghost-button {
    width: 38px;
    min-width: 38px;
    min-height: 36px;
    flex: 0 0 38px;
    padding: 0;
    border-radius: 10px;
  }
  .game-actions .ghost-button span { display: none; }
  .game-layout {
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 7px;
    align-items: start;
    align-content: start;
  }
  .game-view[data-status="playing"] .players-panel,
  .game-view[data-status="finished"] .players-panel {
    order: 0;
    width: 100%;
    max-height: 58px;
    display: block;
    padding: 4px 7px;
    overflow: hidden;
    border-top-width: 4px;
  }
  .game-view[data-status="playing"] .players-panel .panel-heading,
  .game-view[data-status="finished"] .players-panel .panel-heading,
  .game-view[data-status="playing"] .players-panel .lobby-action,
  .game-view[data-status="finished"] .players-panel .lobby-action,
  .game-view[data-status="playing"] .players-panel .network-address,
  .game-view[data-status="finished"] .players-panel .network-address { display: none; }
  .game-view[data-status="playing"] .players-list,
  .game-view[data-status="finished"] .players-list {
    grid-template-columns: repeat(4,minmax(0,1fr));
    gap: 4px;
    padding: 0;
  }
  .game-view[data-status="playing"] .player-row,
  .game-view[data-status="finished"] .player-row {
    min-height: 43px;
    grid-template-columns: 27px minmax(0,1fr);
    gap: 5px;
    padding: 2px 4px;
    border: 0;
    border-radius: 9px;
    background: rgba(255,255,255,.36);
  }
  .game-view[data-status="playing"] .player-info b,
  .game-view[data-status="finished"] .player-info b { max-width: 100%; font-size: 9px; }
  .game-view[data-status="playing"] .player-info span,
  .game-view[data-status="finished"] .player-info span { display: none; }
  .game-view[data-status="playing"] .active-turn,
  .game-view[data-status="finished"] .active-turn { background: rgba(255,255,255,.8); box-shadow: inset 0 0 0 1px currentColor; }
  .game-view[data-status="playing"] .active-turn::before,
  .game-view[data-status="finished"] .active-turn::before { display: none; }
  .board-column {
    order: 1;
    width: min(100%,calc(100dvh - 198px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
    min-width: 0;
    justify-self: center;
  }
  .board-frame {
    padding: 10px;
    border-radius: 4px;
    box-shadow:
      inset 0 0 0 2px rgba(255,255,255,.95),
      inset 0 0 0 5px rgba(199,207,210,.4),
      inset 0 -7px 10px rgba(104,118,122,.12),
      0 4px 0 #c5cbcd,
      0 9px 20px rgba(35,53,51,.18);
  }
  .board-frame::before { inset: 10px; border-radius: 1px; }
  .board-frame::after { inset: 3px; border-radius: 2px; }
  .ludo-board { border-width: 1.5px; border-radius: 1px; }
  .turn-panel {
    position: static;
    order: 2;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0,.86fr) 47px minmax(128px,1.25fr);
    grid-template-rows: auto auto;
    align-items: center;
    gap: 5px 7px;
    padding: 7px 8px;
    border-radius: 14px;
  }
  .turn-panel .turn-status { padding: 0; border: 0; }
  .turn-panel .turn-status h2 { font-size: 12px; }
  .turn-panel .turn-status p { display: none; }
  .turn-panel .dice-stage { min-height: 0; grid-column: 2; padding: 0; }
  .turn-panel .dice-stage .dice { width: 43px; height: 43px; gap: 3px; padding: 6px; border-radius: 11px; box-shadow: 0 4px 0 #c99a2b,0 7px 12px rgba(99,66,9,.15); }
  .turn-panel .dice-stage p { display: none; }
  .turn-panel .turn-controls { grid-column: 3; }
  .turn-panel .roll-button { min-height: 43px; padding: 0 8px; margin: 0; }
  .turn-panel .move-hint { grid-column: 1 / -1; max-height: 1.4em; margin: 0 2px; -webkit-line-clamp: 1; font-size: 7px; }
  .turn-panel .activity { display: none; }
  .turn-panel .roll-series { top: -15px; }

  .game-view[data-status="lobby"] .game-layout {
    grid-template-rows: minmax(0,1fr) auto;
  }
  .game-view[data-status="lobby"] .board-column {
    width: min(100%,calc(100dvh - 340px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  }
  .game-view[data-status="lobby"] .turn-panel { display: none; }
  .game-view[data-status="lobby"] .players-panel {
    order: 1;
    width: 100%;
    max-height: 204px;
    padding: 8px 10px;
    overflow: hidden;
  }
  .game-view[data-status="lobby"] .panel-heading { padding-bottom: 5px; }
  .game-view[data-status="lobby"] .panel-heading .eyebrow { display: none; }
  .game-view[data-status="lobby"] .panel-heading h2 { font-size: 14px; }
  .game-view[data-status="lobby"] .players-list { grid-template-columns: repeat(2,minmax(0,1fr)); padding-top: 2px; }
  .game-view[data-status="lobby"] .player-row { min-height: 34px; padding: 2px; }
  .game-view[data-status="lobby"] .player-token { width: 25px; height: 25px; }
  .game-view[data-status="lobby"] .lobby-action { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 5px; }
  .game-view[data-status="lobby"] .lobby-action .primary-button,
  .game-view[data-status="lobby"] .configure-rules-button { min-height: 36px; margin: 0; }
  .game-view[data-status="lobby"] .network-address { margin-top: 5px; padding-top: 5px; }
  .game-view[data-status="lobby"] .network-address > span { display: none; }
}

@media (max-width: 760px) and (max-height: 560px) and (orientation: landscape) {
  body:has(.game-view:not(.hidden)) .site-header {
    height: calc(40px + env(safe-area-inset-top));
  }
  body:has(.game-view:not(.hidden)) .brand-mark { width: 28px; height: 28px; }
  body:has(.game-view:not(.hidden)) main {
    height: calc(100dvh - 40px - env(safe-area-inset-top));
  }
  .game-topbar {
    min-height: 41px;
    grid-template-columns: 110px minmax(0,1fr) auto;
    grid-template-rows: 38px;
  }
  .game-heading { grid-column: 2; grid-row: 1; text-align: center; }
  .game-actions { width: auto; grid-column: 3; grid-row: 1; }
  .game-actions .ghost-button { width: 32px; min-width: 32px; min-height: 32px; flex-basis: 32px; }
  .game-layout { grid-template-columns: minmax(0,1fr) 180px; grid-template-rows: 1fr; }
  .game-view[data-status="playing"] .players-panel,
  .game-view[data-status="finished"] .players-panel { display: none; }
  .board-column { grid-column: 1; grid-row: 1; width: min(100%,calc(100dvh - 96px - env(safe-area-inset-top))); }
  .turn-panel { grid-column: 2; grid-row: 1; align-self: stretch; display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 7px 9px; }
  .turn-panel .turn-controls { width: 100%; }
  .turn-panel .dice-stage .dice { width: 52px; height: 52px; }
  .turn-panel .move-hint { max-height: 2.8em; -webkit-line-clamp: 2; }
  .game-view[data-status="lobby"] .board-column { width: min(100%,calc(100dvh - 96px - env(safe-area-inset-top))); }
  .game-view[data-status="lobby"] .players-panel { grid-column: 2; grid-row: 1; max-height: 100%; }
}

/* Keep the game chrome anchored to the board, rather than the browser edges. */
@media (min-width: 1400px) {
  .game-view {
    --board-rail-size: min(calc(100dvh - 190px),calc(100vw - 500px),940px);
  }
  .game-topbar,
  .game-layout {
    grid-template-columns: 205px var(--board-rail-size) 225px;
  }
  .board-column { width: var(--board-rail-size); }
}

@media (min-width: 1000px) {
  .game-topbar { justify-content: center !important; }
  .game-heading {
    grid-column: 2;
    width: 100%;
    justify-self: center;
    text-align: center;
  }
  .game-actions {
    grid-column: 3;
    width: 124px;
    display: grid;
    grid-template-columns: repeat(3,38px);
    gap: 5px;
    justify-self: start;
    align-content: center;
  }
  .game-actions .ghost-button {
    width: 38px;
    min-width: 38px;
    min-height: 36px;
    padding: 0;
  }
  .game-actions .ghost-button span { display: none; }
}

@media (max-width: 1399px) and (min-width: 1000px) {
  .game-view {
    --board-rail-size: min(calc(100dvh - 186px),calc(100vw - 432px),860px);
  }
  .game-topbar,
  .game-layout {
    grid-template-columns: 185px var(--board-rail-size) 205px;
  }
  .board-column { width: var(--board-rail-size); }
}

/* A clean ivory die reads like a physical tabletop die at every size. */
.dice {
  border-color: #d5ccbd;
  background: linear-gradient(145deg,#ffffff,#f3f0e9);
  box-shadow: 0 7px 0 #d7cec0,0 12px 20px rgba(70,55,37,.16),inset 0 1px 0 rgba(255,255,255,.95);
}
.pip { background: #302a23; }

@media (max-width: 999px) and (min-width: 761px) {
  .game-view { --board-rail-size: min(100%,calc(100dvh - 190px)); }
  .game-heading {
    width: var(--board-rail-size);
    justify-self: center;
    text-align: center;
  }
  .board-column { width: var(--board-rail-size); }
}

@media (max-width: 760px) {
  .game-topbar {
    position: relative;
    grid-template-columns: 1fr;
    grid-template-rows: 29px 39px;
  }
  .game-topbar > div:first-child {
    position: absolute;
    z-index: 1;
    left: 0;
    top: 0;
  }
  .game-heading {
    grid-column: 1;
    grid-row: 1;
    width: min(100%,calc(100% - 116px));
    max-width: calc(100% - 116px);
    justify-self: center;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .game-actions { grid-column: 1; }
  .turn-panel .dice-stage .dice {
    box-shadow: 0 4px 0 #d7cec0,0 7px 12px rgba(70,55,37,.14),inset 0 1px 0 rgba(255,255,255,.95);
  }
}

@media (max-width: 760px) and (max-height: 560px) and (orientation: landscape) {
  .game-topbar {
    grid-template-columns: minmax(0,1fr) 180px;
    grid-template-rows: 38px;
  }
  .game-topbar > div:first-child { display: none; }
  .game-heading {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    max-width: 100%;
  }
  .game-actions { grid-column: 2; grid-row: 1; }
}

/* Handheld table: plain, compact controls with the live rail clear of the turn card. */
@media (max-width: 760px) {
  .panel,
  .players-panel,
  .turn-panel,
  .game-view[data-status="playing"] .players-panel,
  .game-view[data-status="finished"] .players-panel {
    border-top-width: 1px;
    border-radius: 8px;
    box-shadow: 0 3px 0 #cedbd5,0 8px 18px rgba(37,68,59,.08);
  }
  .players-panel { border-top-color: var(--game-border); }
  .turn-panel { border-top-color: var(--game-border); }
  .game-view[data-status="playing"] .player-row,
  .game-view[data-status="finished"] .player-row { border-radius: 4px; }
  .game-actions { gap: 4px; }
  .game-actions .ghost-button,
  .room-code-button,
  .roll-button,
  .undo-button,
  .turn-panel .dice-stage .dice {
    border-radius: 7px;
    box-shadow: none;
  }
  .turn-panel { gap: 5px; }
  .camera-rail {
    right: 8px;
    bottom: calc(132px + env(safe-area-inset-bottom));
    width: min(252px,calc(100vw - 16px));
    max-height: min(38dvh,268px);
    padding: 7px;
    border-radius: 8px;
    box-shadow: 0 5px 16px rgba(25,57,48,.15);
  }
  .camera-rail.collapsed { width: auto; padding: 4px 6px; }
  .camera-rail-heading { margin-bottom: 5px; padding: 0 1px 5px; }
  .camera-rail-heading h2 { font-size: 12px; }
  .camera-rail-heading button { width: 32px; height: 32px; border-radius: 6px; }
  .camera-rail.collapsed .camera-rail-heading button { margin-left: 2px; }
  .camera-tile { border-radius: 7px; }
}

/* Mobile uses a document flow so media and turn controls can never overlap. */
@media (max-width: 760px) {
  body:has(.game-view:not(.hidden)) {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }
  body:has(.game-view:not(.hidden)) main {
    height: auto;
    min-height: calc(100dvh - 48px - env(safe-area-inset-top));
    overflow: visible;
  }
  .game-view {
    height: auto;
    min-height: calc(100dvh - 48px - env(safe-area-inset-top));
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    overflow: visible;
  }
  .game-topbar { margin-bottom: 10px; }
  .game-layout {
    flex: none;
    min-height: auto;
    grid-template-columns: minmax(0,1fr);
    grid-template-rows: repeat(4,auto);
    gap: 12px;
    overflow: visible;
  }
  .board-column {
    grid-column: 1;
    width: 100%;
    max-width: 100%;
  }
  /* Mobile hierarchy: keep the board first, then gameplay controls and
     supporting room information. Lobby mode hides the turn panel, so the
     Players card sits directly below the Ludo board. */
  .game-view[data-status] .board-column { order: 0; }
  .game-view[data-status] .turn-panel { order: 1; }
  .game-view[data-status] .players-panel { order: 2; }
  .turn-panel {
    position: static;
    bottom: auto;
    margin: 0;
  }
  .camera-rail,
  .camera-rail.collapsed {
    position: static;
    z-index: auto;
    grid-column: 1;
    order: 3;
    width: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 7px 8px;
    overflow: visible;
  }
  .camera-rail.collapsed .camera-rail-heading {
    min-height: 36px;
    margin: 0;
    padding: 0;
  }
  .camera-rail:not(.collapsed) .video-grid { margin-top: 7px; }
}

@media (max-width: 760px) and (max-height: 560px) and (orientation: landscape) {
  .game-layout {
    grid-template-columns: minmax(0,1fr) 180px;
    grid-template-rows: auto auto;
    gap: 10px;
  }
  .board-column { grid-column: 1; grid-row: 1; }
  .turn-panel { grid-column: 2; grid-row: 1; }
  .camera-rail,
  .camera-rail.collapsed { grid-column: 1 / -1; grid-row: 2; }
}

/* Spacious handheld table: every control stays in flow with a clear touch target. */
@media (max-width: 760px) and (orientation: portrait) {
  body:has(.game-view:not(.hidden)) .site-header,
  body:has(.game-view:not(.hidden)) main {
    width: calc(100% - 20px);
  }

  body:has(.game-view:not(.hidden)) .site-header {
    height: calc(56px + env(safe-area-inset-top));
  }

  body:has(.game-view:not(.hidden)) main {
    min-height: calc(100dvh - 56px - env(safe-area-inset-top));
  }

  .game-view {
    min-height: calc(100dvh - 56px - env(safe-area-inset-top));
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
  }

  .game-topbar {
    min-height: 96px;
    grid-template-rows: 36px 46px;
    row-gap: 10px;
    margin-bottom: 16px;
  }

  .game-topbar > div:first-child { top: 2px; }

  .room-code-button {
    min-height: 34px;
    padding: 6px 10px;
  }

  .game-heading {
    width: min(100%,calc(100% - 126px));
    max-width: calc(100% - 126px);
    align-self: center;
  }

  .game-heading h1 {
    font-size: 18px;
    line-height: 1.15;
  }

  .game-actions {
    min-height: 46px;
    gap: 8px;
  }

  .game-actions .ghost-button {
    width: 42px;
    min-width: 42px;
    min-height: 42px;
    flex-basis: 42px;
  }

  .game-layout { gap: 18px; }

  .game-view[data-status="playing"] .players-panel,
  .game-view[data-status="finished"] .players-panel {
    max-height: none;
    padding: 10px;
    overflow: visible;
  }

  .game-view[data-status="playing"] .players-list,
  .game-view[data-status="finished"] .players-list {
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 8px;
  }

  .game-view[data-status="playing"] .player-row,
  .game-view[data-status="finished"] .player-row {
    min-height: 46px;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid var(--game-border);
    background: rgba(255,255,255,.78);
  }

  .game-view[data-status="playing"] .player-token,
  .game-view[data-status="finished"] .player-token {
    width: 30px;
    height: 30px;
  }

  .board-column { margin: 0 auto; }

  .turn-panel {
    grid-template-columns: minmax(0,1fr) 58px;
    grid-template-rows: auto auto auto;
    gap: 12px;
    padding: 14px;
  }

  .turn-panel .turn-status {
    grid-column: 1;
    grid-row: 1;
  }

  .turn-panel .turn-status h2 { font-size: 16px; }

  .turn-panel .dice-stage {
    grid-column: 2;
    grid-row: 1;
  }

  .turn-panel .dice-stage .dice {
    width: 54px;
    height: 54px;
    padding: 8px;
  }

  .turn-panel .turn-controls {
    width: 100%;
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .turn-panel .roll-button {
    min-height: 50px;
    padding: 0 16px;
    font-size: 12px;
  }

  .turn-panel .undo-button {
    min-height: 44px;
    margin-top: 10px;
    font-size: 10px;
  }

  .turn-panel .move-hint {
    max-height: none;
    grid-column: 1 / -1;
    grid-row: 3;
    margin: 0;
    overflow: visible;
    -webkit-line-clamp: unset;
    text-align: center;
    font-size: 9px;
    line-height: 1.45;
  }

  .camera-rail,
  .camera-rail.collapsed {
    margin-top: 2px;
    padding: 10px 12px;
  }

  .camera-rail.collapsed .camera-rail-heading {
    min-height: 42px;
  }

  .camera-rail-heading h2 { font-size: 14px; }
}

@media (max-width: 430px) and (orientation: portrait) {
  body:has(.game-view:not(.hidden)) .site-header,
  body:has(.game-view:not(.hidden)) main {
    width: calc(100% - 16px);
  }

  .game-topbar { margin-bottom: 14px; }
  .game-actions { gap: 6px; }
  .game-actions .ghost-button {
    width: 40px;
    min-width: 40px;
    flex-basis: 40px;
  }
  .game-layout { gap: 16px; }
  .turn-panel { padding: 12px; }
}

@media (max-width: 360px) and (orientation: portrait) {
  .game-actions { gap: 5px; }
  .game-actions .ghost-button {
    width: 38px;
    min-width: 38px;
    flex-basis: 38px;
  }
  .game-view[data-status="playing"] .players-list,
  .game-view[data-status="finished"] .players-list {
    grid-template-columns: 1fr;
  }
}

/* Room chat: a compact tabletop drawer on large screens and normal document
   flow on handhelds, so conversation never covers the board or dice. */
.chat-button { position: relative; }
.chat-button.live {
  border-color: #83bda6;
  background: #e6f7ed;
  color: var(--green);
}
.chat-unread-badge {
  position: absolute;
  right: -5px;
  top: -6px;
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0 4px;
  border: 2px solid white;
  border-radius: 9px;
  background: var(--red);
  color: white;
  box-shadow: 0 3px 8px rgba(154,49,43,.25);
  font: 900 8px/1 Inter,system-ui,sans-serif;
}
.chat-panel {
  position: fixed;
  z-index: 19;
  left: 18px;
  right: auto;
  bottom: 18px;
  width: min(330px,calc(100vw - 36px));
  height: min(480px,calc(100dvh - 110px));
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 20px 65px rgba(25,57,48,.2);
}
.chat-panel-heading {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #e5ece8;
}
.chat-panel-heading > div {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-heading-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #e9f6f0;
  color: var(--green);
}
.chat-heading-icon .ui-icon { width: 17px; height: 17px; }
.chat-panel-heading p {
  margin: 0 0 2px;
  color: #84938e;
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 1.25px;
  text-transform: uppercase;
}
.chat-panel-heading h2 {
  margin: 0;
  font-family: ui-rounded,"Arial Rounded MT Bold","Trebuchet MS",sans-serif;
  font-size: 16px;
  line-height: 1.05;
}
.chat-panel-heading > button {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid #dce6e1;
  border-radius: 9px;
  background: #f8faf9;
  color: #61736c;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}
.chat-messages {
  flex: 1 1 auto;
  min-height: 150px;
  padding: 14px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  background: #f7faf8;
}
.chat-empty {
  min-height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 24px;
  color: #71827b;
  text-align: center;
}
.chat-empty > span { margin-bottom: 8px; font-size: 24px; }
.chat-empty b { color: var(--ink); font-size: 12px; }
.chat-empty p { max-width: 190px; margin: 5px 0 0; font-size: 9px; line-height: 1.45; }
.chat-message {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  margin: 0 0 11px;
}
.chat-message.own { flex-direction: row-reverse; }
.chat-avatar {
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--chat-player-color);
  color: white;
  box-shadow: 0 2px 7px rgba(29,61,52,.14);
  font: 900 10px/1 Georgia,serif;
}
.chat-message > div {
  max-width: calc(100% - 50px);
  padding: 8px 10px;
  border: 1px solid #dfe8e3;
  border-radius: 11px 11px 11px 3px;
  background: white;
  color: #29473f;
  box-shadow: 0 3px 9px rgba(32,61,53,.05);
}
.chat-message.own > div {
  border-color: #add7c5;
  border-radius: 11px 11px 3px 11px;
  background: #e8f6ef;
}
.chat-message > div > p {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 4px;
}
.chat-message > div > p b { color: var(--chat-player-color); font-size: 8px; }
.chat-message > div > p time { color: #9aa7a2; font-size: 7px; }
.chat-message > div > span {
  display: block;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 10px;
  line-height: 1.45;
}
.chat-form {
  display: grid;
  grid-template-columns: minmax(0,1fr) 42px;
  align-items: end;
  gap: 8px;
  padding: 11px 12px 7px;
  border-top: 1px solid #e5ece8;
  background: white;
}
.chat-form textarea {
  width: 100%;
  min-height: 42px;
  max-height: 92px;
  resize: none;
  padding: 11px 12px;
  border: 1px solid #d7e3dd;
  border-radius: 9px;
  background: #f8faf9;
  color: var(--ink);
  font: 500 11px/1.45 Inter,system-ui,sans-serif;
}
.chat-form textarea::placeholder { color: #93a19c; }
.chat-form button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: var(--green);
  color: white;
  cursor: pointer;
}
.chat-form button .ui-icon { width: 18px; height: 18px; }
.chat-form button:disabled { cursor: wait; opacity: .5; }
.chat-privacy {
  margin: 0;
  padding: 0 12px 10px;
  background: white;
  color: #93a19c;
  font-size: 7px;
  text-align: center;
}

@media (max-width: 760px) {
  .game-layout { grid-template-rows: repeat(5,auto); }
  .chat-panel {
    position: static;
    z-index: auto;
    left: auto;
    right: auto;
    grid-column: 1;
    order: 4;
    width: 100%;
    height: auto;
    min-height: 330px;
    max-height: none;
    margin: 0;
    border-radius: 8px;
    box-shadow: 0 3px 0 #cedbd5,0 8px 18px rgba(37,68,59,.08);
  }
  .chat-messages { height: min(42dvh,300px); min-height: 210px; flex: none; }
  .chat-panel-heading > button,
  .chat-form button { min-width: 44px; min-height: 44px; }
}

@media (max-width: 760px) and (max-height: 560px) and (orientation: landscape) {
  .game-layout { grid-template-rows: auto auto auto; }
  .chat-panel { grid-column: 1 / -1; grid-row: 3; }
  .chat-messages { height: 210px; min-height: 210px; }
}
