:root {
  color-scheme: dark;
  --ink: #fff4d2;
  --ink-dark: #243238;
  --muted: #b9ceca;
  --panel: rgba(12, 32, 38, 0.9);
  --panel-soft: rgba(21, 52, 56, 0.86);
  --line: rgba(255, 220, 132, 0.34);
  --cream: #fff1c6;
  --coral: #e95e45;
  --gold: #efbd4e;
  --teal: #2ca7a0;
  --sky: #5ec7dc;
  --green: #55b96d;
  --shadow: rgba(2, 10, 15, 0.46);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #173f44;
  color: var(--ink);
  font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
}

button,
input,
select {
  width: 100%;
  min-width: 0;
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid rgba(255, 221, 137, 0.48);
  border-radius: 6px;
  background: #fff0c5;
  color: var(--ink-dark);
  font-weight: 900;
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(39, 48, 51, 0.16), 0 7px 15px rgba(2, 10, 15, 0.2);
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

button:hover:not(:disabled) {
  filter: brightness(1.04) saturate(1.05);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 2px 0 rgba(39, 48, 51, 0.2);
}

button:disabled,
button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.42;
}

input,
select {
  min-height: 38px;
  border: 1px solid rgba(255, 220, 132, 0.34);
  border-radius: 5px;
  background: rgba(255, 248, 222, 0.96);
  color: #203136;
  padding: 7px 9px;
  font-weight: 850;
  outline: none;
}

input:focus,
select:focus {
  border-color: #efbd4e;
  box-shadow: 0 0 0 3px rgba(239, 189, 78, 0.18);
}

.app-shell,
.game-layout,
.board-panel {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

.board-panel {
  background: #2b9ead;
  touch-action: none;
}

#boardCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  outline: 0;
  touch-action: none;
}

#boardCanvas:active {
  cursor: grabbing;
}

.topbar {
  position: fixed;
  z-index: 12;
  top: 12px;
  left: 14px;
  right: 14px;
  height: 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 29, 34, 0.9);
  box-shadow: 0 12px 26px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(12px) saturate(1.12);
}

.brand,
.player-line,
.turn-heading,
.block-heading,
.room-code-line {
  display: flex;
  align-items: center;
}

.brand {
  min-width: 0;
  gap: 10px;
}

.brand-mark,
.lobby-emblem {
  flex: 0 0 auto;
  border: 2px solid rgba(255, 242, 194, 0.45);
  background: conic-gradient(from 225deg, #3477d4, #2ca7a0, #75c95e, #efbd4e, #e95e45, #3477d4);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.18), 0 7px 14px rgba(0, 0, 0, 0.28);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
}

.brand h1 {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1;
  letter-spacing: 0;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.stat-strip {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(76px, 1fr));
  gap: 6px;
}

.stat-strip div {
  min-width: 0;
  padding: 6px 9px;
  border: 1px solid rgba(255, 221, 137, 0.46);
  border-radius: 6px;
  background: #fff0c5;
  color: #203136;
  text-align: center;
  box-shadow: inset 0 -3px 0 rgba(39, 48, 51, 0.13);
}

.stat-strip strong,
.stat-strip span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-strip strong {
  font-size: 0.94rem;
}

.stat-strip span {
  color: #68767a;
  font-size: 0.62rem;
  font-weight: 900;
}

.player-ribbon {
  position: fixed;
  z-index: 11;
  top: 84px;
  left: 14px;
  right: 382px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 3px;
  scrollbar-width: none;
}

.player-ribbon::-webkit-scrollbar,
.weather-ribbon::-webkit-scrollbar {
  display: none;
}

.player-chip {
  flex: 1 1 120px;
  min-width: 112px;
  max-width: 190px;
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 43px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  background: rgba(10, 32, 37, 0.82);
  color: #eef8ed;
  box-shadow: 0 8px 18px rgba(2, 10, 15, 0.22);
  backdrop-filter: blur(9px);
}

.player-chip.is-current {
  border-color: #ffd36c;
  background: rgba(27, 57, 55, 0.94);
  box-shadow: 0 0 0 2px rgba(255, 211, 108, 0.18), 0 9px 20px rgba(2, 10, 15, 0.3);
}

.player-chip.is-eliminated {
  filter: grayscale(0.85);
  opacity: 0.5;
}

.player-chip-color {
  width: 9px;
  height: 29px;
  border-radius: 3px;
}

.player-chip-copy {
  min-width: 0;
}

.player-chip-copy strong,
.player-chip-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-chip-copy strong {
  font-size: 0.72rem;
}

.player-chip-copy span,
.player-chip-lap {
  color: #bcd0ca;
  font-size: 0.58rem;
  font-weight: 850;
}

.weather-ribbon {
  position: fixed;
  z-index: 10;
  top: 134px;
  left: 14px;
  right: 382px;
  display: flex;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
}

.weather-chip {
  flex: 0 0 auto;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 5px;
  background: rgba(12, 36, 41, 0.78);
  color: #eff9f2;
  font-size: 0.65rem;
  font-weight: 900;
  backdrop-filter: blur(8px);
}

.weather-chip.is-alert {
  border-color: rgba(255, 194, 104, 0.62);
  color: #ffe3a1;
}

.control-panel {
  position: fixed;
  z-index: 12;
  top: 84px;
  right: 14px;
  bottom: 14px;
  width: 354px;
  display: grid;
  grid-template-rows: min-content minmax(0, 1fr) min-content;
  gap: 8px;
  min-width: 0;
}

.panel-block {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 28px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(12px) saturate(1.08);
}

.turn-block {
  display: grid;
  gap: 8px;
}

.turn-heading,
.block-heading,
.room-code-line {
  justify-content: space-between;
  gap: 10px;
}

.player-line {
  min-width: 0;
  gap: 9px;
}

.player-line strong {
  display: block;
  max-width: 180px;
  overflow: hidden;
  color: #fff2c8;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-swatch {
  width: 15px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 4px;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.18), 0 0 0 2px rgba(255, 241, 194, 0.24);
}

.panel-kicker,
.lobby-kicker,
.result-kicker {
  display: block;
  color: #f0c45e;
  font-size: 0.64rem;
  font-weight: 950;
  letter-spacing: 0.08em;
}

.controller-badge {
  flex: 0 0 auto;
  padding: 4px 7px;
  border: 1px solid rgba(94, 199, 220, 0.38);
  border-radius: 4px;
  background: rgba(94, 199, 220, 0.12);
  color: #bceef5;
  font-size: 0.58rem;
  font-weight: 950;
}

.wallet-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.wallet {
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid rgba(255, 221, 137, 0.45);
  border-radius: 6px;
  background: #fff0c5;
  color: #253439;
  box-shadow: inset 0 -3px 0 rgba(39, 48, 51, 0.12);
}

.travel-wallet {
  border-color: rgba(94, 199, 220, 0.5);
  background: #d9f3f3;
}

.wallet span,
.wallet strong {
  display: block;
}

.wallet span {
  color: #69767a;
  font-size: 0.62rem;
  font-weight: 900;
}

.wallet strong {
  margin-top: 1px;
  overflow: hidden;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badges {
  min-height: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 2px 7px;
  border: 1px solid rgba(107, 216, 182, 0.34);
  border-radius: 4px;
  background: rgba(107, 216, 182, 0.12);
  color: #ddfff2;
  font-size: 0.62rem;
  font-weight: 900;
}

.dice-readout {
  min-height: 75px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 221, 137, 0.42);
  border-radius: 7px;
  background: #14242f;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.18);
}

.dice-graphic {
  width: 100%;
  display: grid;
  grid-template-columns: 48px 48px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
}

.die {
  width: 48px;
  height: 48px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
  padding: 7px;
  border-radius: 7px;
  background: #f8f5e9;
  box-shadow: inset 0 -4px 0 rgba(31, 42, 50, 0.14), 0 6px 11px rgba(0, 0, 0, 0.24);
}

.pip {
  width: 8px;
  height: 8px;
  align-self: center;
  justify-self: center;
  border-radius: 50%;
  background: #243238;
}

.dice-total {
  min-width: 0;
  display: grid;
  gap: 2px;
  color: #fff2c8;
}

.dice-total strong {
  font-size: 1.28rem;
}

.dice-total span {
  overflow: hidden;
  color: #bdd1cd;
  font-size: 0.66rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dice-placeholder {
  color: #fff2c8;
  font-size: 1.35rem;
  font-weight: 950;
}

.action-grid {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.action-grid button {
  min-width: 0;
  overflow: hidden;
  min-height: 36px;
  padding: 5px 6px;
  font-size: 0.72rem;
}

.primary-action {
  grid-column: 1 / -1;
  min-height: 45px !important;
  border-color: rgba(255, 218, 130, 0.65);
  background: #e95e45;
  color: #fff8dc;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.24);
}

.button-icon {
  display: inline-grid;
  width: 1.25em;
  margin-right: 2px;
  place-items: center;
}

.intel-panel {
  min-height: 0;
  overflow: hidden;
}

.intel-panel-toolbar {
  min-width: 0;
}

.intel-close-button {
  display: none;
}

.panel-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 10px;
}

.panel-tab {
  min-height: 30px;
  padding: 4px 6px;
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.07);
  color: #bdd1cd;
  box-shadow: none;
  font-size: 0.68rem;
}

.panel-tab.is-active {
  border-color: rgba(255, 211, 108, 0.5);
  background: #efbd4e;
  color: #263439;
}

.panel-view {
  display: none;
  max-height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
}

.panel-view.is-active {
  display: block;
}

#tileTitle {
  margin: 5px 0 8px;
  color: #fff2c8;
  font-size: 1.06rem;
  line-height: 1.25;
}

.tile-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.meta-pill {
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid rgba(255, 221, 137, 0.35);
  border-radius: 5px;
  background: rgba(255, 242, 202, 0.95);
  color: #253439;
}

.meta-pill span,
.meta-pill strong {
  display: block;
}

.meta-pill span {
  color: #6b777a;
  font-size: 0.58rem;
  font-weight: 950;
}

.meta-pill strong {
  margin-top: 1px;
  overflow-wrap: anywhere;
  font-size: 0.78rem;
}

.tile-detail {
  margin: 9px 0 0;
  color: #d7e8e3;
  font-size: 0.76rem;
  line-height: 1.48;
}

.region-progress,
.event-log {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.progress-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 6px;
  color: #edf7ef;
  font-size: 0.66rem;
  font-weight: 850;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(255, 247, 219, 0.2);
}

.progress-fill {
  height: 100%;
  background: var(--green);
}

.event-log {
  margin-bottom: 0;
  padding: 0;
  list-style: none;
}

.event-log li {
  padding: 7px 8px;
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  background: rgba(255, 247, 219, 0.09);
  color: #edf7ef;
  font-size: 0.68rem;
  line-height: 1.4;
}

.new-game-button {
  min-height: 32px;
  background: rgba(12, 36, 41, 0.88);
  color: #d4e7e2;
  box-shadow: none;
}

.board-tools {
  position: fixed;
  z-index: 13;
  left: 14px;
  bottom: 14px;
  display: grid;
  grid-template-columns: repeat(7, 36px);
  gap: 5px;
}

.board-tools button {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

#intelToggleButton {
  display: none;
}

.event-toast {
  position: fixed;
  z-index: 25;
  left: 50%;
  top: 174px;
  max-width: min(560px, calc(100vw - 420px));
  padding: 10px 14px;
  border: 1px solid rgba(255, 211, 108, 0.58);
  border-radius: 6px;
  background: rgba(20, 41, 45, 0.94);
  color: #fff2c8;
  font-size: 0.78rem;
  font-weight: 900;
  box-shadow: 0 12px 26px rgba(2, 10, 15, 0.36);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.event-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.start-screen,
.result-screen,
.route-choice-dialog {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 20, 24, 0.64);
  backdrop-filter: blur(7px) saturate(0.82);
}

.start-screen[hidden],
.result-screen[hidden],
.route-choice-dialog[hidden] {
  display: none;
}

.route-choice-dialog {
  z-index: 65;
  background: rgba(5, 20, 24, 0.72);
}

.route-choice-frame {
  width: min(470px, 100%);
  padding: 20px;
  border: 1px solid rgba(255, 220, 132, 0.58);
  border-radius: 8px;
  background: rgba(9, 31, 36, 0.98);
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.54), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.route-choice-kicker {
  color: var(--gold);
  font-size: 0.64rem;
  font-weight: 950;
}

.route-choice-frame h2 {
  margin: 5px 0 0;
  color: #fff2c8;
  font-size: 1.45rem;
  letter-spacing: 0;
}

.route-choice-frame > p {
  margin: 8px 0 15px;
  color: #b9ceca;
  font-size: 0.74rem;
}

.route-choice-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.route-choice-button {
  min-height: 82px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-content: center;
  gap: 4px 8px;
  padding: 11px;
  background: rgba(255, 242, 202, 0.1);
  color: #edf7ef;
  box-shadow: none;
  text-align: left;
}

.route-choice-button .route-arrow {
  grid-row: 1 / span 2;
  align-self: center;
  color: #ffd46e;
  font-size: 1.45rem;
  text-align: center;
}

.route-choice-button strong,
.route-choice-button small {
  display: block;
}

.route-choice-button strong {
  color: #fff2c8;
  font-size: 0.82rem;
}

.route-choice-button small {
  color: #abc2bd;
  font-size: 0.62rem;
}

.route-choice-cancel {
  min-height: 34px;
  margin-top: 9px;
  background: rgba(255, 255, 255, 0.05);
  color: #b9ceca;
  box-shadow: none;
}

.lobby-frame {
  min-width: 0;
  width: min(1060px, 100%);
  max-height: calc(100dvh - 36px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid rgba(255, 220, 132, 0.52);
  border-radius: 8px;
  background: rgba(9, 31, 36, 0.96);
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.52), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.lobby-header {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 17px 20px 13px;
  border-bottom: 1px solid rgba(255, 220, 132, 0.2);
}

.lobby-emblem {
  width: 58px;
  height: 58px;
  border-radius: 8px;
}

.lobby-header h2 {
  margin: 2px 0 0;
  color: #fff2c8;
  font-size: 1.9rem;
  line-height: 1;
  letter-spacing: 0;
}

.lobby-header p {
  margin: 6px 0 0;
  color: #b9ceca;
  font-size: 0.82rem;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255, 220, 132, 0.16);
}

.mode-button {
  min-height: 72px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  column-gap: 9px;
  padding: 8px 10px;
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #edf7ef;
  box-shadow: none;
  text-align: left;
}

.mode-button.is-active {
  border-color: rgba(255, 211, 108, 0.62);
  background: rgba(239, 189, 78, 0.16);
  box-shadow: inset 0 -3px 0 rgba(239, 189, 78, 0.26);
}

.mode-icon {
  grid-row: 1 / span 2;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 211, 108, 0.4);
  border-radius: 6px;
  background: rgba(239, 189, 78, 0.13);
  color: #ffd879;
  font-size: 0.68rem;
  font-weight: 950;
}

.mode-button strong,
.mode-button small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-button strong {
  align-self: end;
  font-size: 0.78rem;
}

.mode-button small {
  align-self: start;
  color: #a9bfba;
  font-size: 0.62rem;
  font-weight: 750;
}

.lobby-content {
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(300px, 0.9fr);
  gap: 16px;
  overflow-y: auto;
  padding: 14px 20px;
}

.setup-section,
.mode-panel {
  min-width: 0;
}

.setup-section {
  display: grid;
  align-content: start;
  gap: 8px;
}

.setup-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
}

.setup-row label,
.setup-label,
.lan-actions label span {
  color: #c6d9d4;
  font-size: 0.72rem;
  font-weight: 900;
}

.lap-options {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.lap-option {
  min-height: 38px;
  padding: 5px;
  border-color: rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.06);
  color: #dcebe6;
  box-shadow: none;
  font-size: 0.68rem;
}

.lap-option.is-active {
  border-color: rgba(239, 189, 78, 0.72);
  background: rgba(239, 189, 78, 0.2);
  color: #ffe29a;
  box-shadow: inset 0 -3px 0 rgba(239, 189, 78, 0.24);
}

.lap-custom-input {
  grid-column: 1 / -1;
  min-height: 36px;
}

.player-setup-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 4px;
}

.player-setup-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) 62px;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.045);
}

.player-setup-color {
  width: 12px;
  height: 31px;
  border-radius: 3px;
}

.player-setup-row input {
  width: 100%;
  min-height: 32px;
  padding: 5px 7px;
  font-size: 0.7rem;
}

.player-kind {
  color: #a9c2bd;
  font-size: 0.6rem;
  font-weight: 950;
  text-align: center;
}

.mode-panel {
  display: none;
}

.mode-panel.is-active {
  display: block;
}

.mission-board,
.lan-actions,
.lan-room-panel {
  padding: 13px;
  border: 1px solid rgba(255, 220, 132, 0.24);
  border-radius: 7px;
  background: rgba(255, 242, 202, 0.08);
}

.mission-board span,
.mission-board strong,
.mission-board p {
  display: block;
}

.mission-board span {
  color: #efbd4e;
  font-size: 0.68rem;
  font-weight: 950;
}

.mission-board strong {
  margin-top: 7px;
  color: #fff2c8;
  font-size: 1.12rem;
}

.mission-board p,
.lan-room-panel p {
  margin: 8px 0 0;
  color: #bed2cd;
  font-size: 0.72rem;
  line-height: 1.5;
}

.lan-actions {
  display: grid;
  gap: 8px;
}

.lan-actions label {
  display: grid;
  gap: 5px;
}

.join-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 7px;
}

.lan-room-panel {
  margin-top: 8px;
}

.room-code-line strong {
  color: #ffd46e;
  font-size: 1.5rem;
  letter-spacing: 0.12em;
}

.lan-player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}

.lan-player-pill {
  padding: 4px 7px;
  border: 1px solid rgba(94, 199, 220, 0.32);
  border-radius: 4px;
  background: rgba(94, 199, 220, 0.1);
  color: #d8f5f6;
  font-size: 0.66rem;
  font-weight: 900;
}

.lobby-footer {
  min-height: 62px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 330px);
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  border-top: 1px solid rgba(255, 220, 132, 0.2);
  background: rgba(5, 22, 26, 0.58);
}

.lobby-footer-actions {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(92px, 0.75fr) minmax(128px, 1.25fr);
  gap: 7px;
}

.install-pwa-button {
  min-height: 42px;
  background: rgba(94, 199, 220, 0.13);
  border-color: rgba(94, 199, 220, 0.44);
  color: #dcf8fa;
  box-shadow: none;
}

.install-pwa-button.is-ready {
  background: #2ca7a0;
  color: #fffdf1;
  box-shadow: inset 0 -3px 0 rgba(22, 74, 72, 0.28), 0 7px 15px rgba(2, 10, 15, 0.2);
}

.lobby-footer span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #b9ceca;
  font-size: 0.72rem;
  font-weight: 800;
}

.lobby-start-button {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  background: #e95e45;
  color: #fff8dc;
}

.result-frame {
  width: min(520px, 100%);
  padding: 22px;
  border: 1px solid rgba(255, 220, 132, 0.55);
  border-radius: 8px;
  background: rgba(9, 31, 36, 0.97);
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.52);
}

.result-frame h2 {
  margin: 5px 0 15px;
  color: #fff2c8;
}

.ranking-list {
  display: grid;
  gap: 7px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.ranking-row {
  display: grid;
  grid-template-columns: 34px 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
}

.ranking-place {
  color: #f0c45e;
  font-size: 1rem;
  font-weight: 950;
}

.ranking-color {
  width: 10px;
  height: 30px;
  border-radius: 3px;
}

.ranking-copy strong,
.ranking-copy span {
  display: block;
}

.ranking-copy span,
.ranking-value {
  color: #afc5c0;
  font-size: 0.66rem;
  font-weight: 850;
}

body.is-lobby .topbar,
body.is-lobby .player-ribbon,
body.is-lobby .weather-ribbon,
body.is-lobby .control-panel,
body.is-lobby .board-tools {
  opacity: 0.18;
  pointer-events: none;
}

@media (max-width: 980px) {
  .topbar {
    top: 7px;
    left: 7px;
    right: 7px;
    height: 54px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand h1 {
    font-size: 1rem;
  }

  .brand p {
    display: none;
  }

  .player-ribbon {
    top: 68px;
    left: 7px;
    right: 7px;
  }

  .weather-ribbon {
    top: 117px;
    left: 7px;
    right: 7px;
  }

  .control-panel {
    top: auto;
    left: 7px;
    right: 7px;
    bottom: 7px;
    width: auto;
    max-height: 41dvh;
    grid-template-columns: minmax(300px, 0.9fr) minmax(260px, 1.1fr);
    grid-template-rows: minmax(0, 1fr) min-content;
  }

  .turn-block,
  .intel-panel {
    min-height: 0;
    overflow-y: auto;
  }

  .new-game-button {
    grid-column: 1 / -1;
  }

  .board-tools {
    bottom: calc(41dvh + 15px);
    left: 7px;
  }

  .event-toast {
    top: 151px;
    max-width: calc(100vw - 30px);
  }
}

@media (max-width: 700px) {
  html,
  body,
  .app-shell,
  .game-layout,
  .board-panel {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body {
    position: fixed;
    inset: 0;
  }

  .topbar {
    top: calc(env(safe-area-inset-top, 0px) + 4px);
    height: 42px;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 3px;
    padding: 4px;
  }

  .brand {
    width: 28px;
  }

  .brand-mark {
    width: 24px;
    height: 24px;
    border-radius: 5px;
  }

  .brand div {
    display: none;
  }

  .stat-strip {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px;
  }

  .stat-strip div {
    padding: 3px 2px;
    border-radius: 4px;
  }

  .stat-strip strong {
    font-size: 0.62rem;
  }

  .stat-strip span {
    font-size: 0.45rem;
  }

  .player-ribbon {
    top: calc(env(safe-area-inset-top, 0px) + 51px);
    left: 4px;
    right: 4px;
    gap: 3px;
  }

  .player-chip {
    flex: 0 0 91px;
    min-width: 91px;
    min-height: 32px;
    grid-template-columns: 6px minmax(0, 1fr);
    gap: 4px;
    padding: 3px 4px;
    border-radius: 4px;
  }

  .player-chip-color {
    width: 6px;
    height: 22px;
  }

  .player-chip-copy strong {
    font-size: 0.54rem;
  }

  .player-chip-copy span,
  .player-chip-lap {
    font-size: 0.44rem;
  }

  .player-chip-lap {
    display: none;
  }

  .weather-ribbon {
    top: calc(env(safe-area-inset-top, 0px) + 87px);
    left: 4px;
    right: 4px;
    gap: 3px;
  }

  .weather-chip {
    min-height: 20px;
    padding: 2px 5px;
    font-size: 0.48rem;
  }

  .control-panel {
    left: 4px;
    right: 4px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 4px);
    max-height: 34dvh;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 4px;
    overflow-y: auto;
  }

  .panel-block {
    padding: 5px;
    border-radius: 5px;
  }

  .turn-block {
    gap: 4px;
  }

  .player-swatch {
    width: 8px;
    height: 25px;
  }

  .player-line strong {
    max-width: 115px;
    font-size: 0.68rem;
  }

  .panel-kicker,
  .controller-badge {
    font-size: 0.45rem;
  }

  .controller-badge {
    padding: 2px 4px;
  }

  .wallet {
    padding: 3px 5px;
  }

  .wallet span {
    font-size: 0.44rem;
  }

  .wallet strong {
    font-size: 0.66rem;
  }

  .status-badges {
    min-height: 16px;
  }

  .badge {
    min-height: 15px;
    padding: 1px 4px;
    font-size: 0.44rem;
  }

  .dice-readout {
    min-height: 40px;
  }

  .dice-graphic {
    grid-template-columns: 28px 28px minmax(0, 1fr);
    gap: 4px;
    padding: 3px 4px;
  }

  .die {
    width: 28px;
    height: 28px;
    gap: 1px;
    padding: 4px;
    border-radius: 5px;
  }

  .pip {
    width: 5px;
    height: 5px;
  }

  .dice-total strong {
    font-size: 0.76rem;
  }

  .dice-total span {
    font-size: 0.44rem;
  }

  .action-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 3px;
  }

  .action-grid button,
  button {
    min-height: 27px;
    padding: 3px 2px;
    border-radius: 4px;
    font-size: 0.51rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .primary-action {
    grid-column: span 6;
    min-height: 32px !important;
  }

  .button-icon {
    display: none;
  }

  .intel-panel {
    display: none;
  }

  .new-game-button {
    display: none;
  }

  .board-tools {
    left: 5px;
    bottom: calc(34dvh + env(safe-area-inset-bottom, 0px) + 10px);
    grid-template-columns: repeat(5, 27px);
    gap: 3px;
  }

  .board-tools button {
    width: 27px;
    min-height: 27px;
  }

  #intelToggleButton {
    display: block;
  }

  .intel-panel.is-mobile-open {
    position: fixed;
    left: 4px;
    right: 4px;
    bottom: calc(34dvh + env(safe-area-inset-bottom, 0px) + 8px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    max-height: 31dvh;
    overflow: hidden;
  }

  .intel-panel.is-mobile-open .intel-panel-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 30px;
    align-items: start;
    gap: 5px;
    margin-bottom: 9px;
  }

  .intel-panel.is-mobile-open .panel-tabs {
    margin-bottom: 0;
  }

  .intel-panel.is-mobile-open .intel-close-button {
    display: grid;
    width: 30px;
    min-height: 30px;
    padding: 0;
    place-items: center;
    background: rgba(255, 255, 255, 0.08);
    color: #f6eac6;
    box-shadow: none;
    font-size: 1.15rem;
    line-height: 1;
  }

  .intel-panel.is-mobile-open .panel-view.is-active {
    min-height: 0;
    overflow-y: auto;
  }

  .event-toast {
    top: calc(env(safe-area-inset-top, 0px) + 114px);
    max-width: calc(100vw - 16px);
    padding: 6px 8px;
    font-size: 0.58rem;
  }

  .start-screen,
  .result-screen,
  .route-choice-dialog {
    align-items: start;
    overflow-y: auto;
    padding: calc(env(safe-area-inset-top, 0px) + 7px) 6px calc(env(safe-area-inset-bottom, 0px) + 7px);
  }

  .route-choice-frame {
    padding: 14px;
  }

  .route-choice-list {
    grid-template-columns: 1fr;
  }

  .route-choice-button {
    min-height: 62px;
  }

  .lobby-frame {
    max-height: none;
    overflow: visible;
  }

  .lobby-header {
    gap: 9px;
    padding: 10px;
  }

  .lobby-emblem {
    width: 40px;
    height: 40px;
  }

  .lobby-header h2 {
    font-size: 1.18rem;
  }

  .lobby-header p {
    font-size: 0.62rem;
  }

  .mode-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 7px;
  }

  .mode-button {
    min-height: 54px;
    grid-template-columns: 32px minmax(0, 1fr);
    column-gap: 6px;
    padding: 5px;
  }

  .mode-icon {
    width: 32px;
    height: 32px;
    font-size: 0.52rem;
  }

  .mode-button strong {
    font-size: 0.62rem;
  }

  .mode-button small {
    font-size: 0.5rem;
  }

  .lobby-content {
    grid-template-columns: 1fr;
    gap: 8px;
    overflow: visible;
    padding: 8px;
  }

  .setup-row {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .setup-row label,
  .setup-label,
  .lan-actions label span {
    font-size: 0.6rem;
  }

  .lap-option {
    min-height: 32px;
    font-size: 0.56rem;
  }

  .player-setup-list {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .player-setup-row {
    padding: 4px;
  }

  .mission-board,
  .lan-actions,
  .lan-room-panel {
    padding: 8px;
  }

  .mission-board strong {
    font-size: 0.8rem;
  }

  .mission-board p,
  .lan-room-panel p {
    font-size: 0.58rem;
  }

  .lobby-footer {
    grid-template-columns: 1fr;
    gap: 7px;
    min-height: 52px;
    padding: 7px 8px;
  }

  .lobby-footer span {
    display: none;
  }

  .lobby-footer-actions {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  }
}
