:root, html[data-theme="dark"] {
  --bg: #0f1420;
  --card: #1e2536;
  --card2: #242c40;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --primary: #1f6aa5;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #dc2626;
  --violet: #7c3aed;
  --gray: #475569;
  --cell: #232a3d;
  --cell-sel: #1e3a8a;
  --cell-rel: #2b3348;
  --border: #3b4763;
  --err-bg: #7f1d1d;
  --err: #f87171;
  --clue-bg: #2a3348;
  --clue: #93c5fd;
}
html[data-theme="light"] {
  --bg: #f1f5f9;
  --card: #ffffff;
  --card2: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --cell: #f8fafc;
  --cell-sel: #bfdbfe;
  --cell-rel: #eef2f7;
  --border: #cbd5e1;
  --err-bg: #fecaca;
  --err: #dc2626;
  --clue-bg: #e2e8f0;
  --clue: #1e3a8a;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  max-width: 560px; margin-left: auto; margin-right: auto;
  min-height: 100vh; padding-bottom: 24px;
  touch-action: manipulation;
}
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px 4px;
}
.topbar h1 { margin: 0; font-size: 20px; }
.subtitle { margin: 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.pill-btn {
  background: var(--card2); border: 1px solid var(--border);
  color: var(--text); border-radius: 16px; padding: 4px 10px;
  font-size: 13px; font-weight: bold; cursor: pointer; display: flex; align-items: center; gap: 4px;
}
.pill-btn:hover { border-color: var(--accent); }
.lang-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.lang-opt {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; text-align: left; width: 100%; font-size: 15px;
  background: var(--card2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; cursor: pointer;
}
.lang-opt:hover, .lang-opt.active { border-color: var(--accent); background: var(--cell-sel); }
.ghost-btn { background: none; border: none; font-size: 20px; cursor: pointer; }
.tabs { display: flex; gap: 4px; padding: 8px 12px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.tab {
  flex: 1; padding: 10px 2px; border: none; border-radius: 10px 10px 0 0;
  background: transparent; color: var(--muted); font-weight: bold; font-size: 20px; cursor: pointer;
}
.tab.active { color: var(--accent); border-bottom: 3px solid var(--accent); }
.tabpage { display: none; padding: 4px 12px; }
.tabpage.active { display: block; }
.card {
  background: var(--card); border-radius: 12px; padding: 12px;
  margin-bottom: 8px;
}
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.row:last-child { margin-bottom: 0; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button {
  border: 1px solid var(--border); background: var(--card2); color: var(--text);
  border-radius: 16px; padding: 6px 10px; font-size: 13px; cursor: pointer;
}
.seg button.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: bold; }
.timer { font-family: Consolas, monospace; font-size: 18px; font-weight: bold; color: var(--accent); }
.moves { color: var(--muted); font-size: 13px; text-align: right; }
.check { font-size: 13px; display: flex; align-items: center; gap: 4px; }
.hint { color: var(--muted); font-size: 12px; }
.btn {
  border: none; border-radius: 10px; padding: 12px 8px;
  font-size: 14px; font-weight: bold; cursor: pointer; color: #fff;
}
.btn:active { transform: scale(0.97); }
.btn.small { padding: 8px 4px; font-size: 12px; }
.primary { background: var(--primary); }
.green { background: var(--green); }
.amber { background: var(--amber); }
.red { background: var(--red); }
.blue { background: #0ea5e9; }
.violet { background: var(--violet); }
.gray { background: var(--gray); }
.purple { background: #8b5cf6; }
.ghost { background: transparent; color: var(--muted); font-weight: normal; }
.toggle { background: var(--card2); color: var(--text); border: 1px solid var(--border); }
.toggle[aria-pressed="true"] { background: var(--amber); color: #000; border-color: var(--amber); }
.btn:disabled { opacity: 0.5; }
.quickbar { display: flex; gap: 6px; margin-bottom: 4px; }
.quickbar .btn { flex: 1; }
/* Üst kalın satır: sol Yeni Bulmaca, sağ 2x2 dörtlü */
.topactions { align-items: stretch; }
.topactions #newBtn { flex: 1; }
.quad { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.quad .btn { width: 100%; font-size: 14px; }
.topactions #newBtn { font-size: 16px; }
.status { text-align: center; font-size: 13px; font-weight: bold; color: var(--accent); min-height: 20px; margin: 4px 0; }
.board-wrap { display: flex; justify-content: center; margin: 4px 0 8px; }
#board {
  display: grid; gap: 4px; justify-content: center;
}
.cell, .clue {
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-weight: bold;
}
.cell {
  background: var(--cell); border: 2px solid var(--border);
  cursor: pointer; flex-direction: column; line-height: 1.15; user-select: none;
}
.cell .big { font-size: 22px; }
.cell .notes { font-size: 10px; color: var(--muted); white-space: pre; text-align: center; }
.cell.sel { background: var(--cell-sel); border-color: var(--accent); color: #fff; }
.cell.sel .notes { color: #e0f2fe; }
.cell.rel { background: var(--cell-rel); }
.cell.err { background: var(--err-bg); border-color: var(--err); }
.cell.err .big { color: var(--err); }
.clue { background: var(--clue-bg); color: var(--clue); font-size: 15px; }
.clue.err { background: var(--err-bg); color: var(--err); }
.clue.blank { background: transparent; }
/* Oyun tahtası 3D modu (Android parity: sprite + koyu karo; zemin 2D ile aynı saydam) */
#board.w3d { background: transparent; }
#board.w3d .cell {
  position: relative; overflow: visible;
  background: #232c4b; border: 1px solid rgba(255,255,255,.12);
}
#board.w3d .cell img {
  position: absolute; bottom: 1px; left: 50%; transform: translateX(-50%);
  width: 88%; display: block; pointer-events: none;
}
#board.w3d .cell.sel img { filter: drop-shadow(0 0 5px rgba(56,189,248,.95)); }
#board.w3d .cell.rel img { filter: drop-shadow(0 0 4px rgba(148,163,184,.7)); }
#board.w3d .cell.err img { filter: drop-shadow(0 0 5px rgba(248,113,113,.95)); }
#board.w3d .cell .notes { color: #e2e8f0; }
#board.w3d .cell.sel .notes { color: #e0f2fe; }
.numpad { display: grid; gap: 6px; margin: 4px 0 8px; }
.numpad button {
  background: var(--card2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 12px 0; font-size: 18px; font-weight: bold; cursor: pointer;
}
.numpad button.del { background: var(--red); color: #fff; border: none; font-size: 14px; }
h2 { font-size: 19px; margin: 8px 0; }
h3 { font-size: 15px; margin: 10px 0 4px; }
.guide p { font-size: 14px; line-height: 1.5; }
/* Rehber: her maddede 4x4 örnek tahta */
.gstep { margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.gstep:last-of-type { border-bottom: none; }
.gstep h3 { margin: 6px 0 4px; font-size: 15px; }
.gboard {
  position: relative;
  display: grid; grid-template-columns: repeat(6, 44px); gap: 5px;
  justify-content: center; align-items: center;
  background: #232c4b; border-radius: 12px;
  padding: 10px 10px 24px; margin: 8px auto 4px;
}
/* platform ön kalınlığı + birleşim çizgisi */
.gboard::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 14px;
  background: #141a33; border-radius: 0 0 12px 12px;
}
.gboard::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 14px; height: 2px;
  background: #3a4a6e;
}
.gboard .blank { width: 44px; height: 44px; }
.gboard .gc, .gboard .gl {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-weight: 800; font-size: 15px;
}
.gboard .gc {
  position: relative; height: 64px;
  background: none; border: none; width: 44px; padding: 0;
}
.gboard .gc img { position: absolute; bottom: 0; left: 0; width: 44px; display: block; }
.gboard .gl { background: var(--clue-bg); color: var(--clue); font-size: 16px; }
.gboard .gl.key { outline: 2px solid var(--amber); outline-offset: -2px; }
.gboard .gc.rowhl img { filter: drop-shadow(0 0 4px rgba(96,165,250,.9)); }
.gboard .gc.hl img { filter: drop-shadow(0 0 5px rgba(34,197,94,.9)); }
.gboard .gc.dimmed img { opacity: 0.45; }
.gcap { font-size: 12px; color: var(--muted); text-align: center; margin: 2px 0 6px; }
.hl-text { color: #22c55e; }
.cursel { font-weight: bold; font-size: 16px; }
/* Madde 7: dialog + banner slotu */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal[hidden] { display: none; }
.dlg {
  background: var(--card); border-radius: 14px; padding: 16px;
  width: min(92vw, 380px);
}
.adslot {
  position: sticky; bottom: 0; margin: 8px 12px 0;
  min-height: 52px; display: flex; align-items: center; justify-content: center;
  background: var(--card); border-radius: 10px; color: var(--muted); font-size: 13px;
}
/* Madde 8: mini örnek ızgaralar + 3D görünümlü binalar (assetsiz) */
.mini-grid { display: grid; gap: 4px; justify-content: center; margin: 6px 0 10px; }
.mcell, .mclue {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border-radius: 7px; font-weight: bold; font-size: 15px;
}
.mcell { background: var(--cell); border: 1px solid var(--border); }
.mclue { background: var(--clue-bg); color: var(--clue); }
.b3d { width: 46px; }
.b3d.dim { opacity: 0.45; }
.b3d .roof {
  display: block; height: 10px; background: #5b6e95;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
.b3d .brow { display: flex; align-items: stretch; }
.b3d .face {
  flex: 1; height: calc(var(--h) * 17px);
  background-color: #46587e;
  background-image:
    repeating-linear-gradient(to right, transparent 0 9px, rgba(0,0,0,0.35) 9px 11px),
    repeating-linear-gradient(to bottom, transparent 0 7px, rgba(255,209,102,0.9) 7px 12px);
  color: #fff; font-weight: 800; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.kv { display: flex; justify-content: space-between; font-size: 14px; padding: 3px 0; }
.kv span:last-child { font-family: Consolas, monospace; }

/* En iyi süreler: Dahili kaydırma */
#bestCard {
  max-height: 115px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#bestCard::-webkit-scrollbar {
  width: 5px;
}
#bestCard::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Skor Sekmesi: Jeton Kazanma Kartı (Alternatif B) */
.earn-token-card {
  border: 1.5px solid #b45309;
  background: linear-gradient(135deg, rgba(27, 38, 64, 0.95), rgba(19, 31, 51, 0.95));
  border-radius: 14px;
  padding: 14px;
  margin-top: 10px;
}
.earn-token-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.earn-token-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
}
.badge.gold {
  background: #451a03;
  color: #fde68a;
  border: 1px solid #f59e0b;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
}
.earn-token-desc {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 10px 0;
  line-height: 1.4;
}
.btn.gold {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0f172a;
  font-weight: 800;
  font-size: 14px;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
  transition: transform 0.1s ease, filter 0.15s ease;
}
.btn.gold:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}
.btn.gold:active {
  transform: translateY(0);
}


/* Android v5 Parity Stilleri */
.token-pill {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #f59e0b;
}
.token-pill:hover {
  background: rgba(245, 158, 11, 0.25);
  border-color: #f59e0b;
}
.subheader-row {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
}
.subheader-row .cursel { font-size: 14px; font-weight: bold; }
.subheader-row .timer { font-size: 15px; font-weight: bold; color: var(--accent); }
.subheader-row .moves { font-size: 13px; color: var(--muted); }
.v5-actions {
  display: flex; gap: 6px; align-items: stretch; height: 42px; margin-bottom: 4px;
}
.btn.tonal {
  background: var(--card2); border: 1px solid var(--border); color: var(--text); border-radius: 12px;
}
.btn.tonal:hover {
  background: var(--border);
}
.btn.outline {
  background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: 12px;
}
.btn.outline:hover {
  background: var(--card2);
}
.new-btn { flex: 1.35; font-size: 13px; }
.undo-btn { flex: 1.0; font-size: 13px; }
.more-menu-wrap {
  position: relative; flex: 0.95;
}
.more-btn {
  width: 100%; height: 100%; font-size: 13px;
}
.dropdown-menu {
  position: absolute; right: 0; top: 46px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); z-index: 30; min-width: 170px; overflow: hidden; display: flex; flex-direction: column;
}
.dropdown-menu[hidden] { display: none; }
.dropdown-item {
  background: none; border: none; padding: 12px 14px; text-align: left; color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px;
}
.dropdown-item:hover {
  background: var(--card2); color: var(--accent);
}
.thumb-bar {
  display: flex; gap: 8px; align-items: center; height: 44px; margin: 4px 0 8px;
}
.thumb-btn {
  height: 100%; border-radius: 12px; font-size: 14px; font-weight: bold; cursor: pointer; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; gap: 6px;
}
.note-thumb {
  flex: 1; background: var(--card2); color: var(--text);
}
.note-thumb[aria-pressed="true"] {
  background: rgba(56, 189, 248, 0.2); border-color: var(--accent); color: var(--accent);
}
.hint-thumb {
  flex: 1.3; background: var(--card2); color: var(--text); justify-content: space-between; padding: 0 10px;
}
.hint-badge {
  font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 8px; background: rgba(245, 158, 11, 0.2); color: #d97706; border: 1px solid rgba(245, 158, 11, 0.4);
}
.dim-switch {
  flex: 1.1; height: 100%; background: var(--card2); border: 1px solid var(--border); border-radius: 12px; display: flex; padding: 3px; gap: 2px;
}
.switch-seg {
  flex: 1; height: 100%; border: none; border-radius: 9px; font-size: 13px; font-weight: bold; background: transparent; color: var(--muted); cursor: pointer; transition: all 0.15s ease;
}
.switch-seg.active {
  background: var(--primary); color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.token-balance-box {
  background: var(--card2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; text-align: center; margin: 12px 0 16px; font-size: 15px;
}
.token-balance-box strong {
  color: #f59e0b; font-size: 18px; margin-left: 6px;
}
