/* Phone-first Pool Pilot — one screen, no page scroll. */
:root {
  --ink: #f4ecee;
  --mute: #b9a8ae;
  --bg: #141012;
  --panel: #1c181a;
  --line: #3a3034;
  --pink: #e0447c;
  --pink-2: #c22f64;
  --bid: #2f9d5b;
  --ask: #d24b4b;
  --duck: #f2c14b;
  --font: 'Satoshi', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #0c0a0b;
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Rabby / MetaMask in-app: fill the webview, allow the sheet to scroll and zoom type. */
html.is-wallet,
html.is-wallet body {
  overflow: auto;
}

.pilot-stage {
  height: 100dvh;
  min-height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.pilot {
  position: relative;
  width: 100%;
  max-width: none;
  height: 100dvh;
  max-height: none;
  background: var(--bg);
  overflow: hidden;
  isolation: isolate;
}

html.is-wallet .pilot {
  overflow: visible;
}

.scr {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: calc(18px + env(safe-area-inset-top)) 20px calc(18px + env(safe-area-inset-bottom));
  gap: 12px;
}

.scr.is-on { display: flex; }

.kicker {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pink);
}

h1 {
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  letter-spacing: -0.04em;
  line-height: 0.95;
}

.lede {
  color: #ddd0d4;
  font-size: 1.08rem;
  line-height: 1.4;
}

.mono { font-family: var(--mono); }

.bar {
  appearance: none;
  border: 0;
  width: 100%;
  min-height: 58px;
  border-radius: 18px;
  background: var(--pink);
  color: #fff;
  font: 700 1.15rem/1 var(--font);
  letter-spacing: -0.02em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.bar:active { background: var(--pink-2); }
.bar.ghost {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--line);
}

.back {
  align-self: flex-start;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.stack { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.stack.tight { margin-top: 12px; }

/* Enter — the whole phone is the duck */
#scr-enter { padding: 0; }
.ducky {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center 38%;
  padding: 8% 6% 22%;
}
.enter-actions {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#scr-enter .bar { position: static; }
.open-hits { display: flex; flex-direction: column; gap: 6px; }
.open-hits button {
  text-align: left;
  border: 1.5px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  font: 700 0.95rem var(--font);
  cursor: pointer;
}
.team-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 36vh;
  overflow: auto;
  margin: 8px 0 12px;
}
.team-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 14px;
  padding: 10px 10px 10px 14px;
  text-align: left;
}
.team-row > button[data-book-id] {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0;
  min-width: 0;
}
.team-row strong { display: block; font-size: 1.05rem; }
.team-row em {
  font-style: normal;
  font: 400 11px var(--mono);
  color: var(--mute);
}
.team-forget {
  border: 0;
  background: transparent;
  color: var(--mute);
  font: 700 0.8rem var(--font);
  cursor: pointer;
  padding: 6px 8px;
}

.doors {
  flex: 1;
  display: grid;
  grid-template-rows: 1fr 1fr 1fr;
  gap: 10px;
  min-height: 0;
}
.door {
  border: 1.5px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 22px;
  padding: 18px 20px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
}
.door strong { font-size: 1.45rem; letter-spacing: -0.03em; }
.door span { color: var(--mute); font-size: 0.92rem; line-height: 1.25; }
.door:active { border-color: var(--pink); }

.fields {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fields label { display: flex; flex-direction: column; gap: 6px; }
.fields span {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mute);
}
.hint {
  font-size: 0.95rem;
  color: #d4c4c8;
  line-height: 1.4;
}
.fields input[type="text"],
.fields input:not([type="file"]) {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 14px;
  padding: 11px 12px;
  font: 600 1rem/1.2 var(--font);
}
#ticker { text-transform: uppercase; letter-spacing: 0.08em; }
.mark-pick input[type="file"] { font-size: 12px; color: var(--mute); }
.jersey {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: #2a1b22;
  border: 1.5px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.jersey img { width: 100%; height: 100%; object-fit: contain; }
.jersey span { font-size: 1.8rem; font-weight: 700; color: var(--duck); }

.addr {
  font-size: 12px;
  color: var(--mute);
  word-break: break-all;
  min-height: 2.4em;
}

.invite-row { display: flex; gap: 8px; }
.invite-row input {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 12px;
  padding: 12px;
  font-size: 11px;
}
.chip {
  border: 1.5px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 12px;
  padding: 0 14px;
  font: 700 0.85rem var(--font);
  cursor: pointer;
}

.seats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.seats-sm { margin-top: 4px; }
.seat {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: #221c1e;
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  color: var(--mute);
  font-size: 10px;
  font-weight: 700;
}
.seat.is-on { border-color: var(--pink); }
.seat.is-mine { box-shadow: inset 0 0 0 2px var(--pink); }
.seat img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  /* Fill the square tile edge-to-edge (avatar-style) instead of letterboxing
     a non-square mark with empty gaps. */
  object-fit: cover;
  border-radius: inherit;
}
.seat.is-open {
  background: #1a241c;
  border-color: #3a6a48;
  flex-direction: column;
  gap: 1px;
  font-size: 8px;
  letter-spacing: 0.04em;
}
.seat.is-gate-next {
  border-color: var(--pink);
  animation: gatenext 1.4s ease-in-out infinite;
}
@keyframes gatenext {
  50% { box-shadow: 0 0 0 2px rgba(224, 68, 124, 0.55); }
}
.seat.is-sale { background: #3a2a18; border-color: #c9a04a; }

.scr-book { padding-bottom: calc(10px + env(safe-area-inset-bottom)); gap: 8px; }
.book-top {
  display: grid;
  grid-template-columns: 40px 36px 1fr auto auto;
  align-items: center;
  gap: 6px;
}
.book-type button {
  min-width: 36px;
  min-height: 36px;
}
.book-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: contain;
  background: #2a1b22;
}
.book-id {
  min-width: 0;
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0;
  font: inherit;
}
.book-id strong { display: block; font-size: 1.15rem; letter-spacing: -0.03em; }
.book-id span { font-size: 11px; color: var(--mute); }
.live {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--bid);
}

.chart {
  position: relative;
  flex: 1;
  min-height: 160px;
  background: #100e10;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}
.chart canvas { width: 100%; height: 100%; display: block; }
.chart-cap {
  position: absolute;
  left: 10px;
  bottom: 8px;
  font-size: 10px;
  color: var(--mute);
  z-index: 2;
  pointer-events: none;
}
.chart-tfs {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 4;
  display: flex;
  gap: 3px;
  pointer-events: auto;
}
.chart-tf {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 5px 6px;
  min-width: 28px;
  min-height: 26px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: rgba(16, 14, 16, 0.82);
  color: var(--mute);
}
.chart-tf.is-on {
  border-color: var(--pink);
  color: var(--ink);
  background: #2a1b22;
}
.marks { position: absolute; inset: 0; pointer-events: none; }
.mark-hair {
  position: absolute;
  height: 0;
  border-top: 1px dashed;
  opacity: 0.4;
  pointer-events: none;
}
.mark-hair.bid, .mark-hair.buy { border-color: var(--bid); }
.mark-hair.ask, .mark-hair.sell { border-color: var(--ask); }
.mark-chip {
  position: absolute;
  width: 26px;
  height: 26px;
  margin-left: -13px;
  margin-top: -13px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--bid);
  box-shadow: 0 0 0 1px #141012, 0 2px 6px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  z-index: 2;
  background: #2a1b22;
}
.mark-chip.ask, .mark-chip.sell { border-color: var(--ask); }
.mark-chip.bid, .mark-chip.buy { border-color: var(--bid); }
.mark-chip.is-ghost { opacity: 0.72; }
.mark-chip img, .mark-chip span {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
}
.chart { box-shadow: none; }
.seats.is-flash .seat { animation: seatflash 0.9s ease; }
@keyframes seatflash { 50% { border-color: var(--pink); } }
.pads-8 { grid-template-columns: repeat(4, 1fr); gap: 5px; }
.pads-8 .pad { min-height: 40px; font-size: 0.78rem; }
html.is-wallet .pads-8 .pad { min-height: 44px; font-size: 0.88rem; }
.scr-book .seats { flex: 0 0 auto; }
.split-row { display: flex; gap: 8px; margin: 10px 0; }
.split-row .chip.is-on { border-color: var(--pink); color: var(--pink); }
.split-seats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}
.split-seats button {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  background: #221c1e;
  color: var(--mute);
  font-size: 10px;
  font-weight: 700;
}
.split-seats button.is-on { border-color: var(--pink); color: var(--ink); }
.split-seats img { width: 100%; height: 100%; object-fit: contain; border-radius: 6px; }
.sheet-card input {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 12px;
  padding: 14px 14px;
  min-height: 52px;
  font: 600 1.35rem/1.2 var(--font);
}
.act-preview {
  margin: 8px 0 4px;
  font-size: 0.95rem;
  color: #d4c4c8;
}
.act-preview .prow {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
}
.act-preview .prow .v { color: var(--ink); font-weight: 600; }
.act-err { color: #ff8a8a; font-size: 0.95rem; margin: 6px 0; min-height: 0; line-height: 1.35; }
.act-steps { margin: 8px 0; }
.act-steps .step {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  padding: 4px 0;
  color: var(--mute);
}
.act-steps .step.active { color: var(--ink); }
.act-steps .step.done { color: var(--bid); }
.act-steps .step.fail { color: var(--ask); }
.act-steps .dot {
  width: 16px;
  flex: 0 0 16px;
  text-align: center;
  font-weight: 700;
}
.seat { position: relative; }
.seat.is-talk { box-shadow: 0 0 0 2px #4ecb7d; }
.act-marks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
  margin: 8px 0 2px;
}
.act-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--bid);
  background: #2a1b22;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
}
.act-mark img { width: 100%; height: 100%; object-fit: contain; }
.floor {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  flex: 0 0 auto;
}
.floor-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font: 700 0.78rem var(--font);
  background: #3a3034;
  color: #fff;
  cursor: pointer;
}
.floor-btn.is-wait { background: #3a3420; color: var(--duck); }
.floor-btn.is-live { background: #1e3a28; color: #4ecb7d; }
.floor-hint {
  font-size: 11px;
  color: var(--mute);
  line-height: 1.25;
}
.live.is-tv { animation: tv 1.2s ease-in-out infinite; }
@keyframes tv { 50% { opacity: 0.35; } }

.pads { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pads-6 { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.pad {
  min-height: 40px;
  border-radius: 12px;
  border: 0;
  font: 700 0.78rem var(--font);
  cursor: pointer;
  color: #fff;
  background: #3a3034;
}
.pad.bid { background: var(--bid); }
.pad.ask { background: var(--ask); }
.pad.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }

.sheet {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  z-index: 5;
}
.sheet-card {
  width: 100%;
  max-height: 92dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
  border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
}
.sheet-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.sheet-card header strong { font-size: 1.35rem; letter-spacing: -0.03em; }
#actWallet { font-size: 0.95rem; line-height: 1.4; color: #eee4e6; }
.type-zoom {
  display: inline-flex;
  gap: 4px;
  margin-left: auto;
}
.type-zoom button {
  min-width: 40px;
  min-height: 40px;
  border: 1.5px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 10px;
  font: 700 0.95rem var(--font);
  cursor: pointer;
}
.room-card { max-height: 88dvh; }
.pads-room {
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin: 10px 0 8px;
}
#roomArb { margin: 0 0 8px; }
.pads-room .pad {
  min-height: 38px;
  text-decoration: none;
  display: grid;
  place-items: center;
}
.room-books {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 22vh;
  overflow: auto;
  margin-top: 8px;
}
.room-book {
  border: 1.5px solid var(--line);
  background: #221c1e;
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 12px;
  font: 700 0.72rem var(--font);
  cursor: pointer;
}
.room-book.is-on { border-color: var(--pink); color: #fff; }
.lib-mark {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  overflow: hidden;
  margin: 10px 0;
  background: #2a1b22;
}
.lib-mark img { width: 100%; height: 100%; object-fit: contain; }
.lib-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0;
}
.lib-stats dt { font-size: 11px; color: var(--mute); }
.lib-stats dd { font-size: 1.1rem; font-weight: 700; }
.dir-head { display: flex; gap: 12px; align-items: center; margin: 8px 0; }
.dir-head img { width: 56px; height: 56px; border-radius: 14px; object-fit: contain; background: #2a1b22; }
.dir-seats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0 14px; max-height: 28vh; overflow: auto; }
.dir-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
}

/* Desktop / wide viewports — the phone-first column otherwise stretches edge to
   edge and squeezes the chart into a thin strip. Center it as a framed device
   column and give the book chart real vertical room so you can read the tape. */
@media (min-width: 820px) {
  .pilot-stage { justify-content: center; }
  .pilot {
    max-width: 820px;
    margin-inline: auto;
    border-inline: 1px solid var(--line);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 30px 90px rgba(0, 0, 0, 0.5);
  }
  .scr-book .chart { min-height: 44vh; }
}

[hidden] { display: none !important; }
