/* draftroom — sized for iPad first (768–1366pt), scales up to desktop. */

:root {
  --bg: #f7f6f3;
  --surface: #fffefc;
  --surface-2: #f0eee9;
  --ink: #171a19;
  --ink-2: #4e534f;
  --ink-3: #8b8f8a;
  --line: #e2e0d9;
  --line-2: #d2cfc6;
  --accent: #1d6b53;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe9;
  --win: #1d6b53;
  --loss: #a33a2e;
  --danger: #a33a2e;

  --r-sm: 7px;
  --r-md: 11px;
  --r-lg: 16px;
  --shadow-1: 0 1px 2px rgba(20, 24, 22, .05), 0 1px 1px rgba(20, 24, 22, .03);
  --shadow-2: 0 6px 24px -8px rgba(20, 24, 22, .18), 0 2px 6px -2px rgba(20, 24, 22, .07);
  --ease: cubic-bezier(.32, .72, 0, 1);
  --rail: 17rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101312;
    --surface: #181c1b;
    --surface-2: #202524;
    --ink: #e9ece9;
    --ink-2: #a8afab;
    --ink-3: #71786f;
    --line: #262c2a;
    --line-2: #333a37;
    --accent: #5cc79c;
    --accent-ink: #0c0f0e;
    --accent-soft: #172a23;
    --win: #5cc79c;
    --loss: #e08276;
    --danger: #e08276;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 8px 30px -10px rgba(0, 0, 0, .65), 0 2px 8px -3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "kern", "liga";
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Touch targets: iPad wants 44pt. */
button, input, textarea, select { font: inherit; color: inherit; }
button { min-height: 2.5rem; }

/* ============================ landing ============================ */

.shell { max-width: 40rem; margin: 0 auto; padding: clamp(2rem, 8vh, 5rem) 1.5rem 4rem; }

.wordmark {
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1.75rem;
}

h1 {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  line-height: 1.15;
  letter-spacing: -.02em;
  margin: 0 0 .75rem;
}

.lede { color: var(--ink-2); font-size: 1.02rem; margin: 0 0 2.5rem; max-width: 34rem; }

.field { margin-bottom: 1.4rem; }
.field label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .01em;
  margin-bottom: .4rem;
}
.optional { font-weight: 400; color: var(--ink-3); }

input[type=text], input[type=password], textarea {
  width: 100%;
  padding: .7rem .85rem;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
input[type=text]:focus, input[type=password]:focus, textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }

.hint { font-size: .84rem; color: var(--ink-3); margin: .5rem 0 0; line-height: 1.45; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .6rem 1.15rem;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 550;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: transform .12s var(--ease), filter .16s var(--ease), opacity .16s;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: progress; filter: none; }

.btn-quiet {
  background: var(--surface);
  color: var(--ink-2);
  border-color: var(--line-2);
  box-shadow: none;
}
.btn-quiet:hover { background: var(--surface-2); filter: none; }

.status { min-height: 1.5rem; font-size: .9rem; margin: 1rem 0 0; color: var(--ink-2); }
.status.error { color: var(--danger); }

/* Auth pages sit a little narrower and higher than the create form. */
.narrow-form { max-width: 26rem; }
.switcher { margin-top: 2rem; }

.whoami {
  font-size: .85rem;
  font-weight: 550;
  color: var(--ink-2);
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================ room chrome ============================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  align-items: center;
  justify-content: space-between;
  padding: .75rem clamp(1rem, 3vw, 1.75rem);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-left { min-width: 0; }
.brand {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
}
.roomtitle {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -.01em;
  margin: .1rem 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}
.meta { margin: .1rem 0 0; font-size: .8rem; color: var(--ink-3); }
.meta a { color: var(--ink-3); }
.dot { opacity: .5; margin: 0 .4rem; }

.topbar-right { display: flex; align-items: center; gap: .6rem; }
.topbar-right input { width: 9.5rem; padding: .45rem .65rem; }

.live {
  width: .55rem; height: .55rem;
  border-radius: 50%;
  background: var(--ink-3);
  flex: none;
  transition: background .3s var(--ease), box-shadow .3s var(--ease);
}
.live.on { background: var(--win); box-shadow: 0 0 0 3px color-mix(in srgb, var(--win) 22%, transparent); }

/* ============================ layout ============================ */

.layout {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: clamp(1rem, 2vw, 1.5rem);
  padding: clamp(1rem, 2vw, 1.5rem);
  align-items: start;
}

.rail {
  position: sticky;
  top: 4.6rem;
  max-height: calc(100vh - 6rem);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

/* Segmented control — Draft / Games */
.segmented {
  display: flex;
  gap: .2rem;
  padding: .35rem;
  margin: .5rem .5rem 0;
  background: var(--surface-2);
  border-radius: var(--r-md);
}
.segmented button {
  flex: 1;
  min-height: 2.1rem;
  border: 0;
  border-radius: calc(var(--r-md) - 3px);
  background: transparent;
  color: var(--ink-2);
  font-size: .86rem;
  font-weight: 550;
  cursor: pointer;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.segmented button[aria-selected=true] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}
.segmented button:disabled { opacity: .38; cursor: not-allowed; }

.raillist { overflow-y: auto; padding: .45rem; -webkit-overflow-scrolling: touch; }

.grouplabel {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: .68rem;
  font-weight: 650;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: .7rem .55rem .35rem;
  background: linear-gradient(var(--surface) 72%, transparent);
}

.railitem {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  min-height: 2.35rem;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--ink);
  padding: .35rem .55rem;
  border-radius: var(--r-sm);
  font-size: .875rem;
  cursor: pointer;
  transition: background .14s var(--ease);
}
.railitem:hover { background: var(--surface-2); }
.railitem[aria-current=true] { background: var(--accent); color: var(--accent-ink); }
.railitem .idx {
  flex: none;
  width: 2.6rem;
  font-variant-numeric: tabular-nums;
  font-size: .78rem;
  color: var(--ink-3);
}
.railitem[aria-current=true] .idx { color: color-mix(in srgb, var(--accent-ink) 75%, transparent); }
.railitem .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pip { flex: none; width: .45rem; height: .45rem; border-radius: 50%; }
.pip.win { background: var(--win); }
.pip.loss { background: var(--loss); }

.badge {
  flex: none;
  min-width: 1.3rem;
  text-align: center;
  font-size: .72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: .08rem .34rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.railitem[aria-current=true] .badge { background: var(--accent-ink); color: var(--accent); }

/* ============================ detail pane ============================ */

.detail {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: clamp(1rem, 2.2vw, 1.6rem);
  min-height: 60vh;
}

.detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .5rem .9rem;
  margin-bottom: 1.1rem;
}
.detail-head h2 { font-size: 1.25rem; letter-spacing: -.015em; margin: 0; }

.chip {
  font-size: .75rem;
  font-weight: 550;
  padding: .15rem .55rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.chip.win { background: var(--accent-soft); color: var(--win); }
.chip.loss { background: color-mix(in srgb, var(--loss) 14%, transparent); color: var(--loss); }

.notice {
  display: flex;
  gap: .6rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
  padding: .65rem .8rem;
  font-size: .875rem;
  color: var(--ink-2);
  margin-bottom: 1.2rem;
}

.subhead {
  font-size: .72rem;
  font-weight: 650;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 1.4rem 0 .6rem;
}
.subhead:first-of-type { margin-top: 0; }

/* card grids */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: .8rem;
}
.cards.tight { grid-template-columns: repeat(auto-fill, minmax(6rem, 1fr)); gap: .6rem; }

.card {
  display: block;
  border: 0;
  padding: 0;
  background: none;
  text-align: center;
  min-height: 0;
}
.card img,
.card .noimg {
  width: 100%;
  aspect-ratio: 488 / 680;
  border-radius: 4.6% / 3.3%;
  display: block;
  background: var(--surface-2);
  object-fit: cover;
  box-shadow: var(--shadow-1);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.card .noimg {
  display: grid;
  place-items: center;
  padding: .5rem;
  font-size: .74rem;
  color: var(--ink-3);
  border: 1px dashed var(--line-2);
  box-shadow: none;
  overflow-wrap: anywhere;
}
.card.picked img, .card.picked .noimg {
  box-shadow: 0 0 0 3px var(--accent), var(--shadow-2);
}
.card .cap {
  font-size: .76rem;
  line-height: 1.3;
  margin-top: .4rem;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}
.card.picked .cap { color: var(--accent); font-weight: 600; }

.statgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: .7rem;
  margin-bottom: .4rem;
}
.stat {
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: .55rem .7rem;
}
.stat dt { font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.stat dd { margin: .1rem 0 0; font-size: .95rem; font-weight: 550; font-variant-numeric: tabular-nums; }

/* ============================ comments ============================ */

.comments { margin-top: 2rem; border-top: 1px solid var(--line); padding-top: 1.2rem; }

.comment {
  display: flex;
  gap: .7rem;
  padding: .55rem 0;
}
.comment + .comment { border-top: 1px solid var(--line); }

.avatar {
  flex: none;
  width: 2rem; height: 2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .78rem;
  font-weight: 650;
  background: var(--accent-soft);
  color: var(--accent);
  user-select: none;
}
.comment-main { min-width: 0; flex: 1; }
.comment-head { display: flex; align-items: baseline; gap: .5rem; }
.who { font-weight: 600; font-size: .88rem; }
.when { color: var(--ink-3); font-size: .76rem; }
.comment .body { white-space: pre-wrap; overflow-wrap: anywhere; margin: .15rem 0 0; }

.del {
  background: none;
  border: 0;
  color: var(--ink-3);
  cursor: pointer;
  font-size: .76rem;
  min-height: 1.8rem;
  padding: 0 .3rem;
  border-radius: 4px;
  margin-left: auto;
}
.del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }

.composer { margin-top: 1rem; }
.composer textarea { min-height: 5rem; resize: vertical; line-height: 1.5; }
.composer-row {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin-top: .6rem;
}
.kbd { font-size: .78rem; color: var(--ink-3); }
kbd {
  font: inherit;
  font-size: .72rem;
  padding: .05rem .3rem;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
}
/* Inline post error — takes no space until it has something to say. */
.composer .status { margin: .45rem 0 0; min-height: 0; font-size: .84rem; }
.composer .status:empty { display: none; }

.empty { color: var(--ink-3); font-size: .9rem; margin: .2rem 0 0; }
.placeholder { color: var(--ink-3); }

/* ============================ responsive ============================ */

/* iPad portrait and narrower: rail becomes a horizontal strip. */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .rail { position: static; max-height: none; }
  .raillist {
    display: flex;
    gap: .35rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding: .5rem;
    scroll-snap-type: x proximity;
  }
  .grouplabel {
    position: static;
    background: none;
    align-self: center;
    padding: 0 .3rem;
    white-space: nowrap;
  }
  .railitem {
    width: auto;
    flex: none;
    scroll-snap-align: start;
    white-space: nowrap;
  }
  .railitem .label { max-width: 9rem; }
  .roomtitle { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* --- 17Lands link panel --- */
.panel {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}
.panel-title { font-size: 1.05rem; margin: 0 0 .4rem; letter-spacing: -.01em; }
.panel-lede { color: var(--ink-2); font-size: .92rem; margin: 0 0 1rem; }
.panel textarea { width: 100%; resize: vertical; font-size: .85rem; }
.panel .hint code {
  font-size: .82em;
  padding: .05rem .25rem;
  border-radius: 4px;
  background: var(--surface-2);
}
.hint.warn {
  border-left: 3px solid var(--accent);
  padding-left: .65rem;
  color: var(--ink-2);
}
#linkactions { display: flex; gap: .6rem; }
.roomlist { list-style: none; padding: 0; margin: .8rem 0 0; font-size: .88rem; }
.roomlist li { margin-bottom: .2rem; }

/* --- your drafts --- */
.draftlist { list-style: none; padding: 0; margin: 0; }
.draftlist li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .3rem .7rem;
  padding: .6rem 0;
  border-bottom: 1px solid var(--line);
}
.draftlist li:last-child { border-bottom: 0; }
.draftlink { font-weight: 550; text-decoration: none; }
.draftlink:hover { text-decoration: underline; }
.draftmeta { font-size: .8rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* --- play by play --- */
.turns { list-style: none; padding: 0; margin: 0 0 1.5rem; counter-reset: none; }
.turn {
  border-left: 3px solid var(--line-2);
  padding: .5rem 0 .5rem .8rem;
  margin-bottom: .35rem;
}
.turn.mine { border-left-color: var(--accent); }
.turnhead { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.turnno { font-weight: 650; font-size: .9rem; }
.turnwho { font-size: .78rem; color: var(--ink-3); }
.life {
  margin-left: auto;
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  background: var(--surface-2);
  padding: .05rem .45rem;
  border-radius: 999px;
}
.plays { list-style: none; padding: 0; margin: .3rem 0 0; }
.plays li {
  display: flex;
  align-items: baseline;
  gap: .45rem;
  font-size: .88rem;
  padding: .12rem 0;
  flex-wrap: wrap;
}
.plays .who {
  flex: none;
  min-width: 2.4rem;
  font-size: .72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-3);
}
.plays li.mine .who { color: var(--accent); }
.plays .verb { color: var(--ink-3); }
.plays .cardname { font-weight: 550; }
.plays .phase { font-size: .74rem; color: var(--ink-3); }

/* --- foldouts (wheel + opponent card dump) --- */
details.wheel, details.foldout {
  margin-top: 1rem;
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: .7rem .85rem;
}
details.wheel > summary, details.foldout > summary {
  cursor: pointer;
  font-size: .88rem;
  font-weight: 550;
  min-height: 2rem;
  display: flex;
  align-items: center;
}
details.wheel[open] > summary, details.foldout[open] > summary { margin-bottom: .7rem; }
