:root {
  --bg: #14161c;
  --bg2: #1b1e26;
  --card: #20242e;
  --line: #2f3542;
  --text: #e8e6e1;
  --muted: #9aa1ad;
  --accent: #e2b65a;
  --danger: #d0675f;
  --ok: #7fb685;

  --sq-light: #e2d5b6;
  --sq-dark: #b89870;
  --fog-light: #2b303b;
  --fog-dark: #252933;

  --cell: 32px;
  --cols: 10;
  --rows: 24;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Üst çubuk */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; background: rgba(20,22,28,.94); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px); }
.brand { color: var(--accent); font-weight: 700; letter-spacing: .04em; text-decoration: none; }
.status-line { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-line b { color: var(--text); }
.status-line .check { color: #ff8a80; font-weight: 700; }
.conn-badge { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: #5a3b2a; color: #ffd8b0; }

/* Düğmeler */
.btn { border: 1px solid var(--line); background: #2a2f3b; padding: 7px 14px; border-radius: 8px; cursor: pointer; }
.btn:hover { background: #333948; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: #1a1405; border-color: transparent; font-weight: 650; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: #ffb4ad; border-color: #5b3330; background: #2c2022; }
.btn.small { padding: 3px 10px; font-size: 14px; }
.btn.big { padding: 11px 20px; font-size: 16px; width: 100%; }

/* Lobi */
.lobby { display: grid; place-items: start center; padding: 32px 16px; }
.lobby-card { width: min(520px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.lobby-card h1 { margin: 0 0 6px; font-size: 26px; }
.lede { color: var(--muted); margin: 0 0 18px; }
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
legend { font-weight: 650; margin-bottom: 8px; }
.seg { display: flex; gap: 6px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 8px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: #262b36; }
.seg input:checked + span { border-color: var(--accent); background: #3a3324; color: #ffe3a6; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--accent); }
.check.small { font-size: 14px; color: var(--muted); margin-top: 6px; align-items: center; }
.check.small input { margin-top: 0; }
.rules { margin-top: 18px; color: var(--muted); font-size: 14px; }
.rules summary { cursor: pointer; color: var(--text); }
.rules li { margin: 4px 0; }
.hint { margin: 6px 0 0; }

/* Oyun yerleşimi */
.game { display: grid; grid-template-columns: auto minmax(280px, 360px); gap: 16px; padding: 12px 16px; justify-content: center; align-items: start; }
.board-area { min-width: 0; }
.board-tools { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.board-tools .spacer { flex: 1; }
.pill { padding: 3px 12px; border-radius: 999px; background: #2a2f3b; font-size: 14px; white-space: nowrap; }
.pill.mine { background: #3a3324; color: #ffe3a6; }
.pill.check { background: #5b2a27; color: #ffd0cb; font-weight: 700; }
.clock { padding: 3px 10px; border-radius: 999px; background: #232833; color: var(--muted); font-size: 14px;
  font-variant-numeric: tabular-nums; font-weight: 650; }
.clock.mine { background: #3a3324; color: #ffe3a6; }
.clock.low { background: #6a2622; color: #ffd0cb; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { filter: brightness(1.35); } }
select.btn { padding-right: 6px; }
.board-scroll { max-height: calc(100vh - 110px); overflow: auto; border-radius: 6px; overscroll-behavior: contain; }

.board { position: relative; width: calc(var(--cell) * var(--cols)); height: calc(var(--cell) * var(--rows));
  box-shadow: 0 0 0 2px #0c0d11, 0 10px 30px rgba(0,0,0,.5); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.grid { display: grid; grid-template-columns: repeat(var(--cols), var(--cell)); grid-template-rows: repeat(var(--rows), var(--cell)); }
.trails { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.cell { position: relative; display: grid; place-items: center; cursor: pointer; }
.cell.l { background: var(--sq-light); }
.cell.d { background: var(--sq-dark); }
.cell.fog.l { background: var(--fog-light); }
.cell.fog.d { background: var(--fog-dark); }
.cell.fog::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(255,255,255,.035) 0 2px, transparent 2px 7px); }
.cell.vis-all:not(.fog)::before { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 1px rgba(120,200,255,.35); pointer-events: none; }

/* Kule sınır çizgileri: 8|9 ve 16|17 */
.zl { position: absolute; z-index: 4; pointer-events: none; }
.zl.top, .zl.bottom { left: 0; right: 0; height: 3px;
  background: repeating-linear-gradient(90deg, rgba(134,193,204,.95) 0 8px, rgba(134,193,204,.35) 8px 12px); }
.zl.left, .zl.right { top: 0; bottom: 0; width: 3px;
  background: repeating-linear-gradient(180deg, rgba(134,193,204,.95) 0 8px, rgba(134,193,204,.35) 8px 12px); }
.zl.top { top: -1.5px; }
.zl.bottom { bottom: -1.5px; }
.zl.left { left: -1.5px; }
.zl.right { right: -1.5px; }

.coord { position: absolute; font-size: max(9px, calc(var(--cell) * .26)); line-height: 1; font-weight: 600; pointer-events: none; opacity: .75; }
.coord.row { left: 2px; top: 2px; }
.coord.col { right: 3px; bottom: 2px; }
.cell.l .coord { color: #8a6e4a; }
.cell.d .coord { color: #f1e6cc; }
.cell.fog .coord { color: #6d7484; }

.cell.last { box-shadow: inset 0 0 0 calc(var(--cell) * .5) rgba(226,182,90,.28); }
.cell.sel { box-shadow: inset 0 0 0 3px var(--accent), inset 0 0 0 calc(var(--cell) * .5) rgba(226,182,90,.25); }
.cell.pv::after { content: ""; position: absolute; inset: 0; background: rgba(110,190,255,.16); pointer-events: none; }
.cell.fog.pv::after { background: rgba(110,190,255,.1); }
.cell.incheck { box-shadow: inset 0 0 calc(var(--cell) * .45) calc(var(--cell) * .1) rgba(230,60,50,.9); }
.cell.attacker { box-shadow: inset 0 0 0 3px rgba(230,80,70,.85); }

.dot { position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(30,30,30,.38); pointer-events: none; z-index: 3; }
.cell.fog .dot { background: transparent; border: 2px dashed rgba(226,182,90,.75); width: 36%; height: 36%; }
.ring { position: absolute; inset: 6%; border-radius: 50%; border: 3px solid rgba(208,103,95,.85); pointer-events: none; z-index: 3; }

/* Taşlar */
.pc { position: relative; z-index: 2; width: 92%; height: 92%; display: grid; place-items: center; pointer-events: none;
  font-family: "Apple Symbols", "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", serif;
  font-size: calc(var(--cell) * .82); line-height: 1; }
.pc.w { color: #fbf7ee; text-shadow: 0 0 1px #000, 0 1px 1px #000, 1px 0 1px #000, -1px 0 1px #000, 0 -1px 1px #000; }
.pc.b { color: #17181c; text-shadow: 0 0 1px #fff8, 0 1px 1px #fff6, 1px 0 1px #fff6, -1px 0 1px #fff6, 0 -1px 1px #fff6; }
.pc svg { width: 100%; height: 100%; display: block; }
.pc.ghost { opacity: .5; filter: grayscale(.6); }
.cell.fog .pc.b.ghost { color: #4a4f5c; }
.pc.ghost::after { content: ""; position: absolute; inset: 6%; border: 1px dashed rgba(255,255,255,.45); border-radius: 50%; }

/* Panel */
.panel { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.card h2 { font-size: 15px; margin: 0 0 8px; }
.card.row, .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.kv { display: flex; justify-content: space-between; gap: 10px; margin: 3px 0; }
.kv > span:first-child { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.small-link { font-size: 13px; color: var(--muted); }
.invite { display: flex; gap: 6px; margin: 6px 0; }
.invite input { flex: 1; min-width: 0; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: #171a21; }
.glyphs { font-family: "Apple Symbols", "Segoe UI Symbol", "Noto Sans Symbols 2", serif; font-size: 18px; text-align: right; word-break: break-all; }
.meter { position: relative; height: 10px; border-radius: 6px; background: #2a2f3b; margin: 8px 0; overflow: visible; }
.meter > div { height: 100%; border-radius: 6px; background: linear-gradient(90deg, #8d7340, var(--accent)); width: 0; transition: width .3s; }
.meter > i { position: absolute; top: -3px; width: 2px; height: 16px; background: #cfd3da; }
.result { border-color: var(--accent); background: #2a2618; }
.result-text { font-size: 18px; font-weight: 700; margin-bottom: 8px; }

.log-card { display: flex; flex-direction: column; }
.log { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; font-size: 13.5px; }
.log li { padding: 4px 0; border-bottom: 1px solid #272c37; display: flex; gap: 8px; }
.log li .n { color: #6b7280; min-width: 2.2em; text-align: right; font-variant-numeric: tabular-nums; }
.log li.capture { color: #b9e3be; }
.log li.loss { color: #ffb4ad; }
.log li.bump { color: #ffd59a; }
.log li.check { color: #ff8a80; font-weight: 700; }
.log li.enemy { color: #c6cbe0; }
.log li.promo { color: #ffe3a6; }
.log li.end { color: var(--accent); font-weight: 700; }
.log li.timeout { color: #ffd59a; }

/* Terfi çubuğu ve bildirimler */
.promo-bar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 40; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center;
  background: #2a2618; border: 1px solid var(--accent); border-radius: 12px; padding: 8px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: calc(100vw - 32px); }
.toasts { position: fixed; top: 56px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(460px, calc(100vw - 32px)); }
.toast { background: #2a2f3b; border: 1px solid var(--line); padding: 8px 14px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.45); animation: tin .2s ease-out; text-align: center; }
.toast.bump { border-color: #a07a35; color: #ffe0a8; }
.toast.check { border-color: #a33a33; color: #ffd0cb; font-weight: 700; }
.toast.loss { border-color: #6b3a36; color: #ffc8c2; }
.toast.end { border-color: var(--accent); color: #ffe3a6; font-weight: 700; }
.toast.turn { border-color: var(--accent); background: #3a3324; color: #ffe3a6; font-weight: 700; }
.toast.timeout { border-color: #a07a35; color: #ffe0a8; }

/* Fare üzerindeki karenin bilgisi (farenin sol üstünde) */
.hover-info { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; max-width: 270px;
  background: rgba(24,27,34,.97); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px;
  font-size: 13px; line-height: 1.4; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.hover-info .head { display: flex; gap: 8px; align-items: center; margin-bottom: 2px; font-size: 14px; }
.hover-info .tag { font-size: 11px; padding: 0 7px; border-radius: 999px; }
.hover-info .tag.fog { background: #2f3542; color: var(--muted); }
.hover-info .tag.vis { background: #24382a; color: #b9e3be; }
.hover-info .hi { font-weight: 650; }
.hover-info .good { color: #b9e3be; }
.hover-info .bad { color: #ff8a80; font-weight: 700; }

/* Yatay tahta: tahta ekran genişliğince, panel altta kartlar yan yana */
.game.horiz { grid-template-columns: minmax(0, 1fr); justify-items: center; }
.game.horiz .board-area { max-width: 100%; }
.game.horiz .board-scroll { max-height: none; }
.game.horiz .panel { width: 100%; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); align-items: start; }
.game.horiz .log-card { grid-row: span 2; }
.game.horiz .log { max-height: 240px; }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } }

/* Telefon / dar ekran */
@media (max-width: 900px) {
  .game { grid-template-columns: 1fr; padding: 8px; gap: 10px; justify-items: center; }
  .board-area, .panel { width: 100%; }
  .board-area { display: flex; flex-direction: column; align-items: center; }
  .board-tools { width: 100%; }
  .board-scroll { max-height: none; overflow: visible; max-width: 100%; overflow-x: auto; }
  .topbar { padding: 8px 12px; }
  .log { max-height: 220px; }
}
