:root {
  --sea: #1f5871;
  --sea-2: #2b6c8a;
  --ink: #1d2a33;
  --ink-2: #5a6a74;
  --paper: #fbf7ee;
  --paper-2: #f1e9d8;
  --line: rgba(29, 42, 51, 0.12);
  --roof: #c4472f;
  --roof-2: #a83a26;
  --beer: #f2b53c;
  --shadow: 0 10px 30px rgba(8, 24, 34, 0.28);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sea);
  overscroll-behavior: none;
}
body {
  font-size: 16px;
  -webkit-user-select: none;
  user-select: none;
}
#map {
  position: fixed;
  inset: 0;
  touch-action: none;
  display: block;
}
#app {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
#app > * > * {
  pointer-events: auto;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
button:disabled {
  cursor: default;
  opacity: 0.5;
}

/* top bar */
#top {
  position: absolute;
  top: calc(10px + var(--safe-t));
  left: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.embedded #top {
  left: 64px;
}
.title {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(251, 247, 238, 0.92);
  box-shadow: 0 4px 14px rgba(8, 24, 34, 0.2);
  font-size: 15px;
  pointer-events: none !important;
}
.title b {
  color: var(--roof);
  letter-spacing: 1px;
}
.title .time {
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.pill {
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(29, 42, 51, 0.82);
  color: #fff;
  font-size: 14px;
  pointer-events: none !important;
}
.pill.warn {
  background: #b5552f;
}
.pill.auto {
  background: #3c6e8a;
}

/* leaderboard */
#board {
  position: absolute;
  top: calc(10px + var(--safe-t));
  right: 10px;
}
#board table {
  border-collapse: collapse;
  background: rgba(251, 247, 238, 0.94);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(8, 24, 34, 0.2);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
#board th {
  font-weight: 500;
  color: var(--ink-2);
  font-size: 12px;
  padding: 6px 10px 2px;
  text-align: right;
}
#board td {
  padding: 4px 10px;
  text-align: right;
  white-space: nowrap;
}
#board td:first-child {
  text-align: left;
  max-width: 9.5em;
  overflow: hidden;
  text-overflow: ellipsis;
}
#board tr.me td {
  font-weight: 700;
}
#board tr.out td {
  color: #9aa3a8;
  text-decoration: line-through;
}
#board i,
.seats i,
.result i {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: -1px;
}
#board em,
.seats em {
  font-style: normal;
  font-size: 11px;
  color: var(--ink-2);
  background: var(--paper-2);
  border-radius: 6px;
  padding: 1px 5px;
  margin-left: 5px;
}
#board .more {
  margin-top: 4px;
  text-align: right;
  font-size: 12px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* bottom dock: big, thumb-sized buttons */
#dock {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(12px + var(--safe-b));
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 20px;
  background: rgba(251, 247, 238, 0.95);
  box-shadow: var(--shadow);
}
#dock:empty {
  display: none;
}
#dock button {
  width: 60px;
  height: 58px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 12px;
  color: var(--ink);
}
#dock button svg {
  width: 24px;
  height: 24px;
}
#dock button:active {
  background: var(--paper-2);
}
#dock button.on {
  background: var(--sea-2);
  color: #fff;
}

/* countdown */
#count {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 120px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
#count.show {
  opacity: 1;
}

/* sheets */
#sheet {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#sheet.modal {
  pointer-events: auto;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  background: radial-gradient(ellipse at 30% 20%, rgba(43, 108, 138, 0.55), rgba(15, 40, 54, 0.75));
}
.card {
  width: min(440px, 100%);
  background: var(--paper);
  border-radius: 22px;
  padding: 24px 22px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: rise 0.28s ease-out;
}
@keyframes rise {
  from {
    transform: translateY(14px);
    opacity: 0;
  }
}
.card h1 {
  margin: 0;
  font-size: 28px;
  color: var(--roof);
  letter-spacing: 2px;
}
.card h2 {
  margin: 0;
  font-size: 22px;
}
.sub {
  margin: 0;
  color: var(--ink-2);
  line-height: 1.55;
}
.center {
  text-align: center;
}
.hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.logo,
.trophy {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--roof);
  color: #fff;
  display: grid;
  place-items: center;
}
.logo svg,
.trophy svg {
  width: 38px;
  height: 38px;
}
.trophy {
  margin: 0 auto;
  background: var(--beer);
}
.finish h1 {
  text-align: center;
}
.finish .sub {
  text-align: center;
}
form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
label {
  font-weight: 600;
}
input {
  font: inherit;
  font-size: 18px;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #fff;
  -webkit-user-select: text;
  user-select: text;
}
input:focus {
  outline: 2px solid var(--sea-2);
  border-color: transparent;
}
.primary {
  border: 0;
  border-radius: 14px;
  padding: 15px;
  font-size: 18px;
  font-weight: 700;
  background: var(--roof);
  color: #fff;
}
.primary:active {
  background: var(--roof-2);
}
.ghost {
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
  font-weight: 600;
}
.link {
  text-align: center;
  color: var(--ink-2);
  font-size: 14px;
}
.error {
  margin: 0;
  color: #b23a24;
  font-weight: 600;
}
.wait {
  margin: 4px 0;
  text-align: center;
  color: var(--ink-2);
}
.code {
  letter-spacing: 2px;
  color: var(--ink);
}
details summary {
  cursor: pointer;
  color: var(--sea-2);
  font-weight: 600;
}
.rules {
  margin: 10px 0 0;
  padding-left: 18px;
  line-height: 1.6;
  font-size: 15px;
}
.rules li {
  margin-bottom: 4px;
}
.keys {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--ink-2);
}
.seats,
.result {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.seats li,
.result li {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
}
.seats li span {
  font-weight: 600;
}
.seats em.you {
  background: var(--sea-2);
  color: #fff;
}
.seats .x {
  margin-left: auto;
  border: 0;
  background: var(--paper-2);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
}
.result li span {
  font-weight: 600;
}
.result li small {
  margin-left: auto;
  color: var(--ink-2);
}
.result li:first-child {
  background: #fff6dc;
  border-color: #efd28a;
}
.opts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.opts span {
  width: 3em;
  color: var(--ink-2);
  font-size: 14px;
}
.chip {
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  background: #fff;
  font-size: 14px;
}
.chip.on {
  background: var(--sea-2);
  border-color: var(--sea-2);
  color: #fff;
}
.chip:disabled.on {
  opacity: 1;
}

/* in-game menu */
.menu {
  position: absolute;
  right: max(12px, calc(50% - 190px));
  bottom: calc(86px + var(--safe-b));
  display: flex;
  flex-direction: column;
  min-width: 180px;
  background: var(--paper);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise 0.18s ease-out;
}
.menu button {
  border: 0;
  background: transparent;
  padding: 15px 18px;
  text-align: left;
  font-size: 16px;
  border-bottom: 1px solid var(--line);
}
.menu button:last-child {
  border-bottom: 0;
}
.menu .danger {
  color: #b23a24;
  font-weight: 600;
}
.float {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(18px + var(--safe-b));
  border: 0;
  border-radius: 999px;
  padding: 14px 26px;
  font-size: 17px;
  font-weight: 700;
  background: var(--roof);
  color: #fff;
  box-shadow: var(--shadow);
}

/* banner and toast */
#banner {
  position: fixed;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%) scale(0.9);
  padding: 16px 26px;
  border-radius: 18px;
  background: rgba(29, 42, 51, 0.92);
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  max-width: calc(100% - 32px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.25s,
    transform 0.25s;
}
#banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
#banner.gold {
  background: linear-gradient(135deg, #f2b53c, #d9852a);
  color: #3a2408;
}
#banner.bad {
  background: linear-gradient(135deg, #c4472f, #8e2e1d);
}
#banner.warn {
  background: #b5552f;
}
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + var(--safe-b));
  transform: translateX(-50%) translateY(8px);
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(29, 42, 51, 0.9);
  color: #fff;
  font-size: 15px;
  max-width: calc(100% - 32px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%);
}

@media (max-width: 699px) {
  .title {
    font-size: 14px;
    padding: 6px 12px;
    gap: 8px;
  }
  #board table {
    font-size: 13px;
  }
  #board td:first-child {
    max-width: 6.5em;
  }
  #board table:not(.open) thead {
    display: none;
  }
  #dock {
    gap: 2px;
    padding: 5px;
  }
  #dock button {
    width: 54px;
    height: 56px;
  }
  .embedded #top {
    top: calc(60px + var(--safe-t));
    left: 12px;
  }
}
@media (max-width: 360px) {
  #dock button {
    width: 48px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .card,
  .menu {
    animation: none;
  }
}
