:root {
  color-scheme: dark;
  --bg: #080d14;
  --surface: #111a24;
  --surface-strong: #162330;
  --line: #29404d;
  --text: #edf7f6;
  --muted: #8ca2aa;
  --cyan: #7fe7e0;
  --cyan-dark: #123d42;
  --amber: #ffb84d;
  --amber-dark: #442c0d;
  --danger: #ff5d59;
  --radius: 12px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overscroll-behavior: none;
  background: var(--bg);
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--text);
  touch-action: manipulation;
  user-select: none;
  background:
    linear-gradient(rgba(127, 231, 224, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(127, 231, 224, 0.025) 1px, transparent 1px),
    radial-gradient(circle at 50% 15%, #132430 0, var(--bg) 45%);
  background-size: 28px 28px, 28px 28px, auto;
}

button {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.game-shell {
  width: min(100%, 760px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 13px;
  height: 38px;
  border: 1px solid var(--cyan);
  background: linear-gradient(to bottom, var(--cyan) 0 35%, transparent 35% 48%, var(--cyan) 48%);
  box-shadow: 0 0 14px rgba(127, 231, 224, 0.25);
}

h1,
h2,
p {
  margin: 0;
}

.brand h1 {
  font-size: clamp(19px, 4.8vw, 27px);
  line-height: 1.1;
  letter-spacing: 0.09em;
}

.brand p,
.stage-heading,
.status-item span,
.instruction,
.result-kicker {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.1em;
}

.brand p {
  margin-top: 5px;
}

.status-cluster {
  display: flex;
  gap: 16px;
}

.status-item {
  display: grid;
  gap: 4px;
  text-align: right;
}

.status-item strong {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: clamp(15px, 4vw, 20px);
  font-variant-numeric: tabular-nums;
  color: var(--cyan);
}

.status-item.timer strong {
  color: var(--amber);
}

.stage-section {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 9px;
}

.stage-heading {
  display: flex;
  justify-content: space-between;
  text-transform: uppercase;
}

.stage-frame {
  position: relative;
  width: 100%;
  min-height: 0;
  max-height: 64dvh;
  aspect-ratio: 4 / 3;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(127, 231, 224, 0.56);
  border-radius: var(--radius);
  background: #070c10;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.32), inset 0 0 40px rgba(0, 0, 0, 0.28);
}

.stage-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle, transparent 55%, rgba(3, 8, 12, 0.46) 100%);
}

#stageImage {
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 260ms ease, transform 420ms ease;
}

.stage-frame.locating {
  cursor: crosshair;
  border-color: var(--amber);
  box-shadow: 0 0 0 1px rgba(255, 184, 77, 0.35), 0 18px 60px rgba(0, 0, 0, 0.32);
}

.stage-frame:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }

.target-marker {
  position: absolute;
  z-index: 4;
  width: 54px;
  height: 54px;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 2px solid var(--cyan);
  border-radius: 50%;
  color: var(--cyan);
  background: rgba(4, 17, 23, 0.28);
  box-shadow: 0 0 0 7px rgba(127, 231, 224, 0.12), 0 0 22px rgba(127, 231, 224, 0.4);
  pointer-events: none;
}

.target-marker[hidden] { display: none; }
.target-marker::before,
.target-marker::after { content: ""; position: absolute; background: currentColor; }
.target-marker::before { width: 72px; height: 1px; left: -11px; top: 25px; }
.target-marker::after { width: 1px; height: 72px; left: 25px; top: -11px; }
.target-marker span { position: absolute; inset: 19px; border: 1px solid currentColor; border-radius: 50%; }

.answer-frame {
  position: absolute;
  z-index: 6;
  min-width: 10%;
  min-height: 10%;
  border: 3px solid var(--amber);
  box-shadow: 0 0 0 4px rgba(255,184,77,.18), 0 0 28px rgba(255,184,77,.72), inset 0 0 18px rgba(255,184,77,.18);
  pointer-events: none;
  animation: answerPulse .65s ease-in-out infinite alternate;
}
.answer-frame[hidden] { display: none; }
.answer-frame span { position: absolute; left: -3px; bottom: 100%; padding: 5px 8px; color: #171007; background: var(--amber); font-size: 12px; font-weight: 800; white-space: nowrap; }
.answer-frame.normal-answer { border-color: var(--cyan); box-shadow: inset 0 0 30px rgba(127,231,224,.12), 0 0 0 4px rgba(127,231,224,.14); animation: none; }
.answer-frame.normal-answer span { color: #071016; background: var(--cyan); }
@keyframes answerPulse { to { filter: brightness(1.35); } }

#stageImage.ready {
  opacity: 1;
}

.scanline {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 3px,
    rgba(127, 231, 224, 0.32) 4px
  );
}

.corner {
  position: absolute;
  z-index: 3;
  width: 23px;
  height: 23px;
  border-color: var(--cyan);
  pointer-events: none;
}

.corner-tl { top: 12px; left: 12px; border-top: 2px solid; border-left: 2px solid; }
.corner-tr { top: 12px; right: 12px; border-top: 2px solid; border-right: 2px solid; }
.corner-bl { bottom: 12px; left: 12px; border-bottom: 2px solid; border-left: 2px solid; }
.corner-br { bottom: 12px; right: 12px; border-bottom: 2px solid; border-right: 2px solid; }

.loading-state {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  background: #091019;
}

.loading-state[hidden] {
  display: none;
}

.loader {
  width: 34px;
  height: 34px;
  margin: auto;
  border: 2px solid var(--line);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.controls {
  display: grid;
  gap: 10px;
}

.instruction {
  text-align: center;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.action-row[hidden] { display: none; }

.choice-button {
  min-height: 84px;
  border: 1px solid;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: clamp(17px, 4.5vw, 22px);
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease, opacity 120ms ease;
}

.choice-button svg {
  width: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.choice-button.normal {
  color: var(--cyan);
  border-color: var(--cyan);
  background: linear-gradient(150deg, #12353b, #0b1d25);
}

.choice-button.anomaly {
  color: var(--amber);
  border-color: var(--amber);
  background: linear-gradient(150deg, #402a0d, #1c170f);
}

.choice-button:active:not(:disabled) {
  transform: scale(0.975);
  filter: brightness(1.18);
}

.choice-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.game-shell.alarm {
  animation: alarm 380ms ease 2;
}

@keyframes alarm {
  0%, 100% { transform: translateX(0); filter: none; }
  25% { transform: translateX(-5px); filter: saturate(1.7); }
  75% { transform: translateX(5px); filter: saturate(1.7); }
}

.modal-backdrop,
.poster-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  padding: 20px;
  display: grid;
  place-items: center;
  background: rgba(2, 7, 11, 0.86);
  backdrop-filter: blur(10px);
}

.modal-backdrop[hidden],
.poster-backdrop[hidden] {
  display: none;
}

.modal-backdrop.answer-review { place-items: center end; padding-right: max(20px, calc((100vw - 1180px) / 2)); background: rgba(2,7,11,.22); backdrop-filter: none; pointer-events: none; }
.modal-backdrop.answer-review .result-modal { width: min(330px, 34vw); padding: 24px 20px 18px; pointer-events: auto; }
.modal-backdrop.answer-review .result-symbol { width: 58px; height: 58px; margin-bottom: 10px; font-size: 34px; }
.modal-backdrop.answer-review .result-message { margin-block: 8px 12px; }
.modal-backdrop.answer-review .result-stats { margin-bottom: 12px; }

.result-modal,
.poster-panel {
  position: relative;
  width: min(100%, 430px);
  border: 1px solid rgba(127, 231, 224, 0.45);
  border-radius: 16px;
  background: linear-gradient(160deg, #172631, #0b1219 70%);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}

.result-modal {
  padding: 30px 24px 24px;
  text-align: center;
}

.modal-close,
.poster-header button {
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 28px;
  cursor: pointer;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
}

.result-symbol {
  display: grid;
  place-items: center;
  width: 90px;
  height: 90px;
  margin: 0 auto 18px;
  border: 1px solid var(--amber);
  border-radius: 50%;
  color: var(--amber);
  font-size: 52px;
  font-weight: 800;
  box-shadow: inset 0 0 24px rgba(255, 184, 77, 0.11);
}

.result-kicker {
  text-transform: uppercase;
}

.result-modal h2 {
  margin-top: 7px;
  font-size: 28px;
}

.result-message {
  min-height: 42px;
  margin: 12px 0 20px;
  color: #b9c8cc;
  line-height: 1.55;
}

.result-stats {
  margin: 0 0 22px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-block: 1px solid var(--line);
}

.result-stats div {
  padding: 16px 8px;
}

.result-stats div + div {
  border-left: 1px solid var(--line);
}

.result-stats dt {
  color: var(--muted);
  font-size: 12px;
}

.result-stats dd {
  margin: 6px 0 0;
  color: var(--cyan);
  font-family: Consolas, monospace;
  font-size: 20px;
  font-weight: 700;
}

.modal-actions {
  display: grid;
  gap: 10px;
}

.modal-home-link {
  min-height: 48px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
}

.back-link {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(127, 231, 224, 0.55);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--cyan);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.back-link svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* Game collection lobby */
.hub-page { overflow-y: auto; user-select: none; }
.hub-shell {
  width: min(100%, 1180px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 22px max(34px, env(safe-area-inset-bottom));
}
.hub-topbar { min-height: 56px; display: flex; align-items: center; border-bottom: 1px solid rgba(127, 231, 224, 0.22); }
.hub-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--cyan); letter-spacing: 0.08em; }
.hub-brand .brand-mark { height: 28px; }
.hub-tools { align-self: stretch; margin-left: 36px; display: flex; align-items: center; gap: 18px; }
.hub-nav { align-self: stretch; padding: 18px 8px 0; border-bottom: 3px solid var(--amber); color: var(--amber); font-size: 14px; font-weight: 700; }
.hub-help-button { min-height: 38px; padding: 0 15px; border: 1px solid rgba(127,231,224,.5); border-radius: 7px; color: var(--cyan); background: rgba(18,61,66,.24); font-size: 13px; font-weight: 750; cursor: pointer; }
.hub-intro { padding: clamp(34px, 6vw, 70px) 0 clamp(28px, 4vw, 48px); text-align: center; }
.hub-intro h1 { font-size: clamp(40px, 7vw, 76px); line-height: 1; letter-spacing: 0.12em; text-shadow: 0 4px 0 #203642; }
.hub-intro p { margin-top: 18px; color: #9acfd0; font-size: clamp(15px, 2vw, 21px); letter-spacing: 0.25em; }
.game-list { display: grid; gap: 18px; }
.game-entry {
  height: 230px;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
  overflow: hidden;
  border: 1px solid var(--cyan);
  border-radius: 14px;
  background: rgba(6, 14, 21, 0.74);
  box-shadow: inset 0 0 30px rgba(127, 231, 224, 0.03);
}
.game-entry.connect-entry, .game-entry.harbor-entry { border-color: var(--amber); }
.entry-visual { position: relative; min-height: 0; overflow: hidden; border-right: 1px solid rgba(127, 231, 224, 0.2); }
.anomaly-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: saturate(0.72) brightness(0.74); }
.anomaly-preview::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(to bottom, transparent 0 3px, rgba(127,231,224,.08) 4px); }
.preview-corner { position: absolute; z-index: 2; width: 30px; height: 30px; border-color: var(--cyan); }
.preview-corner-tl { top: 16px; left: 16px; border-top: 2px solid; border-left: 2px solid; }
.preview-corner-br { right: 16px; bottom: 16px; border-right: 2px solid; border-bottom: 2px solid; }
.entry-copy { padding: clamp(24px, 4vw, 44px); display: grid; grid-template-columns: auto 1fr; align-content: center; column-gap: 18px; }
.entry-icon { width: 52px; grid-row: span 2; fill: none; stroke: var(--cyan); stroke-width: 2; }
.connect-entry .entry-icon, .harbor-entry .entry-icon { stroke: var(--amber); }
.entry-copy h2 { align-self: end; font-size: clamp(28px, 4vw, 42px); letter-spacing: 0.08em; }
.entry-copy p { margin-top: 10px; color: #b3c1c5; font-size: clamp(14px, 1.6vw, 18px); }
.entry-action { grid-column: 1 / -1; min-height: 58px; margin-top: 28px; padding: 0 22px; border: 1px solid; border-radius: 8px; display: flex; align-items: center; justify-content: center; gap: 18px; font-size: 20px; font-weight: 800; letter-spacing: 0.08em; }
.entry-action span { margin-left: auto; font-size: 28px; font-weight: 400; }
.cyan-action { color: var(--cyan); background: rgba(18, 61, 66, 0.36); }
.amber-action { color: var(--amber); background: rgba(68, 44, 13, 0.42); }
.entry-action:active { transform: scale(.99); filter: brightness(1.2); }
.connect-preview { display: grid; place-items: center; padding: 20px; }
.mini-board { width: min(68%, 240px); aspect-ratio: 7 / 6; padding: 8px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; border: 1px solid #294b5c; border-bottom-width: 8px; border-radius: 9px; background: #102534; }
.mini-board > span { aspect-ratio: 1; border: 2px solid #173f50; border-radius: 50%; background: #071016; }
.mini-board .mini-player-1, .mini-stone.mini-player-1 { background: var(--cyan); box-shadow: inset 0 -3px 0 #25969c; }
.mini-board .mini-player-2, .mini-stone.mini-player-2 { background: var(--amber); box-shadow: inset 0 -3px 0 #bf7415; }
.six-preview { display: grid; place-items: center; padding: 22px; }
.mini-six-board { position: relative; width: min(68%, 210px); aspect-ratio: 1; border: 1px solid #315462; background-color: #0a1822; background-image: linear-gradient(rgba(91,139,155,.5) 1px,transparent 1px),linear-gradient(90deg,rgba(91,139,155,.5) 1px,transparent 1px); background-size: calc(100% / 18) calc(100% / 18); }
.mini-stone { position: absolute; left: calc(var(--x) * 100% / 18); top: calc(var(--y) * 100% / 18); width: 7.5%; aspect-ratio: 1; transform: translate(-50%,-50%); border-radius: 50%; }
.harbor-preview { display: grid; place-items: center; padding: 22px; }
.mini-harbor { width: min(74%, 260px); aspect-ratio: 5 / 4; padding: 12px; display: grid; grid-template-columns: repeat(4,1fr); grid-template-rows: repeat(3,1fr); gap: 8px; border: 1px solid #315c6e; border-radius: 12px; background: radial-gradient(circle at center,#123346,#07151f 72%); }
.mini-harbor-ship { min-width: 0; border-radius: 45% 55% 40% 40%; display: grid; place-items: center; color: #071016; font-size: 20px; font-weight: 900; box-shadow: inset 0 -5px 0 rgba(0,0,0,.22),0 6px 16px rgba(0,0,0,.28); }

.help-modal { width: min(100%,720px); max-height: calc(100dvh - 34px); overflow: auto; text-align: left; }
.help-modal > h2 { text-align: center; }
.help-modal > .result-kicker { text-align: center; }
.help-game-list { margin: 22px 0 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.help-game-list article { padding: 16px; border-left: 3px solid var(--cyan); background: rgba(127,231,224,.055); }
.help-game-list article:nth-child(even) { border-color: var(--amber); }
.help-game-list h3 { margin: 0 0 7px; font-size: 17px; }
.help-game-list p, .help-invite-note p { color: #b9c8cc; font-size: 14px; line-height: 1.65; }
.help-invite-note { margin-bottom: 18px; padding: 15px 16px; border: 1px solid rgba(255,184,77,.45); border-radius: 9px; background: rgba(68,44,13,.25); }
.help-invite-note strong { display: block; margin-bottom: 5px; color: var(--amber); }
.help-modal > .primary-button { width: 100%; min-height: 50px; border-radius: 8px; font-weight: 800; cursor: pointer; }

/* Shared board-game shell */
.connect-page, .connect6-page { overflow-y: auto; }
.connect-shell { width: min(100%, 1240px); min-height: 100dvh; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom)); display: grid; grid-template-rows: auto 1fr; gap: 18px; }
.connect-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.connect-game { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: clamp(18px, 3vw, 34px); align-items: center; }
.board-panel { min-width: 0; padding: clamp(14px, 2vw, 24px); border: 1px solid var(--cyan); border-radius: 14px; background: rgba(8, 23, 33, 0.82); }
.column-guides { width: 100%; height: 48px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.column-guide { border: 0; border-radius: 7px; color: rgba(127,231,224,.5); background: transparent; cursor: pointer; }
.column-guide svg { width: 26px; fill: none; stroke: currentColor; stroke-width: 2; }
.column-guide:hover:not(:disabled), .column-guide:focus-visible { color: var(--cyan); background: rgba(127,231,224,.1); }
.connect-board { width: 100%; aspect-ratio: 7 / 6; padding: clamp(8px, 1.5vw, 16px); display: grid; grid-template-columns: repeat(7, 1fr); gap: clamp(5px, 1vw, 12px); border: 1px solid #21566d; border-radius: 14px; background: #0d2a3c; box-shadow: inset 0 0 30px rgba(0,0,0,.35); }
.connect-cell { aspect-ratio: 1; border: 2px solid #1d5770; border-radius: 50%; background: #06101a; box-shadow: inset 0 5px 10px rgba(0,0,0,.6); }
.connect-cell.player-1, .turn-disc.player-one { border-color: #b6ffff; background: var(--cyan); box-shadow: inset 0 -7px 0 #29979b, 0 0 14px rgba(127,231,224,.35); }
.connect-cell.player-2, .turn-disc.player-two { border-color: #ffe0a4; background: var(--amber); box-shadow: inset 0 -7px 0 #bd741a, 0 0 14px rgba(255,184,77,.3); }
.connect-cell.winning, .six-point.winning::after { animation: winPulse .7s ease-in-out infinite alternate; }
@keyframes winPulse { to { filter: brightness(1.6); transform: scale(.88); } }
.connect-controls { display: grid; gap: 16px; align-content: center; }
.turn-panel { min-height: 88px; padding: 16px; border: 1px solid rgba(127,231,224,.5); border-radius: 12px; display: flex; align-items: center; gap: 16px; color: var(--cyan); background: rgba(10,24,33,.8); }
.turn-panel strong { font-size: clamp(18px, 2vw, 24px); letter-spacing: .05em; }
.turn-disc { flex: 0 0 auto; width: 44px; height: 44px; border: 2px solid; border-radius: 50%; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-button { min-height: 74px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: rgba(10,18,25,.8); font-weight: 700; cursor: pointer; }
.mode-button.active:first-child { color: var(--cyan); border-color: var(--cyan); background: rgba(18,61,66,.38); }
.mode-button.active:last-child { color: var(--amber); border-color: var(--amber); background: rgba(68,44,13,.38); }
.score-panel { padding: 18px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; text-align: center; }
.score-panel div { display: grid; gap: 8px; }
.score-panel span { color: var(--muted); }
.score-panel strong { color: var(--cyan); font: 700 28px Consolas, monospace; }
.score-panel div:last-child strong { color: var(--amber); }
.connect-actions { display: grid; gap: 10px; }
.connect-actions button { min-height: 54px; border-radius: 8px; font-weight: 800; cursor: pointer; }
.connect-actions button:disabled { opacity: .35; cursor: default; }
.connect-result .result-symbol { color: var(--cyan); border-color: var(--cyan); }

.invite-strip { padding: 13px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; border: 1px dashed rgba(255,184,77,.48); border-radius: 10px; background: rgba(68,44,13,.18); }
.invite-strip[hidden] { display: none; }
.invite-strip p { color: #b9c8cc; font-size: 12px; line-height: 1.45; }
.invite-button { min-height: 42px; padding: 0 14px; border: 1px solid var(--amber); border-radius: 7px; color: var(--amber); background: rgba(68,44,13,.36); font-size: 13px; font-weight: 800; cursor: pointer; }
.match-complete-panel { padding: 15px; display: grid; grid-template-columns: auto 1fr; gap: 12px 14px; align-items: center; border: 1px solid var(--amber); border-radius: 12px; background: linear-gradient(145deg,rgba(68,44,13,.45),rgba(8,16,23,.9)); }
.match-complete-panel[hidden] { display: none; }
.match-complete-panel .result-symbol { width: 54px; height: 54px; margin: 0; font-size: 30px; }
.match-complete-panel h2 { margin-top: 4px; font-size: 20px; }
.match-complete-panel p:not(.result-kicker) { margin-top: 5px; color: #b9c8cc; font-size: 12px; line-height: 1.45; }
.match-complete-panel > button { grid-column: 1 / -1; min-height: 48px; border-radius: 8px; font-weight: 800; cursor: pointer; }
.match-complete-panel > button:disabled { opacity: .5; cursor: default; }
.invite-modal .room-code { display: block; margin: 18px auto 8px; color: var(--amber); font: 800 34px/1.2 Consolas,monospace; letter-spacing: .16em; }
.invite-modal > p:not(.result-kicker):not(.invite-tip) { color: #b9c8cc; }
.room-link-label { margin: 18px 0; display: grid; gap: 7px; color: var(--muted); font-size: 12px; text-align: left; }
.room-link-label input { width: 100%; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--text); background: #071016; font: 12px Consolas,monospace; user-select: text; }
.invite-tip { margin-top: 14px; color: var(--muted); font-size: 11px; line-height: 1.55; }

/* Harbor pickup */
.harbor-page { overflow-y: auto; }
.harbor-shell { width: min(100%,1280px); min-height: 100dvh; margin: 0 auto; padding: max(16px,env(safe-area-inset-top)) 18px max(24px,env(safe-area-inset-bottom)); display: grid; gap: 14px; }
.harbor-levels { display: grid; grid-template-columns: repeat(10,1fr); gap: 7px; }
.harbor-levels button { min-height: 38px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: rgba(7,16,24,.8); font: 700 13px Consolas,monospace; cursor: pointer; }
.harbor-levels button.active { color: #071016; border-color: var(--amber); background: var(--amber); }
.harbor-levels button:disabled { opacity: .3; cursor: default; }
.harbor-statusbar { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--line); }
.harbor-statusbar > div { min-width: 0; padding: 10px 14px; display: grid; gap: 4px; background: #0b151e; }
.harbor-statusbar span { color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.harbor-statusbar strong { overflow: hidden; color: var(--cyan); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.harbor-game { min-height: 0; display: grid; grid-template-columns: minmax(0,1fr) 310px; gap: 20px; align-items: start; }
.harbor-playfield { min-width: 0; display: grid; gap: 10px; }
.passenger-queue { min-height: 54px; padding: 8px 10px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; border: 1px solid rgba(127,231,224,.38); border-radius: 9px; background: rgba(8,24,33,.82); }
.queue-label { color: var(--amber); font-size: 11px; }
.passenger-queue > div { min-width: 0; display: flex; gap: 5px; overflow: hidden; }
.passenger { flex: 0 0 28px; width: 28px; height: 28px; border: 2px solid rgba(255,255,255,.5); border-radius: 50%; display: grid; place-items: center; color: #071016; font-size: 10px; font-weight: 900; }
.passenger.front { outline: 2px solid #fff; outline-offset: 2px; }
.passenger-queue > span:last-child { color: var(--muted); font: 12px Consolas,monospace; }
.dock-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.dock-slot { min-width: 0; min-height: 74px; padding: 7px; border: 1px solid #315462; border-radius: 8px; display: grid; align-content: space-between; gap: 4px; background: rgba(7,18,27,.86); }
.dock-slot > span:first-child, .dock-slot small { color: var(--muted); font-size: 9px; }
.sea-panel { min-width: 0; padding: clamp(8px,1.5vw,18px); border: 1px solid var(--cyan); border-radius: 12px; background: radial-gradient(circle at 50% 45%,#13394b,#07151f 70%); }
.sea-grid { width: min(100%,780px); margin: auto; aspect-ratio: var(--columns) / var(--rows); display: grid; grid-template-columns: repeat(var(--columns),minmax(0,1fr)); grid-template-rows: repeat(var(--rows),minmax(0,1fr)); background-image: linear-gradient(rgba(127,231,224,.08) 1px,transparent 1px),linear-gradient(90deg,rgba(127,231,224,.08) 1px,transparent 1px); background-size: calc(100% / var(--columns)) calc(100% / var(--rows)); }
.sea-ship { position: relative; min-width: 0; min-height: 0; padding: 0; border: 0; display: grid; place-items: center; color: var(--text); background: transparent; cursor: pointer; }
.ship-arrow { position: absolute; z-index: 2; color: #fff; font-size: clamp(10px,1.4vw,16px); font-weight: 900; text-shadow: 0 1px 4px #000; }
.ship-arrow.up { top: -2px; }.ship-arrow.down { bottom: -2px; }.ship-arrow.left { left: 0; }.ship-arrow.right { right: 0; }
.harbor-boat { position: relative; width: 88%; height: 48%; padding: 3px 7%; border: 1px solid rgba(255,255,255,.65); border-radius: 48% 52% 38% 38%; display: grid; place-items: center; color: #071016; box-shadow: inset 0 -5px 0 rgba(0,0,0,.2),0 5px 10px rgba(0,0,0,.28); }
.harbor-boat.compact { width: 100%; height: 22px; }
.boat-seats { width: 100%; display: grid; grid-template-columns: repeat(5,minmax(2px,1fr)); gap: 1px; }
.boat-seats i { aspect-ratio: 1; border: 1px solid rgba(7,16,22,.55); background: rgba(255,255,255,.7); }
.boat-seats i.filled { border-radius: 50%; background: #071016; }
.sea-ship.blocked { opacity: .68; }
.sea-ship.hinted { z-index: 3; animation: harborHint .7s ease-in-out infinite alternate; }
@keyframes harborHint { to { filter: brightness(1.55); transform: scale(1.08); } }
.color-red { background: #ff6d68; }.color-blue { background: #57bff2; }.color-yellow { background: #ffd05a; }
.color-green { background: #67d78b; }.color-purple { background: #bb8cff; }.color-orange { background: #ff9b54; }
.harbor-controls { display: grid; gap: 12px; align-content: start; }
.harbor-rules { padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: rgba(9,20,29,.86); }
.harbor-rules h2 { font-size: 19px; }
.harbor-rules ol { margin: 12px 0 0; padding-left: 20px; color: #b9c8cc; font-size: 13px; line-height: 1.65; }
.harbor-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.harbor-actions button { min-height: 48px; border-radius: 8px; font-weight: 800; cursor: pointer; }
.harbor-actions .primary-button { grid-column: 1 / -1; }
.harbor-actions button:disabled { opacity: .35; cursor: default; }
.harbor-complete { grid-template-columns: auto 1fr; }

/* Connect6 */
.six-board-panel { min-width: 0; max-height: calc(100dvh - 120px); overflow: auto; padding: 18px; border: 1px solid var(--cyan); border-radius: 14px; background: rgba(7,18,27,.88); touch-action: pan-x pan-y; scrollbar-color: var(--line) transparent; }
.six-board { width: 608px; height: 608px; margin: auto; padding: 16px; display: grid; grid-template-columns: repeat(19, 1fr); grid-template-rows: repeat(19, 1fr); }
.six-point { position: relative; width: 100%; aspect-ratio: 1; padding: 0; border: 0; background: linear-gradient(to right,transparent calc(50% - .5px),#315c6e calc(50% - .5px),#315c6e calc(50% + .5px),transparent calc(50% + .5px)),linear-gradient(to bottom,transparent calc(50% - .5px),#315c6e calc(50% - .5px),#315c6e calc(50% + .5px),transparent calc(50% + .5px)); cursor: pointer; }
.six-point::after { content: ""; position: absolute; inset: 10%; border: 0 solid transparent; border-radius: 50%; transform: scale(0); transition: transform 120ms ease; }
.six-point.player-1::after { transform: scale(1); border: 1px solid #b6ffff; background: var(--cyan); box-shadow: inset 0 -4px 0 #29979b; }
.six-point.player-2::after { transform: scale(1); border: 1px solid #526676; background: #101a25; box-shadow: inset 0 -4px 0 #02070b, 0 0 0 1px #3b5261; }
.six-point:not(:disabled):hover::after, .six-point:not(:disabled):focus-visible::after { transform: scale(.55); background: rgba(127,231,224,.5); }
.six-point.last-move::before { content: ""; position: absolute; z-index: 2; inset: 39%; border: 1px solid #fff; border-radius: 50%; }

@media (max-width: 760px) {
  .hub-topbar { min-height: 50px; }
  .hub-tools { margin-left: auto; gap: 8px; }
  .hub-intro { padding-block: 30px 26px; }
  .game-entry { grid-template-columns: 1fr; }
  .game-entry { height: auto; }
  .entry-visual { min-height: 180px; border-right: 0; border-bottom: 1px solid rgba(127,231,224,.18); }
  .entry-copy { padding: 22px; }
  .entry-icon { width: 42px; }
  .entry-action { min-height: 54px; margin-top: 20px; font-size: 17px; }
  .anomaly-page .topbar { display: grid; grid-template-columns: 1fr auto; }
  .anomaly-page .status-cluster { grid-column: 1 / -1; grid-row: 2; justify-content: space-between; }
  .anomaly-page .status-item { text-align: left; }
  .connect-game { grid-template-columns: 1fr; align-content: start; }
  .connect-controls { grid-template-columns: 1fr 1fr; }
  .turn-panel, .score-panel { grid-column: 1 / -1; }
  .connect-actions { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
  .invite-strip, .match-complete-panel { grid-column: 1 / -1; }
  .board-panel { padding: 10px; }
  .column-guides { height: 38px; }
  .connect-board { gap: 5px; padding: 8px; }
  .mode-button { min-height: 58px; }
  .six-board-panel { max-height: min(64dvh, 520px); padding: 8px; }
  .modal-backdrop.answer-review { place-items: end center; padding: 10px; }
  .modal-backdrop.answer-review .result-modal { width: min(100%,520px); max-height: 42dvh; overflow: auto; }
  .harbor-game { grid-template-columns: 1fr; }
  .harbor-controls { grid-template-columns: 1fr 1fr; }
  .harbor-rules { grid-column: 1 / -1; }
  .harbor-complete { grid-column: 1 / -1; }
}

@media (max-width: 430px) {
  .hub-shell { padding-inline: 14px; }
  .hub-intro h1 { font-size: 36px; }
  .hub-intro p { font-size: 13px; letter-spacing: .12em; }
  .hub-nav { display: none; }
  .hub-help-button { min-height: 36px; padding-inline: 12px; }
  .game-entry { min-height: 0; }
  .entry-visual { min-height: 152px; }
  .entry-copy { grid-template-columns: 38px 1fr; column-gap: 12px; }
  .entry-copy h2 { font-size: 25px; }
  .entry-copy p { font-size: 13px; line-height: 1.5; }
  .connect-shell { padding-inline: 12px; }
  .connect-header .brand p, .back-link span { display: none; }
  .back-link { width: 46px; padding: 0; }
  .connect-game { gap: 12px; }
  .turn-panel { min-height: 66px; }
  .score-panel { padding: 12px; }
  .help-game-list { grid-template-columns: 1fr; }
  .invite-strip { grid-template-columns: 1fr; }
  .invite-button { width: 100%; }
  .harbor-shell { padding-inline: 10px; }
  .harbor-levels { gap: 4px; }
  .harbor-levels button { min-height: 34px; font-size: 11px; }
  .harbor-statusbar { grid-template-columns: 1fr 1fr; }
  .harbor-statusbar > div:last-child { grid-column: 1 / -1; }
  .harbor-statusbar > div { padding: 8px 9px; }
  .dock-row { gap: 4px; }
  .dock-slot { min-height: 62px; padding: 5px; }
  .sea-panel { padding: 5px; }
  .harbor-controls { grid-template-columns: 1fr; }
  .harbor-rules, .harbor-complete { grid-column: auto; }
}

.modal-actions button {
  min-height: 50px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

.secondary-button {
  border: 1px solid var(--cyan);
  color: var(--cyan);
  background: transparent;
}

.primary-button {
  border: 1px solid var(--amber);
  color: #171007;
  background: var(--amber);
}

.poster-panel {
  max-height: calc(100dvh - 32px);
  padding: 16px;
  overflow: auto;
}

.poster-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.poster-header p {
  color: var(--amber);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.poster-header h2 {
  margin-top: 4px;
  font-size: 20px;
}

#posterImage {
  width: 100%;
  display: block;
  border-radius: 9px;
  -webkit-touch-callout: default;
  user-select: auto;
}

@media (min-width: 720px) {
  .game-shell {
    padding-inline: 28px;
    grid-template-rows: auto auto auto;
    align-content: center;
  }

  .stage-section {
    grid-template-rows: auto auto;
  }

  .stage-frame {
    aspect-ratio: 4 / 3;
  }
}

@media (min-width: 650px) and (orientation: landscape) {
  .game-shell {
    width: min(100%, 1180px);
    height: 100dvh;
    min-height: 0;
    padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
    grid-template-columns: minmax(0, 1fr) clamp(240px, 28vw, 320px);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "header header"
      "stage controls";
    align-content: stretch;
    column-gap: clamp(18px, 3vw, 36px);
    row-gap: 12px;
  }

  .topbar {
    grid-area: header;
  }

  .stage-section {
    grid-area: stage;
    min-height: 0;
    align-self: center;
  }

  .stage-frame {
    width: 100%;
    min-height: 0;
    max-height: calc(100dvh - 112px);
    aspect-ratio: 4 / 3;
  }

  #stageImage {
    min-height: 0;
    aspect-ratio: 4 / 3;
  }

  .controls {
    grid-area: controls;
    align-self: center;
    gap: 16px;
  }

  .instruction {
    max-width: none;
    margin-inline: auto;
    line-height: 1.7;
  }

  .action-row {
    grid-template-columns: 1fr;
  }

  .choice-button {
    min-height: clamp(78px, 15dvh, 116px);
  }
}

@media (min-width: 650px) and (max-height: 600px) and (orientation: landscape) {
  .game-shell {
    width: min(100%, 860px);
    grid-template-columns: minmax(0, 1fr) 240px;
  }

  .brand-mark {
    height: 30px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .brand p,
  .status-item span {
    display: none;
  }

  .stage-frame {
    max-height: calc(100dvh - 72px);
  }

  .choice-button {
    min-height: 68px;
    font-size: 17px;
  }
}

@media (max-height: 690px) {
  .game-shell {
    gap: 10px;
    padding-top: max(10px, env(safe-area-inset-top));
  }

  .stage-frame,
  #stageImage {
    min-height: 230px;
  }

  .choice-button {
    min-height: 68px;
  }
}

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