/* Alle kleuren staan hier als variabele, zodat de donkere modus verderop met
   één blok overrides klaar is. `data-theme` op <html> bepaalt welke set geldt;
   een klein script in de <head> zet dat vóór de eerste opmaak (licht, donker of
   de voorkeur van het toestel). */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --ink: #152334;
  --muted: #637184;
  --navy: #163a5f;
  --navy-2: #0f2c49;
  /* Marineblauwe tekst óp een licht vlak: in de donkere modus moet die juist
     licht worden, terwijl --navy als achtergrondkleur donker blijft. */
  --navy-ink: #163a5f;
  --blue: #2a72c7;
  --blue-hover: #1d62ad;
  --blue-soft: #dcecff;
  --orange: #ed8a22;
  --orange-dark: #c96608;
  --paper: #ffffff;
  --card: rgba(255, 255, 255, .96);
  --card-line: rgba(215, 224, 234, .9);
  --page: #edf2f7;
  --page-glow: #d9e9fb;
  --line: #d7e0ea;
  --good: #177245;
  --bad: #b32727;
  --shadow: 0 16px 45px rgba(19, 45, 72, 0.13);
  --overlay-bg: rgba(9, 25, 42, .68);

  /* Rustige vlakken: lijstregels, uitleg, inklapblokken */
  --surface: #f6f9fc;
  --surface-hover: #eef5fd;
  --info-bg: #eef5fc;
  --dash: #9db1c5;
  --bar-bg: #e7eef6;

  /* Knoppen, tabs en chips */
  --chip: #e6eef7;
  --chip-hover: #d3e3f5;
  --tab-active: #eaf2fb;
  --toolbar-btn: #e9f0f7;
  --code-chip: #dce9f7;

  /* Velden */
  --input-bg: #ffffff;
  --input-line: #b9c6d4;
  --field-label: #3d4b5d;

  /* Meldingen en badges */
  --warm-bg: #fff3d9;
  --warm-ink: #7a4a00;
  --badge-bg: #eef3f8;
  --badge-ink: #435369;
  --good-bg: #dff5e9;
  --good-ink: #14623c;
  --medium-bg: #fff0cc;
  --bad-bg: #ffe1e1;
  --bad-bg-hover: #f8dcdc;
  --bad-line: #eec5c5;
  --bad-ink: #8b2020;

  /* Het puzzelraster */
  --cell-bg: #ffffff;
  --cell-ink: #111111;
  --grid-line: #222222;
  --block-bg: #17202a;
  --word-bg: #d8eaff;
  --cross-bg: #edf5ff;
  --active-bg: #ffd58d;
  --active-line: #d36f08;
  --incorrect-bg: #ffdede;
  --draft-ink: #a8b2bd;
  --circle-line: #555555;
  --viewport-bg: #c7d0d9;
  --viewport-line: #9fadb9;
  --clue-block-bg: #b8c2cc;
  --clue-tile-bg: #f4f1ea;
  --clue-tile-ink: #1d2735;
  /* Het aangewezen omschrijvingsvakje: oranje zoals het actieve woord. De tekst
     erop heeft een eigen variabele, want de oranje tint verschilt per modus. */
  --clue-tile-active-bg: #ffd58d;
  --clue-tile-active-ink: #1d2735;
  --clue-bar: #eef4fa;
  --clue-item-ink: #344256;
  --clue-item-active-ink: #112b49;

  --cell-size: 44px;
  --keyboard-height: 0px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Donkere modus. Het raster blijft een raster: de lettervakjes worden een
   donkere tint in plaats van wit, de blokjes bijna zwart, en het actieve woord
   houdt dezelfde blauwe/oranje betekenis als in het licht. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e6edf5;
  --muted: #9aa9bb;
  --navy: #14293f;
  --navy-2: #0c1c2c;
  --navy-ink: #a8ccf2;
  --blue: #3b86dc;
  --blue-hover: #4b93e6;
  --blue-soft: #1e3a55;
  --orange: #f0a03a;
  --orange-dark: #ffb45c;
  --paper: #131c27;
  --card: rgba(20, 29, 40, .96);
  --card-line: rgba(70, 87, 106, .6);
  --page: #0d141c;
  --page-glow: #16304a;
  --line: #2d3a49;
  --good: #4cc38a;
  --bad: #f47272;
  --shadow: 0 16px 45px rgba(0, 0, 0, 0.45);
  --overlay-bg: rgba(4, 9, 15, .74);

  --surface: #182230;
  --surface-hover: #1f2c3c;
  --info-bg: #172634;
  --dash: #46586c;
  --bar-bg: #22303f;

  --chip: #22303f;
  --chip-hover: #2c3d50;
  --tab-active: #1d2b3a;
  --toolbar-btn: #22303f;
  --code-chip: #24384d;

  --input-bg: #101922;
  --input-line: #3a4b5e;
  --field-label: #b3c1d1;

  --warm-bg: #3a2c12;
  --warm-ink: #f5cd88;
  --badge-bg: #22303f;
  --badge-ink: #b3c1d1;
  --good-bg: #123527;
  --good-ink: #79dba8;
  --medium-bg: #3a2f12;
  --bad-bg: #3a1a1a;
  --bad-bg-hover: #4a2020;
  --bad-line: #5e2a2a;
  --bad-ink: #ff9d9d;

  --cell-bg: #1c2836;
  --cell-ink: #f2f6fb;
  --grid-line: #4b5d72;
  --block-bg: #070b10;
  --word-bg: #204669;
  --cross-bg: #172f45;
  --active-bg: #a9701a;
  --active-line: #ffc061;
  --incorrect-bg: #4a1f1f;
  --draft-ink: #7b8a9a;
  --circle-line: #93a3b4;
  --viewport-bg: #0a1017;
  --viewport-line: #2d3a49;
  /* De omschrijvingen in de zwarte vakjes stonden hier op licht beige: dat is de
     papierkleur uit de lichte modus en die schreeuwt in het donker. Nu een
     donkere leisteentint met lichte tekst, iets lichter dan het randje eromheen
     — dezelfde verhouding als in de lichte modus, waar de tegel ook lichter is
     dan het kader. */
  --clue-block-bg: #202b38;
  --clue-tile-bg: #33455c;
  --clue-tile-ink: #e8eef7;
  --clue-tile-active-bg: #d9922a;
  --clue-tile-active-ink: #1a1206;
  --clue-bar: #18242f;
  --clue-item-ink: #c3cfdd;
  --clue-item-active-ink: #eaf3ff;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); }
body { margin: 0; min-height: 100vh; min-height: 100dvh; color: var(--ink); background: radial-gradient(circle at top right, var(--page-glow) 0, transparent 34rem), var(--page); }
button, input, select { font: inherit; }
button { touch-action: manipulation; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 64px;
  padding: 10px max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--navy-2), var(--navy));
  box-shadow: 0 5px 24px rgba(9, 34, 57, 0.22);
}

.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; font-size: 18px; }
.brand-grid { display: grid; grid-template-columns: repeat(2, 16px); gap: 2px; }
.brand-grid i { width: 16px; height: 16px; display: grid; place-items: center; border-radius: 2px; background: #fff; color: var(--navy); font-size: 8px; font-style: normal; font-weight: 800; }
.version-badge { padding: 3px 8px; border: 1px solid rgba(255,255,255,.28); border-radius: 999px; font-size: 11px; font-weight: 650; color: rgba(255,255,255,.72); }
.connection { padding: 6px 9px; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; font-size: 12px; color: rgba(255,255,255,.78); }
.connection.online { color: #d8ffe8; border-color: #7bd5a5; }

main { width: min(1280px, 100%); margin: 0 auto; padding: 24px max(14px, env(safe-area-inset-left)) 48px; padding-right: max(14px, env(safe-area-inset-right)); }
.screen { min-height: calc(100dvh - 110px); }
.hero { max-width: 790px; padding: 26px 4px 20px; }
.eyebrow { margin: 0 0 7px; color: var(--orange-dark); text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 800; }
.hero h1 { margin: 0; font-size: clamp(32px, 7vw, 58px); line-height: 1.04; letter-spacing: -.035em; }
.hero p:last-child { max-width: 680px; margin: 16px 0 0; color: var(--muted); font-size: clamp(16px, 2.3vw, 20px); line-height: 1.55; }

.card { background: var(--card); border: 1px solid var(--card-line); border-radius: 18px; box-shadow: var(--shadow); }
.lobby-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; max-width: 900px; }
.lobby-grid .card { padding: 24px; }
.name-card { max-width: 900px; margin-bottom: 18px; padding: 18px 24px; }
.name-card .field { margin-bottom: 0; }

/* Account en "Mijn puzzels": twee blokken in de lobby, even breed als de
   naamkaart en het aanmaakblok erboven. */
.account-card, .mine-card { max-width: 900px; margin-bottom: 18px; padding: 18px 24px; }
.mine-card { margin-top: 18px; margin-bottom: 0; }
.account-card h2, .mine-card h2 { margin: 0 0 6px; font-size: 20px; }
/* Eigen puzzels en de kamers waar je aan meedoet: onder het accountblok. */
.mine-block { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.mine-block h3 { margin: 0; font-size: 17px; }
.joined-head { margin-top: 16px; }
.account-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.account-note { margin: 0; max-width: 560px; font-size: 13px; line-height: 1.45; }
.mine-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mine-list { display: grid; gap: 10px; margin-top: 12px; font-size: 14px; }
.mine-item {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.mine-info { display: grid; gap: 3px; min-width: 0; }
.mine-info span { font-size: 12.5px; }
.mine-retention { margin-top: 6px; font-size: 12.5px; }
/* Wanneer deze puzzel automatisch wordt opgeruimd. */
.mine-expiry { color: var(--orange-dark); font-weight: 650; }
.mine-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; }
.mine-actions { display: flex; gap: 8px; }
.mine-actions .button { min-height: 40px; padding: 7px 13px; font-size: 13px; }
.account-modal, .guest-modal { width: min(460px, 100%); }
/* Accountinstellingen: foto (kiezen of maken), naam, e-mailadres, wachtwoord. */
.profile-modal { width: min(560px, 100%); }
.profile-modal .settings-section:first-child { border-top: 0; padding-top: 0; }
.profile-photo-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.profile-photo-row .avatar-actions { margin-top: 0; }
.profile-status:empty { display: none; }
.profile-status { margin-top: 8px; font-size: 13px; }
.camera-box { display: grid; gap: 10px; margin-top: 12px; }
.camera-video {
  width: 100%; max-width: 320px; aspect-ratio: 1; object-fit: cover;
  border: 1px solid var(--line); border-radius: 14px; background: var(--block-bg);
}
/* Feedback sturen: soort bericht, het bericht zelf en je eerdere berichten. */
.feedback-modal { width: min(560px, 100%); }
.feedback-count:empty { display: none; }
.feedback-count { margin: -6px 0 10px; font-size: 12.5px; }
.feedback-history { display: grid; gap: 10px; }
.feedback-item { padding: 9px 11px; border-radius: 10px; background: var(--chip); }
.feedback-item-head { display: block; font-size: 12px; font-weight: 750; color: var(--field-label); }
.feedback-item-text { margin: 4px 0 0; font-size: 13px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
/* De camera aan jouw kant van het toestel spiegelt, zoals een spiegel: beweeg je
   naar links, dan beweegt het beeld mee naar links. Alleen het live beeld — de
   foto zelf wordt van het onbewerkte beeldje gemaakt en staat dus goed. Bij de
   camera aan de achterkant zou spiegelen juist verkeerd zijn. */
.camera-video.mirrored { transform: scaleX(-1); }
/* Keuzescherm vóór het beginnen: account of als gast met alleen een naam. */
.guest-modal .field { margin-bottom: 4px; }
.guest-modal #guest-continue { margin-top: 2px; }
.guest-modal .settings-actions .button { flex: 1; }
.account-modal .field { margin-bottom: 0; }
.account-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.account-links .link-button { padding: 4px 0; text-align: left; font-size: 13px; }
/* Melding bij een nog niet bevestigd e-mailadres. */
.account-warning { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: var(--warm-bg); color: var(--warm-ink); }
.account-warning .link-button { padding: 0 2px; color: var(--orange-dark); font-size: inherit; }

.public-rooms { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.public-rooms h3 { margin: 0 0 10px; font-size: 15px; }
.public-rooms-list { display: grid; gap: 8px; font-size: 14px; }
.public-room {
  display: grid; gap: 2px; padding: 10px 12px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.public-room:hover { border-color: var(--blue); background: var(--surface-hover); }
.public-room span { font-size: 12.5px; }
.browse-link { margin-top: 10px; }

/* Zoekpagina met openbare kamers (/kamers) */
.browse-screen { display: grid; gap: 16px; max-width: 1080px; }
.browse-head { padding: 20px 4px 0; }
.browse-head h1 { margin: 10px 0 8px; font-size: clamp(26px, 4.5vw, 40px); letter-spacing: -.02em; }
.browse-head p { max-width: 720px; margin: 0; font-size: 15px; line-height: 1.55; }
.browse-filters { padding: 18px 20px; }
.browse-grid {
  display: grid; gap: 10px; align-items: end;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.browse-grid .field { margin: 0; min-width: 0; }
.browse-text { grid-column: span 2; }
.browse-button { min-height: 44px; }
.browse-filters .library-line { margin-bottom: 0; }
.browse-name-card { max-width: none; margin: 0; padding: 14px 20px; }
.browse-more { margin: 12px 0 0; }
.browse-more .browse-grid { padding: 12px 14px; }
.browse-more .field { margin: 0; }

.room-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.room-card { display: grid; gap: 10px; padding: 16px; text-align: left; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: var(--shadow); }
.room-card-head { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; }
.room-card-head h3 { margin: 0; font-size: 18px; }
.room-card-code { padding: 3px 8px; border-radius: 8px; background: var(--blue-soft); color: var(--navy-ink); font-size: 12px; font-weight: 800; letter-spacing: .08em; white-space: nowrap; }
.room-card p { margin: 0; font-size: 13px; line-height: 1.45; }
.room-progress { display: grid; gap: 5px; }
.room-progress-bar { height: 8px; border-radius: 999px; background: var(--bar-bg); overflow: hidden; }
.room-progress-bar span { display: block; height: 100%; border-radius: 999px; background: var(--orange); }
.room-progress-bar span.done { background: var(--good); }
.room-progress-text, .room-presence { font-size: 12.5px; }
.badge.full { color: var(--bad-ink); background: var(--bad-bg); }
h1, h2, h3 { text-wrap: balance; }
.card h2 { margin: 0 0 18px; font-size: 23px; }

.field { display: grid; gap: 7px; margin-bottom: 15px; }
.field > span { color: var(--field-label); font-size: 13px; font-weight: 750; }
.field input, .field select, .field textarea, .room-code-input {
  width: 100%; min-height: 48px; padding: 10px 13px; border: 1px solid var(--input-line); border-radius: 10px; background: var(--input-bg); color: var(--ink); font-size: 16px; outline: none;
}
.field textarea { min-height: 120px; font-family: inherit; line-height: 1.45; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .room-code-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(42,114,199,.14); }
.room-code-input { text-transform: uppercase; letter-spacing: .16em; font-weight: 800; }
.compact-field { max-width: 260px; margin-top: 15px; }

.button, .icon-button, .code-button, .link-button, .tab, .crossword-toolbar button {
  border: 0; border-radius: 10px; cursor: pointer; font-weight: 760; transition: transform .12s ease, background .12s ease, opacity .12s ease;
}
.button { min-height: 46px; padding: 10px 16px; }
.button:active, .icon-button:active, .crossword-toolbar button:active { transform: translateY(1px); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button.wide { width: 100%; }
.button.primary { color: #fff; background: var(--blue); }
.button.primary:hover { background: var(--blue-hover); }
.button.accent { color: #fff; background: var(--orange); }
.button.accent:hover { background: var(--orange-dark); }
.button.secondary { color: var(--navy-ink); background: var(--chip); }
.button.ghost { color: var(--muted); background: transparent; border: 1px solid var(--line); }
.button.danger { color: #fff; background: var(--bad); }
.selected-summary { margin: 13px 0; min-height: 24px; line-height: 1.45; }
.notice { min-height: 22px; margin: 12px 0 0; font-size: 14px; }
.notice.error { color: var(--bad); }
.notice.success { color: var(--good); }

.overlay {
  position: fixed; inset: 0; z-index: 100; padding: max(12px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  display: grid; place-items: center; background: var(--overlay-bg); backdrop-filter: blur(4px); overflow: auto;
}
.modal { width: min(980px, 100%); max-height: calc(100dvh - 24px); display: flex; flex-direction: column; overflow: hidden; border-radius: 20px; background: var(--paper); box-shadow: 0 24px 80px rgba(0,0,0,.28); }
.modal-header, .modal-footer { flex: none; padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; }
.modal-footer { border-top: 1px solid var(--line); border-bottom: 0; }
.icon-button { width: 44px; height: 44px; flex: none; display: grid; place-items: center; color: var(--ink); background: var(--chip); font-size: 28px; }
.tabs { display: flex; gap: 4px; padding: 9px 14px 0; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tab { min-height: 42px; padding: 8px 14px; white-space: nowrap; color: var(--muted); background: transparent; border-radius: 9px 9px 0 0; }
.tab.active { color: var(--navy-ink); background: var(--tab-active); }
.tab-panel { flex: 1; min-height: 0; padding: 18px; overflow: auto; }
.search-grid { display: grid; grid-template-columns: minmax(220px, 2fr) minmax(145px, 1fr) minmax(145px, 1fr) auto; gap: 10px; align-items: end; }
.search-grid .field { margin: 0; }
.search-button { min-width: 105px; }
.library-line { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin: 14px 0 10px; font-size: 13px; }
.link-button { padding: 6px; background: transparent; color: var(--blue); }
.puzzle-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.puzzle-card { display: grid; gap: 10px; padding: 15px; text-align: left; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.puzzle-card.selected { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(237,138,34,.15); }
.puzzle-card h3 { margin: 0; font-size: 18px; }
.puzzle-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.puzzle-card-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 8px; border-radius: 999px; background: var(--badge-bg); color: var(--badge-ink); font-size: 11px; font-weight: 760; }
.badge.easy { color: var(--good-ink); background: var(--good-bg); }
.badge.medium { color: var(--warm-ink); background: var(--medium-bg); }
.badge.hard { color: var(--bad-ink); background: var(--bad-bg); }
.puzzle-card-actions { display: flex; gap: 8px; }
.puzzle-card-actions .button { flex: 1; min-height: 40px; padding: 7px 10px; font-size: 13px; }
.empty-results { padding: 28px; grid-column: 1 / -1; text-align: center; color: var(--muted); border: 1px dashed var(--dash); border-radius: 14px; }
.generate-grid { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.generate-grid .field { margin: 0; }
.generate-button { min-height: 46px; }
.import-explanation { margin-bottom: 18px; padding: 14px; border-radius: 12px; background: var(--info-bg); }
.import-explanation h3 { margin: 0 0 6px; }
.import-explanation p { margin: 0; color: var(--muted); line-height: 1.5; }
.file-drop { min-height: 110px; display: grid; place-items: center; padding: 20px; border: 2px dashed var(--dash); border-radius: 14px; text-align: center; background: var(--surface); cursor: pointer; }
.file-drop input { position: absolute; opacity: 0; pointer-events: none; }
.file-drop small { color: var(--muted); }
.check-row { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0 14px; }

.game-screen { padding-top: 8px; }
.game-head { padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.game-head h1 { margin: 0; font-size: clamp(23px, 4vw, 34px); }
.code-button { padding: 3px 8px; color: var(--navy-ink); background: var(--code-chip); letter-spacing: .12em; }
/* Uitklapbare spelerslijst boven de puzzel: de samenvatting staat altijd in
   beeld, de namen (met foto's en kleuren) klap je open. */
.players-details { margin: 12px 5px; color: var(--muted); font-size: 14px; }
.players-details summary {
  display: flex; align-items: center; gap: 6px; width: fit-content;
  padding: 4px 2px; border-radius: 8px; cursor: pointer; list-style: none;
}
.players-details summary::-webkit-details-marker { display: none; }
/* Eigen pijltje, zodat het driehoekje ook op iOS meedraait. */
.players-details summary::after {
  content: '▾'; font-size: 12px; transition: transform .15s ease;
}
.players-details[open] summary::after { transform: rotate(180deg); }
.players-details summary:hover .players-count { color: var(--ink); }
.players { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.players-count { font-weight: 700; }
.player-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink); font-size: 13px;
}
.player-chip.offline { opacity: .55; }
.player-color { width: 11px; height: 11px; flex: none; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); }
.make-owner { margin-left: 2px; padding: 2px 8px; border: 0; border-radius: 999px; background: var(--chip); color: var(--navy-ink); font-size: 11.5px; font-weight: 750; cursor: pointer; }
.make-owner:hover { background: var(--chip-hover); }
.kick-player { padding: 2px 8px; border: 1px solid var(--bad-line); border-radius: 999px; background: var(--bad-bg); color: var(--bad-ink); font-size: 11.5px; font-weight: 750; cursor: pointer; }
.kick-player:hover { background: var(--bad-bg-hover); }
.room-name-head { color: var(--orange-dark); font-weight: 800; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(310px, .65fr); gap: 16px; align-items: start; }
.puzzle-panel, .clues-panel { padding: 14px; }

/* top: 64px zodat de balk onder de sticky site-header blijft plakken en de
   knoppen aanklikbaar blijven tijdens het scrollen. */
.crossword-toolbar { position: sticky; top: 64px; z-index: 20; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; padding: 5px 0 10px; background: var(--paper); }
.crossword-toolbar button { min-width: 44px; min-height: 42px; padding: 7px 11px; color: var(--navy-ink); background: var(--toolbar-btn); font-size: 14px; }
.crossword-toolbar output { min-width: 55px; text-align: center; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.crossword-viewport {
  position: relative; width: 100%; height: min(63vh, 720px); min-height: 330px; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--viewport-line); border-radius: 12px; background: var(--viewport-bg); touch-action: none; cursor: grab;
}
.crossword-viewport.dragging { cursor: grabbing; }
.crossword-canvas { position: relative; min-width: 100%; min-height: 100%; }
.crossword-grid { position: absolute; top: 0; left: 0; display: grid; transform-origin: top left; user-select: none; -webkit-user-select: none; border-top: 1px solid var(--grid-line); border-left: 1px solid var(--grid-line); }
.crossword-cell {
  position: relative; width: var(--cell-size); height: var(--cell-size); padding: 0; display: grid; place-items: center; box-sizing: border-box;
  border: 0; border-right: 1px solid var(--grid-line); border-bottom: 1px solid var(--grid-line); border-radius: 0; color: var(--cell-ink); background: var(--cell-bg); font-size: 23px; font-weight: 780; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.crossword-cell.block { background: var(--block-bg); cursor: default; }
.crossword-cell.block.hidden-cell { border-color: transparent; background: transparent; visibility: hidden; }
.crossword-cell.in-active-word { background: var(--word-bg); }
.crossword-cell.crossing-active-word { background: var(--cross-bg); }
.crossword-cell.active { background: var(--active-bg); outline: 3px solid var(--active-line); outline-offset: -3px; z-index: 3; }
.crossword-cell.incorrect { background: var(--incorrect-bg); color: var(--bad); }
.crossword-cell-number { position: absolute; top: 2px; left: 3px; font-size: 9px; line-height: 1; font-weight: 650; }
.crossword-cell-letter { line-height: 1; }
.crossword-cell.circle::after { content: ''; position: absolute; inset: 5px; border: 1.5px solid var(--circle-line); border-radius: 50%; pointer-events: none; }

/* Potloodletters: lichtgrijs, tellen niet mee als echte invulling. */
.crossword-cell.draft .crossword-cell-letter { color: var(--draft-ink); font-weight: 650; }

/* Klein kleurbolletje rechtsboven: wie vulde deze letter in? Alleen
   zichtbaar wanneer de speler dit aan heeft staan (#game.show-owners). */
.cell-owner-dot { display: none; position: absolute; top: 2px; right: 2px; width: 7px; height: 7px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.3); pointer-events: none; z-index: 2; }
#game.show-owners .cell-owner-dot.visible { display: block; }

/* Ping: het vakje licht 10 seconden op voor iedereen. */
@keyframes ping-pulse {
  0% { box-shadow: inset 0 0 0 3px #d32f9b, 0 0 0 0 rgba(211, 47, 155, .55); }
  70% { box-shadow: inset 0 0 0 3px #d32f9b, 0 0 0 9px rgba(211, 47, 155, 0); }
  100% { box-shadow: inset 0 0 0 3px #d32f9b, 0 0 0 0 rgba(211, 47, 155, 0); }
}
.crossword-cell.pinged { z-index: 4; animation: ping-pulse 1.25s ease-out 8; box-shadow: inset 0 0 0 3px #d32f9b; }

/* Zweedse weergave: omschrijvingen in de (zwarte) vakjes, zoals in
   puzzelboekjes. Buiten deze modus blijven de omschrijvingen verborgen.
   De klasse .swedish-grid staat op het raster zelf, zodat zowel het spel als
   het puzzelvoorbeeld dezelfde weergave gebruiken. */
.crossword-cell.block .cell-clue, .crossword-cell.block .cell-clue-arrow { display: none; }
#game.swedish .clues-panel { display: none; }
#game.swedish .game-layout { grid-template-columns: minmax(0, 1fr); }
.swedish-grid .crossword-cell-number { display: none; }
.swedish-grid .crossword-cell.block.clue-block { position: relative; display: flex; flex-direction: column; gap: 1px; padding: 1px; background: var(--clue-block-bg); cursor: default; }
.swedish-grid .clue-block .cell-clue {
  display: flex; flex: 1 1 0; min-height: 0; min-width: 0; align-items: center; justify-content: center;
  margin: 0; padding: 0.5px 1px; border: 0; border-radius: 1px; overflow: hidden;
  background: var(--clue-tile-bg); color: var(--clue-tile-ink); font-size: 5.5px; line-height: 1.05; font-weight: 680;
  text-transform: uppercase; text-align: center; overflow-wrap: anywhere; hyphens: auto; cursor: pointer;
}
.swedish-grid .clue-block .cell-clue.active { background: var(--clue-tile-active-bg); color: var(--clue-tile-active-ink); }
/* max-height + overflow hidden: te lange tekst wordt onderaan afgekapt in
   plaats van buiten het vakje door te lopen. */
.swedish-grid .clue-block .cell-clue-text { min-width: 0; max-height: 100%; overflow: hidden; }
.swedish-grid .clue-block .cell-clue-arrow {
  display: block; position: absolute; z-index: 2; font-size: 17.5px; line-height: 1; font-weight: 800;
  color: var(--cell-ink); pointer-events: none;
}
/* Volledig buiten het omschrijvingsvakje, in het antwoordvakje ernaast/eronder,
   strak tegen het lijntje aan (de -4px compenseert de witruimte in het
   pijlteken zelf). */
.swedish-grid .clue-block .cell-clue-arrow.edge-right { left: 100%; transform: translate(-4px, -50%); }
.swedish-grid .clue-block .cell-clue-arrow.edge-bottom { top: 100%; transform: translate(-50%, -4px); }
/* In het voorbeeld is de tekst alleen om te lezen. */
.preview-grid .clue-block .cell-clue { cursor: default; }

/* Vergrootglas: vinger ingedrukt houden op het speelschema. De loep zweeft
   boven de pagina en laat de vingerbewegingen door naar het raster. */
.magnifier {
  display: none; position: fixed; z-index: 95; overflow: hidden;
  border: 2px solid var(--navy); border-radius: 16px; background: var(--paper);
  box-shadow: 0 14px 44px rgba(9, 25, 42, .38); pointer-events: none;
}
.magnifier.visible { display: block; }
.magnifier-inner { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
/* Het woord onder je vinger licht op in de loep; laat je los, dan wordt dat
   woord geselecteerd. Het vakje zelf is alleen het aanwijspunt. */
.magnifier .lens-word { background: var(--word-bg); }
.magnifier .lens-cell { background: var(--active-bg); outline: 3px solid var(--active-line); outline-offset: -3px; }

/* Typmodus: zolang het toetsenbord open is plakt het speelveld aan de
   bovenkant van het scherm en vult het de ruimte tot 20px boven het
   toetsenbord (hoogte via --typing-viewport-height uit JS). */
#game.typing .puzzle-panel { position: fixed; top: 0; left: 0; right: 0; z-index: 60; margin: 0; padding: 6px; border-radius: 0; }
#game.typing .game-controls, #game.typing #message { display: none; }
/* In typmodus blijven actief woord, ping, potlood en instellingen bruikbaar;
   alleen de zoomknoppen verdwijnen om ruimte te sparen. */
#game.typing .crossword-toolbar { position: static; padding: 2px 0 8px; }
#game.typing #zoom-in, #game.typing #zoom-out, #game.typing #zoom-fit, #game.typing #zoom-label, #game.typing #share-game { display: none; }
#game.typing #open-settings .button-label { display: none; }
#game.typing .crossword-viewport { height: var(--typing-viewport-height, 55dvh); min-height: 200px; }
#game.typing .active-clue { margin-top: 6px; padding-right: 108px; }

/* Chatknopje rechtsonder in de typmodus, met teller voor ongelezen berichten. */
.typing-chat { display: none; }
#game.typing .typing-chat {
  display: inline-flex; align-items: center; gap: 6px;
  position: absolute; right: 8px; bottom: 8px; z-index: 65;
  min-height: 40px; padding: 6px 12px; border: 0; border-radius: 10px;
  background: var(--blue); color: #fff; font-size: 13.5px; font-weight: 750; cursor: pointer;
}
.chat-unread { min-width: 18px; height: 18px; padding: 0 4px; display: grid; place-items: center; border-radius: 999px; background: var(--orange); color: #fff; font-size: 11px; font-weight: 800; }

/* Chat als overlay boven het toetsenbord, geopend via het chatknopje. */
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chat-close { display: none; }
#game.typing.chat-overlay .chat-panel {
  position: fixed; left: 8px; right: 8px;
  bottom: calc(var(--keyboard-height, 0px) + 8px);
  z-index: 90; display: flex; flex-direction: column; max-height: 46dvh;
  box-shadow: 0 18px 60px rgba(9, 25, 42, .4);
}
#game.typing.chat-overlay .chat-messages { flex: 1; max-height: none; }
#game.typing.chat-overlay .chat-close { display: grid; width: 36px; height: 36px; font-size: 22px; }
/* Bewust bovenaan gepind: een input onderaan het scherm laat mobiele browsers
   bij focus de hele pagina naar beneden scrollen om hem boven het toetsenbord
   te tonen. */
.crossword-hidden-input { position: fixed; top: 0; left: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: .01; font-size: 16px; pointer-events: none; }
.active-clue { min-height: 50px; margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--clue-bar); font-size: 14px; line-height: 1.45; }
/* Chatmelding in de balk onderaan: vijf seconden zichtbaar in plaats van de
   uitleg bij het actieve woord (typmodus). */
.active-clue.chat-flash { background: var(--warm-bg); box-shadow: inset 0 0 0 2px var(--orange); cursor: pointer; }
.game-controls { display: flex; gap: 9px; margin-top: 11px; }
.side-column { display: grid; gap: 16px; min-width: 0; align-content: start; }
.clues-panel { display: grid; grid-template-columns: 1fr; gap: 18px; max-height: min(58vh, 700px); overflow: auto; }

/* Chat: berichten met de spelerskleur, invoer onderaan. */
.chat-panel h2 { margin: 0 0 10px; font-size: 18px; }
.chat-messages { display: grid; gap: 6px; align-content: start; max-height: 260px; min-height: 90px; overflow: auto; overscroll-behavior: contain; padding: 4px 2px; }
.chat-empty { margin: 4px 0; font-size: 13px; }
.chat-message { font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.chat-message .player-color { display: inline-block; vertical-align: baseline; margin-right: 5px; }
.chat-message strong { font-weight: 750; }
.chat-message.own strong { color: var(--blue); }
/* Dag en tijd achter het bericht, klein en rustig. */
.chat-moment { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.chat-form { display: flex; gap: 8px; margin-top: 10px; }
.chat-form input { flex: 1; min-width: 0; min-height: 44px; padding: 9px 12px; border: 1px solid var(--input-line); border-radius: 10px; background: var(--input-bg); color: var(--ink); font-size: 15px; outline: none; }
.chat-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(42,114,199,.14); }
.chat-form .button { min-height: 44px; padding: 8px 14px; }
.clue-column h2 { position: sticky; top: -14px; z-index: 2; margin: 0 -4px 8px; padding: 12px 4px 7px; background: var(--paper); font-size: 18px; }
.clue-list { margin: 0; padding-left: 32px; }
.clue-list li { margin-bottom: 3px; padding: 7px 7px 7px 2px; border-radius: 7px; color: var(--clue-item-ink); font-size: 14px; line-height: 1.35; cursor: pointer; }
.clue-list li.active { color: var(--clue-item-active-ink); background: var(--blue-soft); font-weight: 720; }

.settings-modal { width: min(560px, 100%); }
.settings-body { padding: 18px 20px 22px; display: grid; gap: 14px; overflow: auto; }
.setting-row { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.setting-row input { width: 20px; height: 20px; flex: none; margin-top: 2px; accent-color: var(--blue); }
.setting-row small { line-height: 1.4; }
.settings-note { margin: 4px 0 0; font-size: 12.5px; }
.settings-section { border-top: 1px solid var(--line); padding-top: 14px; }
.settings-section h3 { margin: 0 0 6px; font-size: 15px; }
.settings-section-note { margin: 0 0 10px; font-size: 12.5px; line-height: 1.4; }
.settings-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.visibility-row { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px dashed var(--line); }
#host-settings .setting-row { margin-bottom: 4px; }
#host-settings .field { margin: 10px 0; max-width: 320px; }
/* De kamernaam staat bovenaan de eigenaarssectie en mag daar de volle breedte
   gebruiken (de andere velden in die sectie zijn smaller). */
#host-settings .room-name-field { max-width: none; margin-top: 0; }
.room-name-row { display: flex; gap: 8px; }
.room-name-row input { flex: 1; min-width: 0; }
.room-name-row .button { min-height: 44px; padding: 8px 14px; flex: none; }

/* Kamerinstellingen op het aanmaakscherm (inklapbaar). */
.create-settings { margin: 0 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.create-settings summary { padding: 12px 14px; cursor: pointer; font-weight: 750; color: var(--navy-ink); border-radius: 12px; }
.create-settings summary::marker { color: var(--blue); }
.create-settings[open] summary { border-bottom: 1px solid var(--line); }
.create-settings .field, .create-settings .check-row { margin: 12px 14px; }

.chat-disabled-note { margin: 8px 0 0; font-size: 13px; }
.color-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.color-swatch {
  width: 32px; height: 32px; padding: 0; border: 2px solid transparent; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.22);
  cursor: pointer; transition: transform .1s ease;
}
.color-swatch:hover:not(:disabled) { transform: scale(1.12); }
.color-swatch.selected { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--paper); }
.color-swatch:disabled { opacity: .25; cursor: not-allowed; }
/* Aan/uit-knoppen in de werkbalk (potlood) blijven ingedrukt staan zolang de
   modus aan is; de tekst op de knop verandert niet. */
.crossword-toolbar button.toggled-on {
  background: var(--blue); color: #fff;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .38);
  transform: translateY(1px);
}
.badge.solved { color: var(--good-ink); background: var(--good-bg); }

.preview-modal { width: min(740px, 100%); }
.preview-toolbar { padding: 9px 18px; }
.preview-viewport { margin: 0 18px 18px; width: auto; height: min(58vh, 610px); }
.preview-grid .crossword-cell { cursor: default; }

/* Licht/donker-knopje in de kop, naast de verbindingsmelding. */
.header-tools { display: flex; align-items: center; gap: 10px; }
.theme-toggle {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,.35); border-radius: 999px;
  background: rgba(255,255,255,.1); color: #fff; font-size: 17px; cursor: pointer;
}
.theme-toggle:hover { background: rgba(255,255,255,.2); }
.theme-field { max-width: 320px; margin-bottom: 0; }

/* Profielfoto's: een rond bolletje met de foto, of de eerste letter van de naam.
   De rand krijgt de spelerskleur, zodat die betekenis houdt naast de foto. */
.avatar {
  flex: none; display: inline-grid; place-items: center; overflow: hidden;
  border: 2px solid var(--line); border-radius: 50%;
  background: var(--chip); color: var(--navy-ink); font-weight: 800; line-height: 1;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-large { width: 68px; height: 68px; font-size: 27px; }
.avatar-chip { width: 20px; height: 20px; border-width: 1.5px; font-size: 10px; }
.avatar-mini { width: 17px; height: 17px; border-width: 1.5px; font-size: 9px; vertical-align: -3px; margin-right: 5px; }
.account-identity { display: flex; align-items: flex-start; gap: 14px; min-width: 0; }
.avatar-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.avatar-actions .button { min-height: 38px; padding: 6px 12px; font-size: 13px; }
/* Het bestandsveld zit onzichtbaar in de knop "Profielfoto kiezen". */
.avatar-pick { display: inline-flex; align-items: center; cursor: pointer; }
.avatar-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.avatar-status:empty { display: none; }
.avatar-status { margin-top: 6px; font-size: 12.5px; }

@media (max-width: 860px) {
  main { padding-top: 14px; }
  /* minmax(0, …): '1fr' alleen laat de kolom niet smaller krimpen dan de
     inhoud, waardoor het brede puzzelcanvas de hele pagina oprekte en de
     marge rechts van de puzzel verdween. */
  .lobby-grid, .game-layout { grid-template-columns: minmax(0, 1fr); }
  .game-layout { gap: 12px; }
  .clues-panel { grid-template-columns: repeat(2, minmax(0,1fr)); max-height: none; }
  .search-grid { grid-template-columns: 1fr 1fr; }
  .generate-grid { grid-template-columns: 1fr 1fr; }
  .search-text { grid-column: 1 / -1; }
  .search-button { width: 100%; }
  .browse-grid { grid-template-columns: 1fr 1fr; }
  .browse-text { grid-column: 1 / -1; }
  .browse-button { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .site-header { min-height: 58px; }
  .brand { font-size: 16px; }
  .connection { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  main { padding-left: 10px; padding-right: 10px; }
  .hero { padding-top: 14px; }
  .hero h1 { font-size: 35px; }
  .lobby-grid .card { padding: 18px; }
  .account-card, .mine-card { padding: 16px 18px; }
  .account-row, .mine-item { flex-direction: column; align-items: stretch; }
  .mine-actions .button { flex: 1; }
  .modal { max-height: 100dvh; min-height: min(720px, 100dvh); border-radius: 15px; }
  .settings-modal { min-height: 0; align-self: end; }
  .overlay { padding: 0; place-items: stretch; }
  .modal-header, .modal-footer { padding: 13px 14px; }
  .modal-footer { align-items: stretch; flex-direction: column; }
  .tabs { padding-left: 8px; padding-right: 8px; }
  .tab-panel { padding: 13px; }
  .search-grid { grid-template-columns: 1fr; }
  .generate-grid { grid-template-columns: 1fr; }
  .search-text { grid-column: auto; }
  .puzzle-results { grid-template-columns: 1fr; }
  .browse-grid { grid-template-columns: 1fr; }
  .browse-head { padding: 12px 2px 0; }
  .browse-filters { padding: 14px; }
  .room-results { grid-template-columns: 1fr; }
  .game-head { align-items: flex-start; flex-direction: column; padding: 14px; }
  .puzzle-panel, .clues-panel { padding: 10px; }
  .crossword-viewport { height: calc(62dvh - var(--keyboard-height, 0px)); min-height: 300px; }
  .crossword-toolbar { gap: 5px; }
  .crossword-toolbar button { min-height: 40px; padding: 6px 9px; font-size: 13px; }
  .clues-panel { grid-template-columns: 1fr; }
  .preview-modal { min-height: 100dvh; }
  .preview-viewport { margin: 0 10px 10px; height: 62dvh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

.app-footer { margin: 26px auto 14px; text-align: center; font-size: 12.5px; }
