/* ---------------------------------------------------------------------------
   Spieltisch.

   Every value in the token block is the one the chess app already uses
   (stacks/chess/app/public/style.css). The platform does not invent a second
   language: it lifts the one that exists into a shared file, and each game
   draws with it. New here are only the three parts chess never needed -- chat
   bubble, seat, die -- and they are built from the same pieces.

   Three theme blocks, as over there: the light default, the system preference,
   and the forced choice. A colour whose only definition sits inside a media
   query has no value when the user forces the other theme.
   --------------------------------------------------------------------------- */

:root {
  color-scheme: light;

  /* ground */
  --bg: #dde3ec;
  --bg-a: #a9d2c6;          /* jade wash */
  --bg-b: #edd9b6;          /* warm wash */
  --bg-c: #b9c7e4;          /* cool wash */

  /* glass */
  --glass: rgba(255, 255, 255, .50);
  --glass-strong: rgba(255, 255, 255, .72);
  --glass-brd: rgba(255, 255, 255, .85);
  --glass-edge: rgba(255, 255, 255, .9);
  --glass-ring: rgba(20, 30, 40, .09);
  --blur: blur(22px) saturate(180%);
  --shadow: 0 1px 2px rgba(20, 30, 40, .05), 0 10px 32px -8px rgba(20, 30, 40, .18);
  --shadow-sm: 0 1px 2px rgba(20, 30, 40, .07);
  --shadow-lg: 0 24px 60px -16px rgba(20, 30, 40, .32);

  /* ink */
  --text: #14181d;
  --muted: #5d6771;
  --faint: rgba(20, 30, 40, .08);

  /* accent: jade, cool against the warm board */
  --accent: #0d7d68;
  --accent-2: #10a184;
  --accent-ink: #ffffff;
  --accent-soft: rgba(13, 125, 104, .12);
  --danger: #c0392f;
  --away: #c9a227;

  --r-xl: 26px;
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c0f13;
    --bg-a: #10302b;
    --bg-b: #2a2119;
    --bg-c: #131a26;
    --glass: rgba(30, 35, 43, .55);
    --glass-strong: rgba(34, 40, 49, .78);
    --glass-brd: rgba(255, 255, 255, .10);
    --glass-edge: rgba(255, 255, 255, .16);
    --glass-ring: rgba(0, 0, 0, .5);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 36px -10px rgba(0, 0, 0, .7);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .45);
    --shadow-lg: 0 28px 70px -18px rgba(0, 0, 0, .85);
    --text: #e8ecf1;
    --muted: #949fac;
    --faint: rgba(255, 255, 255, .09);
    --accent: #15806a;
    --accent-2: #23b393;
    --accent-ink: #04140f;
    --accent-soft: rgba(46, 195, 159, .16);
    --danger: #ef7a6e;
    --away: #d9a63a;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0f13;
  --bg-a: #10302b;
  --bg-b: #2a2119;
  --bg-c: #131a26;
  --glass: rgba(30, 35, 43, .55);
  --glass-strong: rgba(34, 40, 49, .78);
  --glass-brd: rgba(255, 255, 255, .10);
  --glass-edge: rgba(255, 255, 255, .16);
  --glass-ring: rgba(0, 0, 0, .5);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 36px -10px rgba(0, 0, 0, .7);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .45);
  --shadow-lg: 0 28px 70px -18px rgba(0, 0, 0, .85);
  --text: #e8ecf1;
  --muted: #949fac;
  --faint: rgba(255, 255, 255, .09);
  --accent: #15806a;
  --accent-2: #23b393;
  --accent-ink: #04140f;
  --accent-soft: rgba(46, 195, 159, .16);
  --danger: #ef7a6e;
  --away: #d9a63a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  font: 15.5px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  letter-spacing: -.005em;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* The ground: three slow washes of colour, fixed so scrolling glides over it. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(70vw 62vw at 8% -10%, var(--bg-a), transparent 62%),
    radial-gradient(62vw 56vw at 96% 4%, var(--bg-b), transparent 60%),
    radial-gradient(80vw 70vw at 46% 106%, var(--bg-c), transparent 66%),
    var(--bg);
}
/* A film of grain, so the large gradients never band. */
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: .22; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}

/* Where the backdrop cannot be blurred, fall back to an opaque panel rather
   than a washed-out translucent one. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass: rgba(255, 255, 255, .92); --glass-strong: rgba(255, 255, 255, .97); }
  :root[data-theme="dark"] { --glass: rgba(28, 33, 40, .96); --glass-strong: rgba(34, 40, 49, .98); }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --glass: rgba(28, 33, 40, .96); --glass-strong: rgba(34, 40, 49, .98); }
  }
}

/* ------------------------------------------------------------------ chrome */

.topbar {
  display: flex; align-items: center; gap: 6px;
  padding: 10px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  position: sticky; top: 0; z-index: 20;
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--glass-brd);
  box-shadow: inset 0 1px 0 var(--glass-edge), 0 8px 24px -18px rgba(0, 0, 0, .5);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; box-shadow: none;
  padding: 4px 8px 4px 4px;
  color: var(--text); font-size: 17px; font-weight: 640; letter-spacing: -.02em;
  border-radius: var(--r-md); cursor: pointer; min-width: 0;
}
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  flex: none;
  background: linear-gradient(145deg, var(--accent-2), var(--accent));
  box-shadow: 0 2px 10px -3px var(--accent), inset 0 1px 0 rgba(255, 255, 255, .45);
  color: #fff; transition: transform .18s ease;
}
.brand .mark svg { width: 18px; height: 18px; }
.brand:hover .mark { transform: translateY(-1px); }
.brand .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The way back: Spieltisch › Tisch. One place, never lost. */
.crumbs {
  display: flex; align-items: center; gap: 7px; margin-right: auto;
  color: var(--muted); font-size: 13.5px; min-width: 0;
}
.crumbs .sep { opacity: .5; flex: none; }
.crumbs b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) { .crumbs { display: none; } }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0; flex: none;
  color: var(--muted); cursor: pointer;
  background: transparent; border: 1px solid transparent; border-radius: 50%;
  box-shadow: none;
  transition: background .18s, color .18s, border-color .18s;
}
.iconbtn:hover { background: var(--glass-strong); color: var(--text); border-color: var(--glass-brd); box-shadow: var(--shadow-sm); }
.iconbtn.on {
  color: var(--accent); background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
.iconbtn svg { width: 19px; height: 19px; }
.spacer { margin-right: auto; }

.conn {
  width: 7px; height: 7px; border-radius: 50%; flex: none; margin: 0 4px 0 2px;
  background: var(--faint); transition: background .3s, box-shadow .3s;
}
.conn.live { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.conn.down { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }

.view {
  padding: 22px max(14px, env(safe-area-inset-left)) calc(28px + env(safe-area-inset-bottom));
  max-width: 1180px; margin: 0 auto; width: 100%; flex: 1;
}

/* ------------------------------------------------------------------- cards */

.card {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-brd);
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-edge);
  border-radius: var(--r-xl);
  padding: 20px; margin: 0 0 16px;
}
.card.compact { padding: 14px; border-radius: var(--r-lg); }
.card h1 { font-size: 16.5px; font-weight: 650; letter-spacing: -.02em; margin: 0 0 16px; }
.card h2 {
  font-size: 11px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 10px;
}
.hint { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 13px 0 0; }
.credit { color: var(--muted); font-size: 11.5px; text-align: center; margin: 26px 0 0; opacity: .8; }

.field { display: block; margin-bottom: 15px; }
.field > span { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); margin-bottom: 7px; }
input[type=text] {
  width: 100%; padding: 12px 14px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--glass-strong); border: 1px solid var(--glass-brd);
  border-radius: var(--r-md); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .04);
  transition: border-color .18s, box-shadow .18s;
}
input[type=text]::placeholder { color: color-mix(in srgb, var(--muted) 65%, transparent); }
input[type=text]:focus {
  outline: none; border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
input.code { text-transform: uppercase; letter-spacing: .16em; font-weight: 600; }

button {
  font: inherit; font-size: 14.5px; font-weight: 550; color: var(--text);
  background: var(--glass-strong); border: 1px solid var(--glass-brd);
  border-radius: 999px; padding: 11px 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-edge);
  touch-action: manipulation;
  transition: transform .1s ease, box-shadow .18s, background .18s, color .18s;
}
button:hover:not(:disabled) { box-shadow: var(--shadow), inset 0 1px 0 var(--glass-edge); }
button:active:not(:disabled) { transform: scale(.975); }
button:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }
button.primary {
  width: 100%; padding: 13px 18px; font-weight: 620; letter-spacing: -.01em;
  color: var(--accent-ink); border-color: transparent;
  background: linear-gradient(160deg, var(--accent-2), var(--accent));
  box-shadow: 0 4px 14px -8px var(--accent), inset 0 1px 0 rgba(255, 255, 255, .28);
}
button.primary:hover:not(:disabled) { box-shadow: 0 8px 22px -8px var(--accent), inset 0 1px 0 rgba(255, 255, 255, .38); }
button.sm { padding: 7px 13px; font-size: 13px; }
button.danger { color: var(--danger); }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.row { display: flex; gap: 8px; }
.row + .row { margin-top: 8px; }

/* ------------------------------------------------------------------- lobby */

.grid-lobby { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid-lobby { grid-template-columns: minmax(0, 1fr); } }

.hello { font-size: 26px; font-weight: 660; letter-spacing: -.025em; margin: 2px 0 4px; }
.hello + p { color: var(--muted); margin: 0 0 18px; font-size: 14.5px; }

/* The two doors. Equal in size, so neither reads as the detour. */
.doors { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 620px) { .doors { grid-template-columns: 1fr; } }
.door {
  background: var(--glass-strong); border: 1px solid var(--glass-brd); border-radius: var(--r-lg);
  padding: 18px; box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-edge);
  display: flex; flex-direction: column; gap: 10px;
}
.door h3 { margin: 0; font-size: 15px; font-weight: 640; letter-spacing: -.015em; }
.door p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; flex: 1; }
.door .joinrow { display: flex; gap: 8px; }
.door .joinrow input { flex: 1; min-width: 0; }
.door .joinrow button { flex: none; }

/* Game tiles -- every new game lands here and nothing else on the page moves.
   display:block is load-bearing: the tile is a <button> and would otherwise
   inherit the centred inline-flex of every other button, putting symbol, name
   and blurb side by side instead of stacked. */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  display: block; text-align: left;
  border: 1px solid var(--glass-brd); background: var(--glass-strong);
  border-radius: var(--r-lg); padding: 16px; cursor: pointer;
  box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-edge);
}
.tile .em { display: block; font-size: 26px; line-height: 1; margin-bottom: 9px; }
.tile b { display: block; font-size: 14.5px; font-weight: 640; letter-spacing: -.015em; }
.tile .d { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.45; }
.tile.soon { opacity: .58; cursor: default; }
.tile.soon:hover { box-shadow: var(--shadow-sm), inset 0 1px 0 var(--glass-edge); }

.rooms { list-style: none; margin: 0; padding: 0; }
.rooms li {
  display: flex; align-items: center; gap: 12px; padding: 11px 10px;
  border-radius: var(--r-md); cursor: pointer; transition: background .15s;
}
.rooms li:hover { background: var(--faint); }
.rooms .gicon {
  width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: var(--faint); font-size: 15px; font-weight: 680; letter-spacing: .02em;
}
.rooms .gmain { display: block; flex: 1; min-width: 0; }
/* Name above the trimmings, not beside them: in a narrow column the most
   important part would otherwise be the first thing cut off. */
.rooms .gname { display: block; font-weight: 580; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rooms .gmeta { display: block; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rooms .rm {
  width: 30px; height: 30px; padding: 0; flex: none; border-radius: 50%;
  background: transparent; border: 0; box-shadow: none; color: var(--muted);
  opacity: 0; transition: opacity .15s, background .15s, color .15s;
}
.rooms .rm svg { width: 15px; height: 15px; }
.rooms li:hover .rm, .rooms .rm:focus-visible { opacity: 1; }
.rooms .rm:hover { background: var(--faint); color: var(--danger); }
@media (hover: none) { .rooms .rm { opacity: .6; } }

.badge {
  font-size: 11.5px; font-weight: 580; padding: 5px 11px; border-radius: 999px;
  background: var(--faint); color: var(--muted); white-space: nowrap;
}
.badge.turn {
  background: linear-gradient(160deg, var(--accent-2), var(--accent));
  color: var(--accent-ink); box-shadow: 0 4px 12px -4px var(--accent);
}

/* ------------------------------------------------------------------- table */

.grid-tisch { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid-tisch { grid-template-columns: minmax(0, 1fr); } }

.tischhead { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; flex-wrap: wrap; }
.tischhead .th-main { flex: 1; min-width: 0; }
.tischhead h1 { margin: 0; font-size: 21px; font-weight: 660; letter-spacing: -.02em; }
.tischhead .code { display: flex; align-items: center; gap: 8px; margin-top: 5px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.tischhead .code b {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px;
  letter-spacing: .16em; color: var(--text); background: var(--faint);
  padding: 3px 9px; border-radius: var(--r-sm);
}

.seats { display: flex; flex-direction: column; gap: 2px; }
.seat { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: var(--r-sm); }
.av {
  width: 30px; height: 30px; border-radius: 10px; flex: none; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 680; color: #fff; box-shadow: var(--shadow-sm);
}
.seat .sname { font-weight: 570; font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--faint); }
.dot.da { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dot.kurz { background: var(--away); box-shadow: 0 0 0 3px color-mix(in srgb, var(--away) 16%, transparent); }

/* Chat -- the table itself. It stays while games come and go. */
.chat { display: flex; flex-direction: column; height: min(600px, calc(100dvh - 210px)); padding: 0; overflow: hidden; }
.chat .log { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 9px; overflow-wrap: anywhere; }
.msg {
  max-width: 74%; padding: 9px 13px; border-radius: 16px; font-size: 14px; line-height: 1.45;
  background: var(--glass-strong); border: 1px solid var(--glass-brd); box-shadow: var(--shadow-sm);
  white-space: pre-wrap;
}
.msg .who { display: block; font-size: 11.5px; font-weight: 640; color: var(--muted); margin-bottom: 2px; }
.msg.me {
  align-self: flex-end;
  background: linear-gradient(160deg, var(--accent-2), var(--accent));
  color: var(--accent-ink); border-color: transparent;
  box-shadow: 0 4px 14px -8px var(--accent);
}
.msg.me .who { display: none; }
.msg .at { display: block; font-size: 10.5px; opacity: .6; margin-top: 3px; }
/* A system line is not a message: narrower, centred, and carrying the door. */
.sys {
  align-self: center; display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; color: var(--muted); background: var(--faint);
  border-radius: 999px; padding: 5px 15px; max-width: 92%; text-align: center;
}
.sys.with-action { padding-right: 7px; }
.sys button { padding: 5px 12px; font-size: 12px; }
.chat .compose {
  display: flex; gap: 8px; padding: 13px 16px;
  border-top: 1px solid var(--glass-brd); background: var(--glass-strong);
}
.chat .compose input { flex: 1; min-width: 0; }
.chat .compose button { flex: none; width: 44px; padding: 0; border-radius: 50%; }
.empty { margin: auto; color: var(--muted); font-size: 13.5px; text-align: center; padding: 20px; }

.launch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* -------------------------------------------------------------------- misc */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 60;
  background: var(--glass-strong); border: 1px solid var(--glass-brd);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: var(--shadow-lg), inset 0 1px 0 var(--glass-edge);
  border-radius: 999px; padding: 11px 20px; font-size: 14px; font-weight: 540;
  max-width: calc(100vw - 32px); text-align: center;
}
.banner {
  margin: 0 0 16px; padding: 12px 16px; border-radius: var(--r-md);
  background: color-mix(in srgb, var(--danger) 10%, var(--glass-strong));
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--text); font-size: 13.5px;
}

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