* { box-sizing: border-box; }
body { margin: 0; background: #19131c; color: white; font-family: system-ui, sans-serif; }
#stage { position: fixed; inset: 0; overflow: hidden; }
.scene { position: absolute; transform-origin: top left; isolation: isolate; }
.scene img { display: block; width: 100%; height: 100%; pointer-events: none; }
.scene button {
  position: absolute;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  transform-origin: top left;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.scene button[data-drag] { touch-action: none; cursor: grab; }
.scene button:focus-visible { outline: 3px solid #007d94; outline-offset: -3px; }
.shade { position: absolute; inset: 0; border: 0; width: 100%; padding: 0; }
#message { position: fixed; left: 16px; bottom: 12px; margin: 0; }
#message:empty { display: none; }
/* ShipFlow multiplayer: warm paper, plum ink, orange actions and teal tickets.
   8px spacing rhythm, 32–40px headings, 16px fields, 44px minimum touch targets. */
#room-dialog, .room-badge {
  --room-ink: #301334;
  --room-paper: #fff0db;
  --room-light: #fffaf1;
  --room-orange: #ff731f;
  --room-ocean: #087e8b;
  font-family: Manrope, Inter, system-ui, sans-serif;
}

.room-badge {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 1;
  min-height: 44px;
  padding: 8px 18px;
  border: 1px solid #ecc39f;
  border-radius: 30px;
  color: var(--room-ink);
  background: var(--room-paper);
  box-shadow: 0 3px 0 #a95c3180;
  font-size: .875rem;
  font-weight: 800;
  cursor: pointer;
}

#room-dialog {
  width: min(480px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  padding: clamp(20px, 5vw, 34px);
  border: 1px solid #e9be9c;
  border-radius: 22px 19px 26px 16px;
  overflow-x: hidden;
  color: var(--room-ink);
  background: var(--room-paper);
  box-shadow: 0 6px 0 #be845c, 0 18px 46px #18091f78;
}

#room-dialog::backdrop {
  background: #23142c9e;
  backdrop-filter: blur(3px);
}

.room-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: .875rem;
  font-weight: 850;
}

.room-brand img { object-fit: contain; flex: none; }
#room-dialog h1 {
  margin: 0 0 24px;
  font-size: clamp(1.85rem, 7vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: -.045em;
  font-weight: 900;
}

#room-dialog label {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  font-weight: 800;
}

#room-dialog input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid #b88f82;
  border-radius: 10px 12px 8px 10px;
  color: var(--room-ink);
  background: var(--room-light);
  font: 500 1rem Manrope, Inter, system-ui, sans-serif;
  box-shadow: inset 0 2px 0 #e9d5bf;
}

#room-code-input { text-transform: uppercase; letter-spacing: .12em; }
#room-code-input::placeholder { text-transform: none; letter-spacing: normal; }

.room-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin-top: 24px;
}

#room-dialog button {
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid #e3bca4;
  border-radius: 24px;
  color: var(--room-ink);
  background: var(--room-light);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

#room-dialog .room-primary {
  grid-column: 1 / -1;
  min-height: 50px;
  border-color: #c54b0d;
  background: var(--room-orange);
  box-shadow: 0 4px 0 #a93a0d;
  font-size: 1.0625rem;
}

#room-dialog .room-primary:not(:disabled):active { translate: 0 2px; box-shadow: 0 2px 0 #a93a0d; }
#room-dialog .room-primary:disabled { opacity: .55; cursor: default; }
#room-dialog .room-quiet { border-color: transparent; background: transparent; }
#room-panel .room-quiet { grid-column: 1 / -1; }
#room-dialog :focus-visible, .room-badge:focus-visible { outline: 3px solid var(--room-ocean); outline-offset: 3px; }
#room-dialog [hidden] { display: none; }

.room-ticket {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 14px 18px 18px;
  color: #102d3b;
  background: #bcece8;
  border-bottom: 3px dashed #087e8b55;
  border-radius: 9px 11px 14px 8px;
  font-size: .875rem;
  font-weight: 850;
}

.room-ticket::after {
  content: '';
  position: absolute;
  inset: auto 0 0 auto;
  width: 18px;
  height: 18px;
  background: #81ceca;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

#room-code { font-size: 1.95rem; letter-spacing: .19em; line-height: 1; }
#room-panel h2 { font-size: 1rem; margin: 20px 0 8px; }
#room-players {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}

#room-players li {
  padding: 9px 12px;
  border-radius: 6px 10px 8px 9px;
  background: #e7d5f5;
  overflow-wrap: anywhere;
  font-size: .875rem;
  font-weight: 750;
}

#room-players li:nth-child(2n) { background: #f9d4b6; }
#room-lobby-hint { color: #654655; font-size: .875rem; line-height: 1.45; }
#room-status { padding: 10px 12px; border-radius: 8px; color: #702a24; background: #ffe0d0; }
#room-status:empty { display: none; }

/* Neutralize the fixed crew data on the original ShipFlow paper artwork. */
.crew-setup {
  position: absolute;
  left: 252px;
  top: 282px;
  width: 754px;
  height: 279px;
  padding: 7px 17px 0;
  background: linear-gradient(105deg, #ffe9d7, #ffeddc 62%, #ffe9d7);
  color: #301334;
  clip-path: polygon(0 0, 99% 0, 100% 7%, 98% 20%, 100% 29%, 100% 98%, 72% 100%, 29% 98%, 0 100%);
  font-family: Manrope, Inter, system-ui, sans-serif;
}
.crew-choices { display: grid; grid-template-columns: repeat(5, 108px); gap: 13px; }
.crew-setup [data-station="1"] { --ticket: #fff4e5; --edge: #dfbda0; }
.crew-setup [data-station="2"] { --ticket: #73d9d9; --edge: #449ba0; }
.crew-setup [data-station="3"] { --ticket: #d9ef75; --edge: #a6bf44; }
.crew-setup [data-station="4"] { --ticket: #ffae7c; --edge: #d8835e; }
.crew-setup [data-station="5"] { --ticket: #d4adee; --edge: #a87fbe; }
.crew-setup [data-station="6"] { --ticket: #a6e6db; --edge: #6db4ab; }
.crew-setup .crew-ticket {
  background: var(--ticket);
  border: 1px solid #52314030;
  border-radius: 9px 12px 7px 11px;
  box-shadow: 0 4px 0 var(--edge), 0 6px 9px #5d304126;
  color: inherit;
  font-weight: 850;
}
.crew-setup button.crew-ticket {
  position: relative;
  width: 108px;
  height: 56px;
  padding: 0;
  font-size: 32px;
}
.crew-setup button[aria-pressed="true"] {
  outline: 4px solid #301334;
  outline-offset: -4px;
  box-shadow: 0 4px 0 #301334, 0 6px 9px #5d304126;
}
.crew-setup button:focus-visible { outline: 4px solid #087e8b; outline-offset: 3px; }
.crew-setup h2 {
  margin: 17px 0 8px;
  padding-top: 9px;
  border-top: 1px solid #ac8172;
  font-size: 16px;
  text-transform: uppercase;
}
.crew-members {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 43px;
  gap: 10px 15px;
  min-height: 96px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.crew-members li { padding: 8px 18px; font-size: 19px; }
.crew-setup p { margin: 11px 0 0; font-size: 16px; }
