:root {
  --green: #1b6e4b;
  --green-d: #14543a;
  --bg: #0f1411;
  --panel: #182019;
  --line: #2a3a30;
  --txt: #e7efe9;
  --muted: #8aa093;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--txt);
  min-height: 100vh;
}

#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--green-d);
  color: #fff;
}

#brand { font-weight: 700; letter-spacing: .5px; }
#me { font-size: 14px; opacity: .9; }

.topRight { display: flex; align-items: center; gap: 10px; }
.iconbtn {
  background: transparent;
  border: 0;
  padding: 2px 4px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  opacity: .45;            /* domyślnie wyszarzony (🔕 jest już przekreślony) */
  filter: grayscale(1);
}
.iconbtn:hover { opacity: .7; }
.iconbtn.on { opacity: 1; filter: none; } /* po włączeniu — normalny 🔔 */

#topbar #leaveBtn {
  padding: 4px 12px;
  font-size: 18px;
  line-height: 1;
  color: #fff;
  border-color: rgba(255,255,255,.45);
}
#topbar #leaveBtn.hidden { display: none; }

main { max-width: 520px; margin: 0 auto; padding: 20px 16px 40px; }

.view.hidden { display: none; }

h1 { font-size: 22px; }
h2 { font-size: 18px; margin: 0; }

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--txt);
  font-size: 16px;
  margin: 10px 0;
}

button {
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--green);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
button:hover { background: #207d56; }
button:disabled { background: #33433a; color: var(--muted); cursor: default; }
button.ghost { background: transparent; border: 1px solid var(--line); }

#myGamesSec { margin-bottom: 14px; }
#myGamesSec.hidden { display: none; }
#myGamesSec h3 { font-size: 15px; margin: 0 0 8px; }
ul#myGames { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
#myGames li.mygame {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #182a20;
  border: 1px solid var(--green);
  border-radius: 10px;
}
.yourturn {
  display: inline-block;
  background: var(--green);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  margin-left: 6px;
  white-space: nowrap;
}
#quitBtn { padding: 6px 12px; font-size: 13px; }
.gtime { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--muted);
}

ul#tableList { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
#tableList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

#requests { margin: 6px 0 14px; }
#requests.hidden { display: none; }
#requests h3 { font-size: 15px; margin: 0; }
#requests button { padding: 6px 12px; font-size: 14px; }
ul#requestList { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
#requestList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
#requestEmpty { margin: 8px 0 0; font-size: 13px; }
#requestEmpty.hidden { display: none; }

.muted { color: var(--muted); }
.muted.hidden { display: none; }

.status { font-weight: 600; }
.clock {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}
.clock.low { color: #ff7a7a; }

/* Formularz nowego stolika */
.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  margin-bottom: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.card.hidden { display: none; }
.card label { font-size: 13px; color: var(--muted); }
.card select {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--txt);
  font-size: 15px;
}
.card .actions { margin-top: 6px; }
.checkrow {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--txt) !important;
  font-size: 14px !important;
}
.checkrow.hidden { display: none; }
.checkrow input { width: 18px; height: 18px; }

#seats {
  display: flex;
  gap: 12px;
  margin: 10px 0;
}
.seat {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
}
.seat.turn { border-color: var(--green); box-shadow: 0 0 0 2px rgba(32,125,86,.4); }
.seat.off { opacity: .5; }
.seat .mark { font-size: 18px; font-weight: 700; line-height: 1; }
.seat .score {
  margin-left: auto;
  font-weight: 700;
  font-size: 12px;
  color: var(--green);
  white-space: nowrap;
}

#boardWrap { position: relative; }

#board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 8px;
  margin: 8px 0 18px;
  aspect-ratio: 1 / 1;
}
.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  font-size: inherit; /* rozmiar znaku ustawia JS na #board zależnie od planszy */
  line-height: 1;
  font-weight: 700;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  user-select: none;
}
#board.dense .cell { border-radius: 3px; }

/* ---- Literki ---- */
#board.literki .cell { border-radius: 2px; border: none; background: #20302a; position: relative; }
#board.literki .cell.center { background: #2c4a3a; }
#board.literki .cell.pDL { background: #2b5b86; }
#board.literki .cell.pTL { background: #1f7fb0; }
#board.literki .cell.pDW { background: #8a4d6a; }
#board.literki .cell.pTW { background: #a23b3b; }
#board.literki .cell.tile { background: #e7d9a8; color: #1b1b1b; }
#board.literki .cell.tile.blanktile { background: #cdbf8f; }
#board.literki .cell.pending { background: #f2e08a; outline: 2px solid var(--green); cursor: pointer; }
.premlabel { font-size: 62%; font-weight: 700; opacity: .9; color: #eaf3ee; }
.tilecontent { position: relative; line-height: 1; font-weight: 800; }
.tilecontent .pts { font-size: 42%; vertical-align: super; margin-left: 1px; opacity: .85; }

#liMsg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 90%;
  padding: 14px 18px;
  background: rgba(138, 59, 46, .96);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.5);
  pointer-events: none;
  z-index: 40;
}
#liMsg.hidden { display: none; }

#literki { margin: 6px 0 14px; }
#literki.hidden { display: none; }
#liInfo { font-size: 13px; margin-bottom: 8px; }
#liRack {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px;
  background: #3a2c18;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 44px;
}
.racktile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 40px;
  background: #e7d9a8;
  color: #1b1b1b;
  border-radius: 6px;
  font-size: 22px;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 2px 0 #b9a875;
}
.racktile.used { opacity: .3; cursor: default; }
.racktile.held { outline: 3px solid var(--green); transform: translateY(-3px); }
#liControls { margin-top: 10px; }
.cell.x { color: #6ec6ff; }
.cell.o { color: #ffb27a; }
.cell.playable { cursor: pointer; outline: 2px dashed rgba(32,125,86,.5); }
.cell.playable:hover { background: #20281f; }

/* Przekreślenie nad wygrywającą trójką */
#strike {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#strike.hidden { display: none; }
#strike line {
  stroke: #ff5b5b;
  stroke-width: 10;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(255,91,91,.6));
}

/* Komunikat o wyniku na środku planszy + rewanż */
#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(15,20,17,.72);
  border-radius: 12px;
  text-align: center;
  padding: 16px;
}
#overlay.hidden { display: none; }
#overlayText {
  font-size: 28px;
  font-weight: 800;
  text-shadow: 0 2px 8px rgba(0,0,0,.6);
}
#rematchInfo { font-size: 13px; min-height: 16px; }

#chat { margin-top: 10px; }
#chatLog {
  list-style: none;
  padding: 8px;
  margin: 0 0 8px;
  height: 120px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
}
#chatLog .who { color: var(--green); font-weight: 600; }
.chatRow { display: flex; gap: 8px; }
.chatRow input { margin: 0; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #2a1414;
  color: #ffd9d9;
  border: 1px solid #5a2a2a;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 50;
}
#toast.hidden { display: none; }

#connBanner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  padding: 8px 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: #8a3b2e;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
#connBanner.hidden { display: none; }
