:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --text: #1d1b19;
  --muted: #6b6560;
  --line: #ddd8d0;
  --accent: #b5481f;
  --accent-text: #ffffff;
  --error: #b3261e;
  --ok: #2e7d32;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --surface: #211f1d;
    --text: #ece8e3;
    --muted: #a39d96;
    --line: #36322e;
    --accent: #e0703f;
    --accent-text: #161514;
    --error: #f2857c;
    --ok: #81c784;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main { max-width: 960px; margin: 0 auto; padding: 24px 16px 48px; }
main.narrow { max-width: 400px; padding-top: 12vh; }

h1 { font-size: 1.6rem; margin: 0 0 20px; }
h2 { font-size: 1.2rem; margin: 0 0 16px; }
a { color: var(--accent); }
.brand { font-weight: 700; letter-spacing: 0.01em; }
main.narrow .brand { text-align: center; }
.muted { color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

label { display: block; margin-bottom: 14px; font-weight: 500; }
input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  font: inherit;
  font-weight: 600;
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}
form.card button { width: 100%; margin-top: 4px; }
button.link { background: none; color: var(--accent); padding: 4px 0 4px 8px; font-weight: 500; }

.error { color: var(--error); margin: 0 0 14px; }
.notice { color: var(--ok); margin: 0 0 14px; font-weight: 500; }
.hint { display: block; margin-top: 4px; color: var(--muted); font-size: 0.875rem; font-weight: 400; }
p.hint { margin: 0 0 14px; }
.below { margin: 16px 0 0; text-align: center; font-size: 0.95rem; }
a.plain { color: inherit; text-decoration: none; }
main.medium { max-width: 560px; }
main.medium .card { margin-bottom: 20px; }
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
form.card button.secondary { width: auto; }

/* Admin screen */
.tabs { display: flex; gap: 4px; margin: -8px 0 20px; border-bottom: 1px solid var(--line); }
.tabs a {
  padding: 8px 14px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a.current { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.small { font-size: 0.875rem; }
p.small { margin: 4px 0 12px; }
button.small { padding: 6px 10px; font-size: 0.875rem; }
button.danger { background: var(--error); color: var(--accent-text); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.actions form.inline { display: inline; }
.small-link { font-size: 0.875rem; }
.danger-link { color: var(--error); }
.person-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.tag.warn { color: var(--error); border-color: var(--error); }
.linkbox { margin: 0 0 14px; padding: 12px; border: 1px dashed var(--accent); border-radius: 8px; }
.linkbox input { margin: 0 0 8px; font-size: 0.875rem; }
.linkbox .row { display: flex; gap: 8px; }
.linkbox .hint { margin: 8px 0 0; }
form.card .linkbox button { width: auto; margin: 0; }
.invites { list-style: none; margin: 0; padding: 0; }
.invites li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.invites li:last-child { border-bottom: 0; }
.invite-status { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.below-form { display: flex; justify-content: flex-end; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.below-form button.danger { background: transparent; color: var(--error); border: 1px solid var(--error); }

.devices { list-style: none; margin: 0 0 16px; padding: 0; }
.devices li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.devices li:last-child { border-bottom: 0; }
.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
form.inline { display: flex; align-items: center; gap: 4px; margin: 0; }
.bar { flex-wrap: wrap; row-gap: 4px; }
.bar form.inline { gap: 16px; flex-wrap: wrap; }
.bar a, .bar button { white-space: nowrap; }
.bar button.link { padding-left: 0; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 120px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}
.tile:hover, .tile:focus-visible { border-color: var(--accent); }
.tile-name { font-size: 1.2rem; font-weight: 700; }
.tile-desc { color: var(--muted); }

/* Logged-out pages: the game-table picture fills the screen behind the card.
   A fixed layer, not background-attachment: fixed, which iOS Safari ignores. */
html:has(body.art) { background: #120d09; }
body.art { background: transparent; min-height: 100vh; }
body.art::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at center, rgba(18, 13, 9, 0.35) 0%, rgba(18, 13, 9, 0.7) 75%),
    #120d09 url("/art/table-wide.webp") center / cover no-repeat;
}
@media (max-aspect-ratio: 4/5) {
  body.art::before {
    background:
      radial-gradient(ellipse at center, rgba(18, 13, 9, 0.35) 0%, rgba(18, 13, 9, 0.7) 75%),
      #120d09 url("/art/table-tall.webp") center / cover no-repeat;
  }
}
body.art main.narrow .brand {
  color: #fbf3e6;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8), 0 0 24px rgba(0, 0, 0, 0.6);
}
body.art .card {
  border-color: transparent;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

/* The game menu: the whole game room, darker than the login page because the tiles sit on it. */
body.art.room::before {
  background:
    linear-gradient(rgba(18, 13, 9, 0.75) 0%, rgba(18, 13, 9, 0.45) 45%, rgba(18, 13, 9, 0.7) 100%),
    #120d09 url("/art/room-wide.webp") center / cover no-repeat;
}
@media (max-aspect-ratio: 4/5) {
  body.art.room::before {
    background:
      linear-gradient(rgba(18, 13, 9, 0.75) 0%, rgba(18, 13, 9, 0.45) 45%, rgba(18, 13, 9, 0.7) 100%),
      #120d09 url("/art/room-tall.webp") center / cover no-repeat;
  }
}
body.art.room main h1 {
  color: #fbf3e6;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8), 0 0 24px rgba(0, 0, 0, 0.6);
}
body.art.room .tile {
  border-color: transparent;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}
body.art.room .tile:hover, body.art.room .tile:focus-visible { border-color: var(--accent); }

/* Who can use a game (admin tiles). */
fieldset.access { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px 4px; margin: 0 0 14px; }
fieldset.access legend { font-weight: 500; padding: 0 4px; }
label.check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-weight: 400; }
label.check input { display: inline-block; width: auto; margin: 0; flex: none; }
fieldset.access .people { margin-left: 26px; }

/* Game servers: the Servers tab and offline tiles on the menu. */
select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
a.button {
  display: inline-block;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
}
a.button.small { padding: 6px 10px; font-size: 0.875rem; }
a.button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.tag.ok { color: var(--ok); border-color: var(--ok); }
.tile.offline { opacity: 0.85; }
.tile.offline .tile-name .tag, .tile .tile-name .tag { font-size: 0.75rem; vertical-align: middle; font-weight: 500; }
.tile-state { color: var(--muted); font-size: 0.875rem; }
.tile form.inline { margin-top: auto; }
