/* The phone controller, in the Grimoire's colours. */
:root {
  --surface: #1a130b;
  --panel: #241a10;
  --raised: #2e2114;
  --vellum: #f1e5cc;
  --ash: #c4b08c;
  --gilt: #dcb462;
  --gilt-bright: #f2d38e;
  --line: #4d3a22;
  --blue: #3f9ff2;
  --copper: #d5814a;
  --dim: #6e5d43;
  --serif: 'IM Fell English', Georgia, serif;
  --sans: 'Atkinson Hyperlegible', system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--surface);
  color: var(--vellum);
  font-family: var(--sans);
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  height: 100%;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  max-width: 560px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 10px env(safe-area-inset-bottom);
}

/* ---------------- Turn strip ---------------- */

.turn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px 8px;
  min-height: 56px;
}
.turn-who { flex: 1; min-width: 0; }
.turn-who b {
  display: block;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 400;
  color: var(--gilt-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.turn-who span { display: block; font-size: 12px; color: var(--ash); }
.turn-no {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--ash);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

/* ---------------- The table ---------------- */

/* Rows of seats, with you along the bottom. Any pod from two to six fills the
   screen rather than squeezing into a fixed shape. */
.table {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 0 6px;
  min-height: 0;
}
.row {
  display: flex;
  gap: 8px;
  flex: 1 1 0;
  min-height: 0;
}
.row-you { flex: 1.3 1 0; }

.seat {
  position: relative;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  padding: 8px 10px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  transition: border-color .12s, background .12s;
}
.seat-you { background: var(--raised); }
.seat.active { border-color: var(--gilt); box-shadow: inset 0 0 0 1px var(--gilt); }
.seat.holding { background: #352512; border-color: var(--gilt-bright); }
.seat.out { opacity: .45; }
.seat.out .life { text-decoration: line-through; }

.seat-name {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.1;
  color: var(--vellum);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seat-you .seat-name { font-size: 17px; }
.seat-deck {
  font-size: 11px;
  color: var(--ash);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.life {
  font-family: var(--serif);
  font-size: 38px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--vellum);
}
.seat-you .life { font-size: 60px; color: var(--gilt-bright); }
.life.low { color: var(--copper); }

/* Five or six at the table: smaller type so nothing is clipped. */
.crowded .seat-name { font-size: 13px; }
.crowded .seat-deck { display: none; }
.crowded .life { font-size: 30px; }
.crowded .seat-you .seat-name { font-size: 16px; }
.crowded .seat-you .seat-deck { display: block; }
.crowded .seat-you .life { font-size: 52px; }
.crowded .mark { font-size: 10px; padding: 2px 5px; }

/* Badges: poison, commander damage, monarch, initiative */
.marks {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin-top: 2px;
  min-height: 0;
}
.mark {
  font-size: 11px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ash);
  white-space: nowrap;
}
.mark.crown { border-color: var(--gilt); color: var(--gilt-bright); }
.mark.cmd { border-color: var(--copper); color: var(--copper); }
.mark.poison { border-color: #7fae5c; color: #9ccf78; }
.mark.gone { border-color: var(--dim); color: var(--dim); }

/* The number that follows your thumb while dragging */
.scrub {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: var(--serif);
  font-size: 62px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: #1f1710;
  color: var(--gilt-bright);
  pointer-events: none;
}
.scrub.gain { color: #8fd07a; }
.scrub small {
  font-size: 13px;
  font-family: var(--sans);
  color: var(--ash);
  letter-spacing: .02em;
}

/* ---------------- Bottom bar ---------------- */

.bar {
  display: flex;
  gap: 8px;
  padding: 8px 0 10px;
  align-items: stretch;
}
.btn {
  flex: 1;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--vellum);
  font-family: var(--sans);
  font-size: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 8px;
}
.btn:active { background: var(--raised); }
.btn[disabled] { opacity: .35; }
.btn small {
  font-size: 11px;
  color: var(--ash);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-main { flex: 1.6; border-color: var(--gilt); color: var(--gilt-bright); }
.btn-undo small { color: var(--copper); }

/* ---------------- Hold menu ---------------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: rgba(10, 7, 4, .6);
}
.sheet-inner {
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}
.sheet h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 20px;
  margin: 2px 2px 10px;
  color: var(--gilt-bright);
}
.sheet h2 span { color: var(--ash); font-size: 13px; font-family: var(--sans); display: block; }
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.grid .btn { min-height: 56px; }
.grid .wide { grid-column: 1 / -1; }
.grid.nums { grid-template-columns: repeat(4, 1fr); }
.grid.nums .btn {
  min-height: 58px;
  font-family: var(--serif);
  font-size: 26px;
  font-variant-numeric: tabular-nums;
}
.danger { border-color: var(--copper); color: var(--copper); }

/* ---------------- Notice ---------------- */

.notice {
  position: fixed;
  left: 50%;
  top: calc(10px + env(safe-area-inset-top));
  transform: translateX(-50%);
  background: #3a2b1b;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .55);
  border: 1px solid var(--gilt);
  color: var(--vellum);
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 30;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  white-space: nowrap;
  max-width: 92vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notice.on { opacity: 1; }

/* ---------------- Finished ---------------- */

.over {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--gilt);
  border-radius: 16px;
  background: var(--panel);
  padding: 18px;
}
.over b {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 400;
  color: var(--gilt-bright);
}
.over span { color: var(--ash); font-size: 14px; }

/* ---------------- Shared games ---------------- */

/* The line across the top: the last thing recorded, or that the phone is offline. */
.strip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 6px 0 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ash);
  font: 13px/1.3 var(--sans);
  text-align: left;
}
.strip.none { display: none; }
.strip span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--vellum); }
.strip i { font-style: normal; color: var(--gilt); font-size: 12px; }
.strip.bad { border-color: var(--copper); background: #3a1f12; color: var(--vellum); }
.strip.bad b { color: #ffb38a; }

/* Offline, connecting or refused: the game stays readable but nothing can be tapped into it. */
body.readonly .seat,
body.readonly .btn-main:not([data-act="leave"]),
body.readonly .btn-undo { opacity: .45; filter: grayscale(.6); }

.qr {
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  width: min(72vw, 300px);
  margin: 6px auto 10px;
}
.qr svg { display: block; width: 100%; height: auto; }
.link {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ash);
  font: 12px var(--sans);
  user-select: all;
  -webkit-user-select: all;
}
.fine { color: var(--dim); font-size: 12px; margin: 10px 2px 0; }

.feed { list-style: none; margin: 0; padding: 0; max-height: 55vh; overflow-y: auto; }
.feed li { padding: 8px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.feed time { display: inline-block; min-width: 64px; color: var(--dim); font-size: 12px; }
