/* Literownia — własny wygląd: morska zieleń, orzechowa rama, kremowe płytki.
   Kolory pól: ×2 litera szałwia, ×3 litera morska zieleń, ×2 słowo złoto, ×3 słowo śliwka. */
body.lit {
  --accent: #6fcfb6; --accent-ink: #062a22;
  --bg: #0f1f1d; --bg-2: #142826; --panel: #17302d; --panel-2: #1f3d39; --line: #2c4e49;
  --text: #e8f0ee; --muted: #9cb8b2;
  --wood: #3a2819; --wood-2: #24170e;
  --cream: #f7eed8; --cream-2: #ecdcb6; --ink-t: #2b2118;
  --q-l2: #8fb9a8; --q-l3: #3f7f6e; --q-s2: #e0b25a; --q-s3: #8e5ba8;
  --sq: #efe6cf; --grid: #cfbf9b;
  background: radial-gradient(1100px 650px at 30% -12%, #1f4a44 0%, var(--bg) 62%) fixed, var(--bg);
  min-height: 100vh; display: flex; flex-direction: column;
}
body.lit > .screen { flex: 1; }
.lit-brand { display: flex; align-items: center; gap: 10px; color: var(--cream); text-decoration: none; font: 700 22px/1 var(--display); letter-spacing: .01em; }
.lit-mark {
  position: relative; width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center;
  background: linear-gradient(160deg, #fbf3df, #ead7ad); color: var(--ink-t); font: 700 18px/1 var(--display);
  box-shadow: inset 0 -3px 0 rgba(120, 90, 40, .35), 0 2px 6px rgba(0, 0, 0, .35);
}
.lit-mark i { position: absolute; right: 3px; bottom: 2px; font: 700 8px/1 var(--font); font-style: normal; }

/* ---------- lobby ---------- */
.lit-lobby { max-width: 980px; margin: 24px auto 8px; padding: 0 16px; display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; align-items: start; }
.lit-hero { grid-column: 1 / -1; text-align: center; padding: 26px 18px 18px; background: linear-gradient(180deg, rgba(111, 207, 182, .08), transparent), var(--panel); }
.lit-hero p { max-width: 620px; margin: 16px auto 0; }
.lit-hero-tiles { display: flex; justify-content: center; gap: clamp(3px, 1vw, 6px); }
.tile.hero {
  position: relative; inset: auto; flex: 0 1 54px; min-width: 0; aspect-ratio: 1;
  font-size: clamp(15px, 4.6vw, 32px); border-radius: clamp(5px, 1.2vw, 8px); animation: heroIn .55s cubic-bezier(.2, .9, .3, 1.3) backwards; animation-delay: calc(var(--i) * 55ms);
}
.tile.hero .v { font-size: clamp(8px, 1.6vw, 12px); right: 4px; bottom: 3px; }
@keyframes heroIn { from { transform: translateY(-18px) rotate(-8deg); opacity: 0; } }
.lit-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.lit-stats div { background: var(--panel-2); border-radius: 12px; padding: 12px 8px; text-align: center; }
.lit-stats b { display: block; font: 700 28px/1.1 var(--display); color: var(--cream); }
.lit-stats span { font-size: 12px; color: var(--muted); }
.seg .btn { background: var(--panel-2); }

/* ---------- układ gry ---------- */
.lit-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; padding: 12px 16px; max-width: 1480px; margin: 0 auto; width: 100%; }
.lit-main { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; }
.lit-side { display: flex; flex-direction: column; gap: 12px; min-height: 0; max-height: calc(100vh - 56px - 24px); position: sticky; top: 68px; }
.lit-side .feed-card { min-height: 200px; }

/* rama i plansza: wymiary w cqw (procent szerokości ramy) */
.lit-frame {
  container-type: inline-size; width: min(100%, calc(100vh - 56px - 250px)); min-width: 300px;
  background: linear-gradient(145deg, #4a3421 0%, var(--wood) 45%, var(--wood-2) 100%);
  border-radius: 14px; padding: 2.1cqw 2.1cqw 0; box-shadow: 0 18px 40px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .08);
}
.lit-board {
  display: grid; grid-template-columns: repeat(15, 1fr); gap: .28cqw; padding: .28cqw; aspect-ratio: 1;
  background: var(--grid); border-radius: .9cqw; box-shadow: inset 0 0 0 .15cqw rgba(0, 0, 0, .12);
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.lit-frame-foot { padding: 1.3cqw .6cqw 1.5cqw; }
.cell {
  position: relative; background: var(--sq); border-radius: .45cqw; display: grid; place-items: center;
  color: rgba(255, 255, 255, .96); text-align: center; line-height: 1; cursor: pointer; min-width: 0; aspect-ratio: 1;
}
.cell.L2 { background: var(--q-l2); }
.cell.L3 { background: var(--q-l3); }
.cell.S2 { background: var(--q-s2); color: #4a3410; }
.cell.S3 { background: var(--q-s3); }
.cell .pl b { display: block; font: 700 2.05cqw/1 var(--display); }
.cell .pl small { display: block; font: 700 .9cqw/1.1 var(--font); text-transform: uppercase; letter-spacing: .02em; margin-top: .2cqw; opacity: .9; }
.cell .starmark { font-size: 3.6cqw; color: #7a5410; }
.cell:not(.filled):hover { filter: brightness(1.06); }
.cell.drop { box-shadow: inset 0 0 0 .35cqw var(--accent); }
.cell.cursor { box-shadow: inset 0 0 0 .3cqw #1c6b5a; }
.cell.cursor::after {
  content: '→'; position: absolute; inset: 0; display: grid; place-items: center; font: 700 3.2cqw/1 var(--font); color: #1c6b5a;
  animation: blink 1s steps(2, start) infinite; background: rgba(255, 255, 255, .45); border-radius: .45cqw;
}
.cell.cursor.dir-v::after { content: '↓'; }
@keyframes blink { to { opacity: .35; } }

/* płytki */
.tile {
  position: absolute; inset: 0; border-radius: .5cqw; display: grid; place-items: center;
  background: linear-gradient(160deg, #fbf3df 0%, var(--cream) 45%, var(--cream-2) 100%); color: var(--ink-t);
  box-shadow: inset 0 -.28cqw 0 rgba(120, 90, 40, .32), inset 0 .1cqw 0 rgba(255, 255, 255, .8), 0 .16cqw .32cqw rgba(0, 0, 0, .32);
  font: 700 3.7cqw/1 var(--display);
}
.tile .l { transform: translateY(-.15cqw); }
.tile .v { position: absolute; right: .33cqw; bottom: .25cqw; font: 700 1.2cqw/1 var(--font); }
.tile.blank .l { color: #2f7c69; font-style: italic; }
.tile.last { box-shadow: inset 0 -.28cqw 0 rgba(120, 90, 40, .32), inset 0 0 0 .22cqw #e8794a, 0 .16cqw .32cqw rgba(0, 0, 0, .32); }
.tile.pending {
  background: linear-gradient(160deg, #fffaf0 0%, #fbeec6 55%, #f1d998 100%); cursor: grab; touch-action: none;
  box-shadow: inset 0 -.28cqw 0 rgba(140, 100, 30, .35), 0 0 0 .3cqw var(--accent), 0 .5cqw 1cqw rgba(0, 0, 0, .35);
  transform: translateY(-.2cqw); z-index: 2;
}
.tile.pending.bad { box-shadow: inset 0 -.28cqw 0 rgba(140, 100, 30, .35), 0 0 0 .3cqw #e0584f, 0 .5cqw 1cqw rgba(0, 0, 0, .35); }
.tile.dragging, .rtile.dragging { opacity: .25; }
.tile.drop-in { animation: dropIn .5s cubic-bezier(.2, .9, .3, 1.25); }
@keyframes dropIn { from { transform: translateY(-1.8cqw) scale(1.15); opacity: 0; } }

/* stojak */
.lit-rackbar { width: min(100%, 700px); min-width: 300px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lit-status { min-height: 26px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 10px; text-align: center; font-size: 14px; }
.st-main { font-weight: 700; }
.st-pts { font: 700 18px/1 var(--display); color: var(--accent); }
.st-err { color: #ff9b93; font-weight: 600; }
.st-words .w, .feed .w { font-weight: 700; letter-spacing: .03em; }
.st-words small, .feed .w + small { color: var(--muted); margin: 0 4px 0 2px; font-size: 11px; }
.bingo { background: var(--q-s2); color: #3b2a07; font-weight: 800; font-size: 11px; padding: 2px 7px; border-radius: 999px; }
.lit-rack {
  --rt: clamp(40px, 11.6vw, 58px);
  display: flex; gap: 7px; justify-content: center; align-items: center; min-height: calc(var(--rt) + 20px); width: 100%;
  padding: 10px 12px; border-radius: 14px; background: linear-gradient(180deg, #4a3421, var(--wood-2));
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, .45), 0 6px 18px rgba(0, 0, 0, .3); transition: box-shadow .15s;
}
.lit-rack.drop { box-shadow: inset 0 3px 8px rgba(0, 0, 0, .45), 0 0 0 3px var(--accent); }
.rack-empty { color: #cdb995; font-size: 13px; }
.rtile {
  --rt: clamp(40px, 11.6vw, 58px);
  position: relative; width: var(--rt); height: var(--rt); flex: 0 0 auto; border-radius: 8px; display: grid; place-items: center; border: 0; padding: 0;
  background: linear-gradient(160deg, #fbf3df 0%, var(--cream) 45%, var(--cream-2) 100%); color: var(--ink-t);
  box-shadow: inset 0 -4px 0 rgba(120, 90, 40, .32), inset 0 1px 0 rgba(255, 255, 255, .85), 0 3px 6px rgba(0, 0, 0, .35);
  font: 700 calc(var(--rt) * .56)/1 var(--display); cursor: grab; touch-action: none; user-select: none; transition: transform .12s;
}
.rtile .v { position: absolute; right: 5px; bottom: 4px; font: 700 calc(var(--rt) * .21)/1 var(--font); }
.rtile.blank .l { display: none; }
.rtile.blank::before { content: ''; width: 46%; height: 46%; border: 2px dashed rgba(47, 124, 105, .55); border-radius: 6px; }
.rtile.sel { transform: translateY(-7px); box-shadow: inset 0 -4px 0 rgba(120, 90, 40, .32), 0 0 0 3px var(--accent), 0 8px 14px rgba(0, 0, 0, .4); }
.rtile:hover { transform: translateY(-2px); }
.drag-ghost { position: fixed; z-index: 90; pointer-events: none; transform: translate(-50%, -60%) rotate(-5deg) scale(1.1); box-shadow: 0 14px 24px rgba(0, 0, 0, .45); }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }
.lit-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.lit-actions .btn:not(.primary):not(.ghost) { background: var(--panel-2); }
#a-play { min-width: 150px; }

/* gracze */
.pl-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 11px; background: var(--panel-2); margin-bottom: 7px; border: 1px solid transparent; transition: background .2s; }
.pl-row.turn { border-color: var(--accent); background: linear-gradient(90deg, rgba(111, 207, 182, .16), var(--panel-2) 70%); }
.pl-av { width: 34px; height: 34px; border-radius: 8px; flex: 0 0 34px; display: grid; place-items: center; background: linear-gradient(160deg, #fbf3df, var(--cream-2)); color: var(--ink-t); font: 700 18px/1 var(--display); box-shadow: inset 0 -3px 0 rgba(120, 90, 40, .3); }
.pl-row.me .pl-av { background: linear-gradient(160deg, #c9f3e7, var(--accent)); }
.pl-main { flex: 1; min-width: 0; }
.pl-nm { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-sub { font-size: 12px; color: var(--muted); }
.pl-right { text-align: right; }
.pl-score { font: 700 24px/1 var(--display); color: var(--cream); }
.pl-clock { font: 600 13px/1.2 var(--font); font-variant-numeric: tabular-nums; color: var(--muted); margin-top: 4px; }
.pl-clock.low { color: var(--q-s2); }
.pl-clock.over { color: #ff8a80; font-weight: 800; }
.crown { color: var(--q-s2); }
.thinking i { font-style: normal; animation: dots 1.2s infinite; }
.thinking i:nth-child(2) { animation-delay: .2s; } .thinking i:nth-child(3) { animation-delay: .4s; }
@keyframes dots { 0%, 60%, 100% { opacity: .2; } 30% { opacity: 1; } }

/* worek */
.unseen { display: flex; flex-wrap: wrap; gap: 4px; }
.us { display: inline-flex; align-items: baseline; gap: 3px; font: 600 12px/1 var(--font); background: rgba(255, 255, 255, .06); border-radius: 6px; padding: 5px 6px; color: var(--muted); font-variant-numeric: tabular-nums; }
.us b { color: var(--text); font-weight: 700; }
.us.zero { opacity: .28; }

/* przebieg */
.feed .pts { color: var(--accent); font-weight: 700; }
.lg-sys { color: var(--muted); font-style: italic; }
.lg-bad { color: #ffb3ab; }

/* okna */
.blank-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.blank-grid .btn { padding: 10px 0; font: 700 18px/1 var(--display); background: var(--panel-2); }
.ex-rack { display: flex; gap: 7px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.ex-rack .rtile { cursor: pointer; }
.ex-rack .rtile.xsel { transform: translateY(-6px); box-shadow: inset 0 -4px 0 rgba(120, 90, 40, .32), 0 0 0 3px #e0584f; opacity: .9; }
.row-btns { display: flex; gap: 8px; justify-content: center; }
.end-modal .rank { flex-wrap: wrap; }
.end-modal .rank.win { box-shadow: inset 0 0 0 2px var(--q-s2); }
.end-det { flex: 1 1 100%; order: 3; font-size: 12px; color: var(--muted); }
.end-sc { font: 700 22px/1 var(--display); color: var(--cream); }
.end-rack { letter-spacing: .1em; color: var(--cream-2); }
.over-win { color: var(--accent); }
.rules-modal { width: min(720px, 100%); }
.rules { font-size: 14px; line-height: 1.55; }
.rules h4 { margin: 16px 0 4px; font-size: 14px; color: var(--accent); }
.rules h4:first-child { margin-top: 0; }
.rules p, .rules ul { margin: 0 0 6px; }
.rules ul { padding-left: 20px; }
.rules li { margin-bottom: 3px; }
.rules a { color: var(--accent); }
.rules kbd { font: 600 12px var(--font); background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; }
.rtable { border-collapse: collapse; margin: 8px 0 6px; font-size: 13px; }
.rtable td { padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rtable .rv { color: var(--muted); white-space: nowrap; }
.rl { display: inline-block; font: 700 15px/1.3 var(--display); margin-right: 8px; }
.rl sub { font: 600 10px var(--font); color: var(--muted); margin-left: 1px; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 12px; font-weight: 700; color: #fff; }
.chip.L2 { background: var(--q-l2); } .chip.L3 { background: var(--q-l3); } .chip.S2 { background: var(--q-s2); color: #4a3410; } .chip.S3 { background: var(--q-s3); }

/* wsparcie autora na ramie planszy */
.wsparcie.on-frame { color: #d9c9a6; font-size: max(11px, 1.45cqw); }
.wsparcie.on-frame b { color: #fff3d6; }
.wsparcie.on-frame .ws-link { color: #f3c46b; }
.wsparcie.on-frame .ws-heart { color: #f08a7e; }

.lit-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; padding: 14px 16px 18px; font-size: 12px; color: var(--muted); text-align: center; }
.lit-foot a { color: var(--accent); }

/* ---------- wąskie ekrany ---------- */
@media (max-width: 1000px) {
  .lit-layout { grid-template-columns: 1fr; padding: 8px; }
  .lit-frame, .lit-rackbar { width: 100%; min-width: 0; }
  .lit-side { position: static; max-height: none; }
  .lit-lobby { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .cell .pl small { display: none; }
  .cell .pl b { font-size: 2.6cqw; }
  .lit-frame { border-radius: 10px; padding: 1.6cqw 1.6cqw 0; }
  .lit-rack { gap: 4px; padding: 8px 6px; }
  .lit-actions .btn { padding: .55em .8em; }
  .lit-brand { font-size: 18px; }
}

/* ---------- stoliki dla znajomych ---------- */
.lit-lobby-right { display: grid; gap: 20px; align-content: start; min-width: 0; }
.mode-seg .btn { padding: .75em .6em; font-size: 14px; }
#tables .tbl .btn { white-space: nowrap; }
.room-title { color: var(--cream); }
.room .seat .pl-av { flex: 0 0 34px; }
.room .seat .xbtn { margin-left: auto; }
.room-host { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin: 0 0 16px; padding: 12px; border-radius: 12px; background: rgba(255, 255, 255, .03); border: 1px solid var(--line); }
.room-host .seg { flex: 0 1 auto; }
.room-host .seg .btn { background: var(--panel-2); }
.room-host .seg .btn.on { background: var(--accent); color: var(--accent-ink); }
.room-bot { display: flex; gap: 8px; align-items: center; }
.room-bot select { width: auto; padding: 7px 10px; font-size: 13px; }
.room .hint { margin-top: 6px; }
.pl-off { color: #ffb36b; }
.pl-row.out { opacity: .55; }
.pl-row.out .pl-score { text-decoration: line-through; text-decoration-thickness: 2px; }
.lg-chat { color: var(--text); }
.lg-chat b { color: var(--accent); font-weight: 700; }
.lit-side .chat-form { margin-top: 8px; }
.pl-av.emo { font: 20px/1 var(--font); }
