/* WordJoy — WordFeud-style dark theme, iPad-first */

:root {
  --side-bg: #182330;
  --side-row: #1f2c3c;
  --side-row-active: #27394e;
  --ink: #e9eef4;
  --muted: #93a3b5;
  --main-bg: #2a3746;
  --cell: #223041;
  --cell-edge: #1a2531;
  --dl: #7cb84f;
  --tl: #3f8fd2;
  --dw: #f0963a;
  --tw: #d94f45;
  --center: #f0963a;
  --tile: #f6f1e2;
  --tile-ink: #20242b;
  --tile-staged: #cfe6b6;
  --tile-last: #e8dfc2;
  --accent: #7cc24f;
  --blue: #3d9be9;
  --danger: #e06a5b;
  --bar: #1c2836;
  --btn: #374a5f;
  --btn-hover: #435b74;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--main-bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

#app { display: flex; height: 100%; height: 100dvh; }

/* ---------- Sidebar (game list) ---------- */

#sidebar {
  width: 320px;
  flex: 0 0 320px;
  background: var(--side-bg);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(0, 0, 0, 0.35);
  z-index: 30;
}

.side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.wordmark { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; }
.wordmark::after { content: ""; }

.side-actions { display: flex; gap: 8px; }

.icon-btn {
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  min-width: 38px;
  height: 38px;
  font-size: 1.05rem;
  display: grid;
  place-items: center;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.16); }

.game-list { flex: 1; overflow-y: auto; padding-bottom: 24px; }

.list-section {
  padding: 14px 18px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.game-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 16px;
  border: 0;
  background: transparent;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
}
.game-row:hover { background: var(--side-row); }
.game-row.active { background: var(--side-row-active); }

.game-row .avatar { flex: 0 0 44px; }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(145deg, #55677d, #3a4b60);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #dbe4ee;
  text-transform: uppercase;
}

.row-text { flex: 1; min-width: 0; }
.row-name { font-weight: 600; font-size: 0.98rem; }
.row-move, .row-meta {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-move { color: #b8c5d4; margin-top: 1px; }
.row-meta { margin-top: 1px; }

.time-badge {
  flex: 0 0 auto;
  background: var(--accent);
  color: #0f1a08;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 6px;
  padding: 4px 7px;
}
.time-badge.idle { background: #4a5f79; color: #d5dfea; }

.empty-list { padding: 28px 20px; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

/* ---------- Main game view ---------- */

#game-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--main-bg);
}

#game-view.online-active > :not(#online-game-base) { display: none !important; }
.online-game-base { flex: 1; min-width: 0; min-height: 0; overflow: hidden; padding: 0; background: var(--main-bg); }
.online-game-page { display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 0; }
.online-native-scorebar { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 66px; padding: 10px 16px; border-bottom: 1px solid rgba(0, 0, 0, 0.3); background: var(--bar); }
.online-native-turn { color: #c4d0dd; }
#sidebar.online-game-selected #game-list .game-row.active { background: transparent; }

#scorebar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--bar);
  border-bottom: 1px solid rgba(0, 0, 0, 0.3);
  min-height: 66px;
}

.player { display: flex; align-items: center; gap: 10px; min-width: 0; }
.player .avatar { width: 40px; height: 40px; flex: 0 0 40px; font-size: 1rem; }
.pmeta { min-width: 0; }
.pmeta.right { text-align: right; }
.pname {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.pscore { font-size: 1.35rem; font-weight: 700; line-height: 1.05; }

.mid {
  flex: 1;
  text-align: center;
  font-size: 0.85rem;
  color: #c4d0dd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mid .sub { display: block; font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
.mid .win { color: var(--accent); font-weight: 700; }

/* ---------- Board ---------- */

#board-wrap {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  position: relative;
  padding: 10px;
}

#board {
  width: 100%;
  max-width: calc(100dvh - 250px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  gap: 2px;
  background: var(--cell-edge);
  padding: 3px;
  border-radius: 6px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.cell {
  position: relative;
  background: var(--cell);
  border-radius: 2px;
  display: grid;
  place-items: center;
}

.cell .premium-label {
  font-size: clamp(7px, 1.1vw, 12px);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.92);
  pointer-events: none;
}

.cell.dl { background: var(--dl); }
.cell.tl { background: var(--tl); }
.cell.dw { background: var(--dw); }
.cell.tw { background: var(--tw); }
.cell.center { background: var(--center); }
.cell.drop-target { outline: 2px solid rgba(255, 255, 255, 0.75); outline-offset: -2px; }

/* ---------- Tiles ---------- */

.tile {
  position: absolute;
  inset: 6%;
  background: linear-gradient(160deg, #fbf7ea, var(--tile));
  border-radius: 8%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45), inset 0 -1px 0 rgba(0, 0, 0, 0.12);
  display: grid;
  place-items: center;
  color: var(--tile-ink);
  font-weight: 700;
  cursor: grab;
  touch-action: none;
}
.tile .letter { font-size: clamp(12px, 2.3vw, 29px); line-height: 1; margin-top: -6%; }
.tile .value {
  position: absolute;
  right: 8%;
  bottom: 5%;
  font-size: clamp(6px, 0.85vw, 11px);
  font-weight: 700;
  color: #4a4f57;
}
.tile.blank .letter { color: #8a4a3c; }
.tile.staged { background: linear-gradient(160deg, #dceec8, var(--tile-staged)); }
.tile.last { background: linear-gradient(160deg, #f3ecd4, var(--tile-last)); }

/* Rack */
#rack-area {
  padding: 8px 12px 4px;
  display: grid;
  place-items: center;
}

#rack {
  /* Seven rack tiles occupy seven of the board's fifteen cell widths. */
  width: min(100%, calc((100dvh - 250px) * 7 / 15), calc((100vw - 20px) * 7 / 15));
  max-width: none;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.rack-slot {
  position: relative;
  aspect-ratio: 1;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 6px;
}
.rack-slot.swap-pick .tile { outline: 3px solid var(--blue); outline-offset: -1px; }
.rack-slot.selected .tile { outline: 3px solid #ffffff; outline-offset: -1px; transform: translateY(-6%); }
.rack-slot .tile { font-size: 100%; }
.rack-slot .tile .letter { font-size: clamp(13px, 3vw, 34px); }
.rack-slot .tile .value { font-size: clamp(8px, 1.3vw, 15px); }

.rack-note { color: var(--muted); font-size: 0.85rem; padding: 12px; }

/* ---------- Action bar ---------- */

#actionbar {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--bar);
}

.btn {
  border: 0;
  background: var(--btn);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  min-width: 74px;
}
.btn:hover:not(:disabled) { background: var(--btn-hover); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); color: #10200a; }
.btn.primary:hover:not(:disabled) { background: #8fd35f; }
.btn.danger { background: var(--danger); color: #2b0f0b; }

/* ---------- Board overlay (game over) ---------- */

#board-overlay {
  position: absolute;
  inset: 10px;
  display: grid;
  place-items: center;
  background: rgba(20, 29, 39, 0.82);
  border-radius: 8px;
  z-index: 5;
}

.gameover-card {
  background: var(--bar);
  border-radius: 14px;
  padding: 28px 34px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  max-width: 420px;
}
.gameover-card h2 { margin: 0 0 6px; font-size: 1.7rem; }
.gameover-card .final { font-size: 1.05rem; color: #c4d0dd; margin-bottom: 18px; }
.gameover-card .final strong { color: var(--ink); font-size: 1.35rem; }
.gameover-card .row { display: flex; gap: 10px; justify-content: center; }

/* ---------- Chat panel ---------- */

#chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 92vw);
  background: var(--side-bg);
  border-left: 1px solid rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  z-index: 40;
  box-shadow: -18px 0 44px rgba(0, 0, 0, 0.4);
  animation: slide-in 160ms ease-out;
}

@keyframes slide-in { from { transform: translateX(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 1.1rem;
  font-weight: 600;
}

#chat-messages { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-day { align-self: center; margin: 7px 0 2px; padding: 3px 10px; border-radius: 999px; background: rgb(31 52 42 / 8%); color: #6f746f; font-size: 1rem; }

.chat-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 0;
  flex-wrap: wrap;
}

.chat-tool {
  border: 0;
  border-radius: 8px;
  background: var(--btn);
  color: var(--ink);
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 600;
}

.chat-tool:hover { background: var(--btn-hover); }
.chat-tool.primary { background: var(--accent); color: #10200a; }
#media-status { color: var(--muted); font-size: 0.75rem; min-height: 1em; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-media { margin-top: 7px; max-width: min(100%, 360px); }
.msg-media img, .msg-media video { display: block; width: 100%; max-height: 300px; object-fit: contain; border-radius: 8px; background: #111820; }
.msg-media audio { display: block; max-width: 100%; }

.doodle-scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(9, 14, 20, 0.72);
}

.doodle-panel {
  width: min(760px, 100%);
  background: var(--bar);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}

.doodle-panel h2 { margin: 0 0 12px; }
.doodle-canvas { display: block; width: 100%; height: auto; border-radius: 8px; background: var(--tile); touch-action: none; cursor: crosshair; }
.doodle-palette, .doodle-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.doodle-color { width: 30px; height: 30px; border: 2px solid rgba(255,255,255,0.65); border-radius: 50%; cursor: pointer; }
.doodle-actions { justify-content: flex-end; }

.msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.you { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.msg.opp { align-self: flex-start; background: #2c3c4f; border-bottom-left-radius: 4px; }
.msg-time { display: block; font-size: 0.65rem; opacity: 0.7; margin-top: 4px; }

.chat-empty { color: var(--muted); text-align: center; margin-top: 40px; font-size: 1.25rem; }

#chat-form {
  display: flex;
  gap: 10px;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
#chat-input {
  flex: 1;
  border: 0;
  border-radius: 999px;
  background: #0f1822;
  color: var(--ink);
  padding: 12px 18px;
  font-size: 0.95rem;
  outline: none;
}
#chat-input:focus { box-shadow: 0 0 0 2px var(--blue); }

/* ---------- Modals ---------- */

#modal-root:empty { display: none; }
#online-root:empty { display: none; }

.modal-scrim {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 23, 0.66);
  display: grid;
  place-items: center;
  z-index: 60;
}

.modal {
  background: var(--bar);
  border-radius: 14px;
  padding: 24px 26px;
  width: min(430px, calc(100vw - 40px));
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
}
.modal h2 { margin: 0 0 16px; font-size: 1.3rem; }
.modal .field { margin-bottom: 14px; }
.modal label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.modal select, .modal input[type="text"] {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #0f1822;
  color: var(--ink);
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 0.95rem;
}
.modal .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.modal .row.stack { flex-direction: column; align-items: stretch; }
/* Lazy board-word definitions. These sit above the game without changing its layout. */
.definition-scrim {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(16 33 28 / 72%);
  backdrop-filter: blur(6px);
}
.chat-header > span { font-size: 1.35rem; }

.emoji-picker { position: relative; display: inline-grid; flex: 0 0 auto; align-self: center; }
.emoji-picker[hidden],
.beta-guest .emoji-picker { display: none !important; }
.emoji-picker-toggle,
.emoji-picker-choice { display: grid; width: 42px; height: 42px; place-items: center; padding: 0; border: 0; border-radius: 11px; background: #263646; color: var(--ink); font: 1.25rem/1 "Segoe UI Emoji", "Apple Color Emoji", sans-serif; touch-action: manipulation; }
.emoji-picker-toggle:hover,
.emoji-picker-choice:hover { background: #354a5f; }
.emoji-picker-tray { position: absolute; z-index: 90; bottom: calc(100% + 8px); left: 0; display: grid; grid-template-columns: repeat(6, 42px); gap: 5px; padding: 8px; border: 1px solid rgb(255 255 255 / 12%); border-radius: 14px; background: #16222e; box-shadow: 0 12px 34px rgb(0 0 0 / 42%); }
.emoji-picker-featured { grid-column: 5; }
.emoji-picker-secondary { grid-column: 6; }
.emoji-picker-choice.compact { font-size: 0.92rem; letter-spacing: -0.28em; padding-right: 0.28em; }
.emoji-picker-choice.oversize { overflow: visible; font-size: 2.35rem; }
.emoji-picker-choice.muted-hundred { filter: saturate(0.72) hue-rotate(-8deg) brightness(1.16); }
.emoji-picker-custom-icon { display: block; width: 34px; height: 34px; object-fit: contain; pointer-events: none; }
.emoji-picker-custom-icon.large { width: 41px; height: 41px; }
.emoji-picker-custom-icon.wide { width: 39px; height: 39px; }
.emoji-picker-tray[hidden] { display: none; }

.definition-panel {
  --definition-drag-x: 0px;
  --definition-drag-y: 0px;
  width: min(520px, 100%);
  max-height: min(76vh, 680px);
  overflow: auto;
  padding: 24px;
  border: 1px solid rgb(255 255 255 / 45%);
  border-radius: 20px 6px 20px 6px;
  color: #20352d;
  background: linear-gradient(145deg, #fffdf2, #e9f0df);
  box-shadow: 0 24px 70px rgb(0 0 0 / 35%);
  transform: translate3d(var(--definition-drag-x), var(--definition-drag-y), 0);
}
.definition-search-panel { gap: 10px; }
.definition-search-input { width: 100%; border: 1px solid rgb(255 255 255 / 24%); border-radius: 10px; background: #f7f1df; color: #15221b; padding: 10px 12px; font: 700 1.15rem/1.2 "Trebuchet MS", sans-serif; text-transform: uppercase; letter-spacing: 0.06em; }
.definition-search-match { min-height: 1.2em; color: #5d6d62; font-size: 0.9rem; }
.keyboard-anchor { outline: 3px solid rgb(244 196 74 / 78%); outline-offset: -3px; }

.definition-eyebrow {
  margin-bottom: 12px;
  color: #7a321f;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.definition-entry + .definition-entry {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgb(32 53 45 / 18%);
}

.definition-entry h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.75rem, 5vw, 2.45rem);
  line-height: 1;
}

.definition-pos {
  margin-top: 6px;
  color: #66766d;
  font-size: 0.82rem;
  font-style: italic;
}

.definition-borrowed-note {
  margin-top: 10px;
  color: #8a432c;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.definition-linked-word {
  appearance: none;
  background: none;
  border: 0;
  color: inherit;
  cursor: inherit;
  display: inline;
  font: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  margin: 0;
  padding: 0;
  text-align: inherit;
  text-decoration: none;
}

.definition-linked-word:focus-visible {
  outline: 1px dotted currentColor;
  outline-offset: 2px;
}

.definition-entry ol {
  margin: 14px 0 0;
  padding-left: 1.35rem;
}

.definition-entry li + li {
  margin-top: 8px;
}

.definition-source {
  display: block;
  margin-top: 20px;
  color: #466c58;
  font-size: 0.76rem;
}

.definition-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.definition-actions .btn {
  flex: 1;
  border: 1px solid rgb(32 53 45 / 24%);
  background: #dbe7d6;
  box-shadow: none;
  color: #20352d;
}

.definition-actions .btn:hover,
.definition-actions .btn:focus-visible {
  background: #c9dbc3;
}

.definition-actions .definition-close {
  border-color: rgb(122 50 31 / 22%);
  background: #f4dccb;
  color: #6f2d1f;
}

.definition-actions .definition-close:hover,
.definition-actions .definition-close:focus-visible {
  background: #ebc8b0;
}

.definition-pager {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  color: #627068;
  font-size: 0.76rem;
  text-align: center;
}

.definition-page-arrow {
  width: 42px;
  height: 34px;
  border: 1px solid rgb(32 53 45 / 22%);
  border-radius: 10px;
  background: #e4ecdf;
  color: #294239;
  font: 700 1rem/1 Georgia, serif;
  cursor: pointer;
}

.definition-page-arrow:disabled {
  opacity: 0.35;
  cursor: default;
}

@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  .definition-scrim {
    background: rgb(16 33 28 / 36%);
    backdrop-filter: blur(3px);
  }

  .definition-panel.is-desktop-draggable .definition-eyebrow {
    margin: -10px -10px 12px;
    padding: 10px;
    cursor: grab;
    user-select: none;
    touch-action: none;
  }

  .definition-panel.is-desktop-draggable .definition-eyebrow.is-dragging {
    cursor: grabbing;
  }
}
/* ---------- Optional online lobby ---------- */

.online-account {
  margin: 8px 12px 4px;
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 0.74rem;
}
.online-account strong { color: var(--ink); }
.online-game-list { padding-bottom: 4px; }
.online-game-list:empty { display: none; }
.online-game-list .list-section { color: #77d4bb; }
.online-request-heading { color: #ffd66b !important; letter-spacing: .04em; }
.online-request-row {
  border: 1px solid rgba(255, 207, 76, .72);
  background: linear-gradient(105deg, rgba(159, 87, 20, .9), rgba(211, 72, 55, .86));
  box-shadow: 0 0 0 1px rgba(255, 238, 169, .18), 0 8px 24px rgba(95, 29, 12, .28);
  animation: online-request-arrive .5s ease-out both;
}
.online-request-row:hover { filter: brightness(1.08); }
.online-request-avatar { background: #ffe48b; color: #713a0e; font-weight: 900; }
.online-request-action {
  color: #fff3c4;
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
}
.online-invite-dialog {
  overflow: hidden;
  border-color: rgba(255, 214, 100, .75);
  background: radial-gradient(circle at 50% 0, rgba(255, 209, 91, .18), transparent 48%), #243832;
}
.online-invite-dialog.arriving { animation: online-request-arrive .42s ease-out both; }
.online-invite-spark { color: #ffe18a; letter-spacing: .8em; text-align: center; }
.online-invite-choices { color: #cae8de; }
.online-invite-actions { justify-content: flex-end; }
@keyframes online-request-arrive {
  from { opacity: 0; transform: translateY(-8px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.online-row .time-badge { background: rgba(53, 164, 132, 0.18); color: #8ce3ca; }
.online-modal { width: min(560px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 32px)); overflow: auto; }
.online-modal h3 { margin: 20px 0 9px; color: var(--muted); font-size: 0.76rem; letter-spacing: 0.08em; text-transform: uppercase; }
.online-modal input[type="password"] {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #0f1822;
  color: var(--ink);
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 1.3rem;
}
.online-account-bar, .online-card, .online-empty {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: #111b25;
  padding: 11px 12px;
}
.online-account-bar, .online-card { display: flex; align-items: center; gap: 10px; }
.online-account-bar { justify-content: space-between; }
.online-card + .online-card { margin-top: 8px; }
.online-card-main { flex: 1; min-width: 0; }
.online-card-name { color: var(--ink); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.online-card-meta { margin-top: 3px; color: var(--muted); font-size: 0.74rem; }
.online-card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.online-card-actions .btn { padding: 7px 10px; font-size: 0.77rem; }
.online-empty { color: var(--muted); font-size: 0.82rem; }
.online-error { min-height: 1.2em; margin-top: 10px; color: #ff9e97; font-size: 0.78rem; }
.online-badge { display: inline-flex; padding: 2px 7px; border-radius: 999px; background: rgba(53, 164, 132, 0.16); color: #8ce3ca; font-size: 0.68rem; }

.humble-welcome {
  position: relative;
  width: min(500px, calc(100vw - 34px));
  overflow: visible;
  border: 1px solid rgb(255 224 134 / 48%);
  background:
    radial-gradient(circle at 50% 10%, rgb(255 223 126 / 22%), transparent 46%),
    linear-gradient(145deg, #173b35, #102720 72%);
  color: #fff8df;
  text-align: center;
  box-shadow:
    0 26px 70px rgb(0 0 0 / 58%),
    0 0 52px rgb(236 192 86 / 12%);
  animation: humble-welcome-arrive 520ms cubic-bezier(.18, .82, .28, 1.16) both;
}
.humble-welcome h2 {
  margin: 12px 0 8px;
  color: #ffe59b;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 6vw, 2.35rem);
  line-height: 1.05;
  text-shadow: 0 2px 18px rgb(255 202 82 / 24%);
}
.humble-welcome p {
  max-width: 32ch;
  margin: 0 auto;
  color: #f4ead0;
  font-size: clamp(1rem, 3.4vw, 1.22rem);
  line-height: 1.5;
}
.humble-welcome-seal {
  display: grid;
  width: 64px;
  height: 64px;
  margin: -4px auto 0;
  place-items: center;
  border: 2px solid #f3d47c;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, #fff3bc, #d9a938 48%, #805c17);
  color: #17352d;
  font: 800 1.05rem/1 Georgia, serif;
  letter-spacing: 0.08em;
  box-shadow: 0 0 0 6px rgb(255 224 134 / 8%), 0 8px 26px rgb(0 0 0 / 34%);
}
.humble-welcome-actions { justify-content: center !important; }
.humble-welcome-actions .btn {
  min-width: 136px;
  border-color: #e4c064;
  background: #d7a93d;
  color: #17271f;
  font-weight: 800;
}
.humble-welcome-stars {
  position: absolute;
  inset: 50%;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.humble-welcome-star {
  position: absolute;
  left: 0;
  top: 0;
  color: #ffe28a;
  font-size: var(--star-size);
  line-height: 1;
  opacity: 0;
  filter: drop-shadow(0 0 5px rgb(255 221 117 / 72%));
  animation: humble-star-spray 1450ms cubic-bezier(.13, .7, .22, 1) var(--star-delay) both;
}
@keyframes humble-welcome-arrive {
  from { opacity: 0; transform: translateY(18px) scale(.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes humble-star-spray {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.2) rotate(0); }
  14% { opacity: 1; }
  72% { opacity: .95; }
  100% { opacity: 0; transform: translate(var(--star-x), var(--star-y)) scale(.92) rotate(var(--star-spin)); }
}
@media (prefers-reduced-motion: reduce) {
  .humble-welcome { animation: none; }
  .humble-welcome-star { display: none; }
}

.online-game-modal { width: min(940px, calc(100vw - 24px)); }
.online-game-notice { color: #8ce3ca; }
.online-game-notice.error { color: #ff9e97; }
.online-game-surface { display: flex; flex: 1; min-height: 0; flex-direction: column; align-items: center; overflow: hidden; }
.online-native-board-wrap { position: relative; display: grid; flex: 1; width: 100%; min-height: 0; place-items: center; padding: 10px; }
.online-native-rack-area { display: grid; width: 100%; place-items: center; padding: 8px 12px 4px; }
.online-game-score { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; width: min(100%, 690px); gap: 14px; }
.online-game-score > div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 7px 10px; border-radius: 8px; background: #111b25; }
.online-game-score > div:last-child { flex-direction: row-reverse; }
.online-game-score strong { font-size: 1.35rem; }
.online-game-score .online-game-turn { display: block; padding: 0; color: var(--muted); background: transparent; font-size: 0.75rem; text-align: center; }
.online-board { display: grid; grid-template-columns: repeat(15, 1fr); width: 100%; max-width: calc(100dvh - 250px); border: 2px solid #14202b; background: #14202b; gap: 2px; padding: 3px; border-radius: 6px; aspect-ratio: 1; }
.online-cell { position: relative; display: grid; place-items: center; min-width: 0; padding: 0; overflow: hidden; border: 0; border-radius: 2px; background: var(--cell); color: #9aacbd; font-size: clamp(0.38rem, 0.8vw, 0.65rem); font-weight: 800; touch-action: none; }
.online-cell.drag-over { outline: 2px solid rgb(255 255 255 / 80%); outline-offset: -2px; }
.online-cell:not(:disabled) { cursor: crosshair; }
.online-cell.premium-double-letter { background: var(--dl); color: #14220d; }
.online-cell.premium-triple-letter { background: var(--tl); color: #0d2032; }
.online-cell.premium-double-word,
.online-cell.premium-center { background: var(--dw); color: #2c1805; }
.online-cell.premium-triple-word { background: var(--tw); color: #2d0e0a; }
.online-cell.staged { outline: 2px solid #c9f2a6; outline-offset: -2px; }
.online-cell.admin-selected { outline: 3px solid #f5f0a4; outline-offset: -3px; box-shadow: inset 0 0 0 2px rgb(24 38 48 / 70%); }
.online-tile { position: absolute; inset: 5%; display: grid; place-items: center; border-radius: 8%; background: linear-gradient(160deg, #fbf7ea, var(--tile)); color: var(--tile-ink); box-shadow: 0 1px 2px rgb(0 0 0 / 45%); }
.online-tile .letter { font-size: clamp(0.72rem, 1.75vw, 1.45rem); font-weight: 800; line-height: 1; }
.online-tile .value { position: absolute; right: 7%; bottom: 3%; font-size: clamp(0.38rem, 0.65vw, 0.62rem); font-weight: 800; }
.online-tile.blank .letter { color: #8a4a3c; }
.online-tile.staged { background: linear-gradient(160deg, #dceec8, var(--tile-staged)); }
.online-rack { display: grid; grid-template-columns: repeat(7, 1fr); width: min(100%, calc((100dvh - 250px) * 7 / 15), calc((100vw - 20px) * 7 / 15)); gap: 5px; }
.online-rack-slot { position: relative; aspect-ratio: 1; min-width: 0; padding: 0; border: 0; border-radius: 6px; background: rgb(0 0 0 / 24%); touch-action: none; }
.online-drag-ghost { position: fixed; z-index: 2000; left: -24px; top: -24px; width: 48px; height: 48px; pointer-events: none; opacity: 0.9; filter: drop-shadow(0 8px 10px rgb(0 0 0 / 38%)); }
.online-rack-slot.selected { outline: 3px solid var(--blue); outline-offset: 2px; transform: translateY(-3px); }
.online-rack-slot.placed { opacity: 0.22; }
.online-rack-slot .online-tile .letter { font-size: clamp(1rem, 3vw, 1.8rem); }
.online-admin-tools { width: min(100%, 690px); padding: 12px; border: 1px solid rgb(201 242 166 / 38%); border-radius: 12px 4px 12px 4px; background: linear-gradient(145deg, rgb(27 48 39 / 96%), rgb(24 38 48 / 96%)); box-shadow: 0 10px 30px rgb(0 0 0 / 20%); }
.online-native-board-wrap > .online-admin-tools,
#board-wrap > .practice-admin-tools { position: absolute; z-index: 12; top: 7%; left: 50%; width: min(620px, calc(100% - 32px)); max-height: 50%; overflow: auto; transform: translateX(-50%); box-shadow: 0 16px 42px rgb(0 0 0 / 46%); }
.online-admin-header { position: sticky; z-index: 2; top: -12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -12px -12px 8px; padding: 10px 12px 8px; background: rgb(27 48 39 / 98%); }
.online-admin-header strong { color: #c9f2a6; font-size: 0.72rem; letter-spacing: 0.18em; }
.online-admin-done { padding: 5px 10px; background: #dce9d2; color: #20352d; }
.online-admin-help { margin: 7px 0 9px; color: #bdcdbf; font-size: 0.74rem; }
.online-admin-targets, .online-admin-premiums { display: flex; flex-wrap: wrap; gap: 5px; }
.online-admin-target, .online-admin-premium { min-width: 34px; min-height: 30px; padding: 4px 8px; border: 1px solid rgb(255 255 255 / 16%); border-radius: 6px; background: #f2ecd9; color: #26382f; font-weight: 800; }
.online-admin-target.selected, .online-admin-premium.selected { outline: 2px solid #c9f2a6; outline-offset: 1px; }
.online-admin-label { margin: 10px 0 5px; color: #8ce3ca; font-size: 0.67rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.online-admin-alphabet { display: grid; grid-template-columns: repeat(13, 1fr); gap: 4px; margin-top: 10px; }
.online-admin-letter { aspect-ratio: 1; min-width: 0; padding: 0; border: 0; border-radius: 5px; background: linear-gradient(160deg, #fffaf0, #d9c99f); color: #2a2419; font-size: 0.8rem; font-weight: 900; }
.online-admin-wildcard { grid-column: span 2; aspect-ratio: auto; min-height: 30px; background: linear-gradient(150deg, #fff7d7, #e0ba58); }
.online-admin-letter:disabled, .online-admin-target:disabled, .online-admin-premium:disabled { opacity: 0.35; }
.online-admin-warning { margin-top: 8px; color: #f3b89d; font-size: 0.72rem; }
.online-admin-settings p { margin: 0 0 14px; color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.online-admin-setting-status { margin-top: 10px; color: #b9cbbb; font-size: 0.76rem; }
.online-blank-picker { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; width: min(100%, 690px); padding: 8px; border-radius: 8px; background: #111b25; }
.online-blank-picker[hidden] { display: none; }
.online-blank-picker strong { flex: 1 0 100%; color: var(--muted); font-size: 0.75rem; text-align: center; }
.online-blank-letter { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 5px; background: var(--tile); color: var(--tile-ink); font-weight: 800; }
.online-game-help { color: var(--muted); font-size: 0.75rem; text-align: center; }
.online-game-actions { display: flex; width: 100%; flex-wrap: wrap; justify-content: center; gap: 10px; padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); background: var(--bar); }
.online-game-actions .btn { padding: 12px 20px; font-size: 0.95rem; }
.online-game-facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; color: var(--muted); font-size: 0.7rem; }
.online-last-move { color: #b8c5d4; font-size: 0.74rem; }
.online-game-final { width: min(100%, 690px); padding: 10px; border-radius: 8px; background: rgb(124 194 79 / 14%); color: #bde89f; text-align: center; }
.online-chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: min(560px, 92vw);
  border-left: 1px solid rgba(0, 0, 0, 0.4);
  background: var(--side-bg);
  box-shadow: -18px 0 44px rgba(0, 0, 0, 0.4);
  animation: slide-in 160ms ease-out;
}
.online-chat-panel.closing { pointer-events: none; animation: slide-out 160ms ease-in forwards; }
@keyframes slide-out { to { transform: translateX(100%); opacity: 0; } }
.online-chat-panel-content { display: flex; flex: 1; min-height: 0; }
.online-chat { display: flex; flex: 1; flex-direction: column; min-width: 0; margin: 0; padding: 12px; }
.online-chat h3 { margin: 0 0 7px; color: var(--muted); font-size: 1rem; letter-spacing: 0.08em; text-transform: uppercase; }
.online-chat-list { display: flex; flex: 1; min-height: 0; flex-direction: column; gap: 6px; overflow-y: auto; padding: 2px; }
.online-chat-empty { padding: 12px; color: var(--muted); font-size: 1.05rem; text-align: center; }
.online-chat-day { align-self: center; margin: 7px 0 2px; padding: 3px 9px; border-radius: 999px; background: rgb(255 255 255 / 7%); color: var(--muted); font-size: 0.9rem; }
.online-chat-message { position: relative; align-self: flex-start; max-width: min(82%, 28rem); padding: 7px 10px 5px; border-radius: 11px 11px 11px 3px; background: #2c3c4f; overflow-wrap: anywhere; }
.online-chat-message.mine { align-self: flex-end; border-radius: 11px 11px 3px 11px; background: #285f46; }
.online-chat-message.revoked { color: var(--muted); font-style: italic; }
.online-chat-message.revoked-sent { color: var(--muted); font-style: italic; opacity: 0.76; }
.online-chat-body { white-space: pre-wrap; font-size: 1.15rem; line-height: 1.32; }
.online-chat-meta { margin-top: 4px; font-size: 0.85rem; opacity: 0.68; text-align: right; }
.online-chat-revoke { display: block; margin: 4px 0 0 auto; padding: 3px 7px; border: 0; border-radius: 5px; background: rgb(0 0 0 / 18%); color: #ffd0cb; font-size: 0.85rem; }
.online-chat-form { display: flex; gap: 6px; margin-top: 7px; }
.online-chat-form .emoji-picker-toggle { width: 38px; height: 38px; border-radius: 9px; font-size: 1.1rem; }
.online-chat-form input { flex: 1; min-width: 0; border: 1px solid rgb(255 255 255 / 12%); border-radius: 9px; background: #0f1822; color: var(--ink); padding: 8px 10px; font: inherit; font-size: 1.1rem; }
.online-chat-form .btn { min-width: 0; padding: 8px 11px; font-size: 1.05rem; }

@media (max-width: 620px) {
  .online-card { align-items: flex-start; flex-direction: column; }
  .online-card-actions { justify-content: flex-start; }
  .online-game-base { padding: 0; }
  .online-native-board-wrap { padding: 8px 6px; }
  .online-native-board-wrap > .online-admin-tools,
  #board-wrap > .practice-admin-tools { top: 4%; width: calc(100% - 16px); max-height: 54%; }
  .online-board { width: min(100%, calc(100dvh - 235px)); }
  .online-rack { width: min(100%, calc((100dvh - 235px) * 7 / 15)); }
  .online-game-score { gap: 6px; font-size: 0.75rem; }
  .online-game-score strong { font-size: 1.05rem; }
}

.blank-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 6px;
}
.blank-grid button {
  aspect-ratio: 1;
  border: 0;
  border-radius: 6px;
  background: var(--tile);
  color: var(--tile-ink);
  font-weight: 700;
  font-size: 1rem;
}
.blank-grid button:hover { background: #fff; }

/* ---------- Toast ---------- */

#toast {
  pointer-events: none;
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: #101a26;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 0.9rem;
  z-index: 80;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  max-width: min(480px, 90vw);
  text-align: center;
}

/* ---------- Drag ghost ---------- */

.drag-ghost {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  width: var(--ghost, 44px);
  height: var(--ghost, 44px);
  transform: translate(-50%, -60%);
}
.drag-ghost .tile { position: absolute; inset: 0; cursor: grabbing; }

/* ---------- Narrow screens ---------- */

.only-narrow { display: none; }

@media (max-width: 880px) {
  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-102%);
    transition: transform 180ms ease-out;
    box-shadow: 18px 0 44px rgba(0, 0, 0, 0.4);
  }
  #sidebar.open { transform: none; }
  .only-narrow { display: grid; }
  #sidebar-scrim {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 25;
  }
  .pname { max-width: 72px; }
  #board { max-width: calc(100dvh - 235px); }
  #rack { max-width: calc(100dvh - 235px); }
  .btn { min-width: 0; padding: 12px 13px; font-size: 0.85rem; }
}
/* Stable keyed chat nodes keep active audio/video playback alive across board renders. */
.chat-message-content {
  min-width: 0;
}

.chat-message {
  display: grid;
  width: fit-content;
  max-width: min(86%, 30rem);
  margin: 0.45rem 0;
  padding: 0.65rem 0.75rem 0.4rem;
  border-radius: 1rem 1rem 1rem 0.25rem;
  background: #ece4cf;
  color: #20312b;
  box-shadow: 0 2px 8px rgb(31 42 37 / 10%);
}

.chat-message-you {
  margin-left: auto;
  border-radius: 1rem 1rem 0.25rem 1rem;
  background: #c9dfc8;
}

.chat-message-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 1.4rem;
  line-height: 1.32;
}

.chat-message-text.emoji-only { overflow-wrap: normal; white-space: nowrap; font-size: 4.2rem; line-height: 1.05; }
.online-chat-body.emoji-only { overflow-wrap: normal; white-space: nowrap; font-size: 3.45rem; line-height: 1.05; }
.chat-custom-emoji { display: inline-block; width: auto; max-width: 2em; height: 1.25em; object-fit: contain; vertical-align: -0.28em; }
.emoji-only .chat-custom-emoji { width: auto; max-width: 2.2em; height: 1em; vertical-align: -0.12em; }
.emoji-only .chat-custom-emoji-briefs { width: auto; max-width: 2.5em; height: 1.48em; }
.emoji-only .chat-custom-emoji-tape { width: auto; max-width: 2.4em; height: 1.4em; }

.chat-message-meta {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  font-size: 1rem;
  opacity: 0.68;
}

.chat-media-slot {
  min-width: 12rem;
  min-height: 2.5rem;
  margin-top: 0.4rem;
}

.chat-media-slot audio,
.chat-media-slot video,
.chat-media-image,
.chat-doodle-canvas {
  display: block;
  width: min(100%, 26rem);
  max-height: 22rem;
  border-radius: 0.75rem;
  object-fit: contain;
}

.doodle-v2-dialog {
  width: min(94vw, 48rem);
  padding: 1rem;
  border: 0;
  border-radius: 1.25rem;
  background: #f5edda;
  color: #20312b;
  box-shadow: 0 1.5rem 5rem rgb(20 34 29 / 38%);
}

.doodle-v2-dialog::backdrop {
  background: rgb(20 34 29 / 58%);
  backdrop-filter: blur(3px);
}

.doodle-v2-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 18 / 11;
  border: 1px solid #c9bea7;
  border-radius: 0.8rem;
  background: #fffdf7;
  touch-action: none;
  cursor: crosshair;
}

.doodle-color-1 { background: #20242b; }
.doodle-color-2 { background: #d94f45; }
.doodle-color-3 { background: #3f8fd2; }
.doodle-color-4 { background: #7cb84f; }
.doodle-color-5 { background: #f0963a; }

.doodle-color.selected {
  outline: 3px solid #fffdf7;
  box-shadow: 0 0 0 5px #163f33;
}

.attach-strip {
  display: flex;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  overflow-x: auto;
  background: #e9dfca;
}

.attach-strip[hidden] { display: none; }

.attach-chip {
  position: relative;
  flex: 0 0 4.5rem;
  width: 4.5rem;
  min-height: 3.5rem;
  overflow: hidden;
  border-radius: 0.7rem;
  background: #cfc5b0;
}

.attach-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chip-remove {
  position: absolute;
  top: 0.2rem;
  right: 0.2rem;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(16 26 22 / 78%);
  color: white;
}

.chip-spinner,
.chip-error {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 0.35rem;
  font-size: 0.7rem;
  text-align: center;
}

.attach-image {
  display: block;
  width: 100%;
  max-width: 20rem;
  min-height: 5rem;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0.75rem;
  background: #111820;
  contain: layout paint;
  cursor: zoom-in;
}

.attach-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attach-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  width: min(100%, 20rem);
}

.attach-grid .attach-image { aspect-ratio: 1; }

#chat-panel.dropping::after {
  content: "Drop photos here";
  position: absolute;
  inset: 0.5rem;
  z-index: 5;
  display: grid;
  place-items: center;
  border: 2px dashed #3f8fd2;
  border-radius: 0.9rem;
  background: rgb(63 143 210 / 12%);
  color: #163f33;
  font-weight: 700;
  pointer-events: none;
}

.photo-lightbox {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
  border: 0;
  background: rgb(6 10 15 / 96%);
}

.photo-lightbox::backdrop { background: rgb(6 10 15 / 96%); }

.lightbox-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: max(0.75rem, env(safe-area-inset-top));
  right: max(0.75rem, env(safe-area-inset-right));
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 18%);
  color: white;
  font-size: 1.15rem;
}

.chat-media-loading,
.chat-media-error {
  display: inline-block;
  padding: 0.65rem;
  font-size: 0.82rem;
}

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid #163f33;
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
.chat-message-content {
  -webkit-user-select: none;
  user-select: none;
}

.chat-message-actions,
.photo-lightbox-actions,
.doodle-tool-row,
.doodle-thickness {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-message-actions {
  justify-content: flex-end;
  margin-top: 5px;
  padding: 0 8px 5px;
}

.chat-message-action,
.chat-media-download {
  border: 0;
  border-radius: 999px;
  background: rgba(31, 52, 42, 0.1);
  color: var(--ink, #1f342a);
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  padding: 5px 9px;
  text-decoration: none;
}

.chat-message-action.danger { color: #9d2f29; }
.chat-message-action:disabled { cursor: wait; opacity: 0.55; }
.chat-revoked, .chat-media-blocked { color: #736f68; font-style: italic; }
.chat-doodle-player { display: grid; gap: 7px; justify-items: end; }
.doodle-play { margin-right: 4px; }

.photo-lightbox-actions {
  justify-content: center;
  margin-top: 10px;
}

.doodle-tool-row,
.doodle-thickness {
  flex-wrap: wrap;
  margin-top: 10px;
}

.doodle-tool-row .selected,
.doodle-thickness .selected {
  background: #285f46;
  color: #fffdf7;
}

.photo-download-setting {
  color: var(--ink, #1f342a);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  margin: 4px 0 7px;
}

.photo-download-setting[hidden] { display: none; }
.finished-game-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 6px;
}

.finished-game-row .game-row { min-width: 0; }

.finished-game-discard {
  align-self: center;
  border: 1px solid rgba(157, 47, 41, 0.24);
  border-radius: 8px;
  background: rgba(157, 47, 41, 0.08);
  color: #8b2b27;
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  padding: 7px 8px;
}

.online-finished-row .online-finished-discard {
  width: 0;
  min-width: 0;
  margin: 7px 0;
  padding-inline: 0;
  overflow: hidden;
  border-width: 0;
  color: #fff;
  background: #a9342f;
  font-size: 1.35rem;
  font-weight: 800;
  opacity: 0;
  transform: translateX(8px);
  transition: width 140ms ease, padding 140ms ease, opacity 140ms ease, transform 140ms ease;
}

.online-finished-row.delete-revealed .online-finished-discard {
  width: 42px;
  padding-inline: 11px;
  border-width: 1px;
  opacity: 1;
  transform: none;
}

.online-finished-row .online-finished-discard:hover { background: #c34139; }
.online-chat-message.pending {
  opacity: 0.78;
  outline: 1px dashed rgba(255, 255, 255, 0.32);
}

.online-chat-message.failed {
  opacity: 1;
  outline-color: #e57968;
}

.online-chat-pending-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  margin-top: 0.3rem;
}

/* JJ can collapse the board editor with 1 or either right-hand corner tile. */
.admin-keyboard-collapsed .online-admin-tools {
  display: none !important;
}

/* Leave both board-edge corner columns exposed as direct Admin toggles. */
.online-admin-tools {
  width: min(560px, calc(100vh - 346px), calc(100vw - 96px)) !important;
}
