:root {
  --bg: #0f1226;
  --bg2: #171b38;
  --card: #1e2347;
  --card2: #262c58;
  --line: #343b70;
  --text: #eef0ff;
  --muted: #9aa0c8;
  --accent: #7c5cff;
  --accent2: #22d3ee;
  --green: #22c55e;
  --yellow: #eab308;
  --gray: #4b5272;
  --red: #ef4444;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}
body.light {
  --bg: #f3f4fb;
  --bg2: #e8eaf6;
  --card: #ffffff;
  --card2: #eef0fb;
  --line: #d4d8ee;
  --text: #1b1e3a;
  --muted: #646a92;
  --gray: #9097b5;
  --shadow: 0 8px 24px rgba(40,50,120,.12);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Nunito', system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(124,92,255,.25), transparent 60%),
              radial-gradient(900px 500px at 110% 10%, rgba(34,211,238,.15), transparent 60%),
              var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-weight: 900; font-size: 20px;
}
.brand-text { font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.bank-badge { font-size: 12px; color: var(--muted); background: var(--card); border: 1px solid var(--line); padding: 5px 10px; border-radius: 999px; }
.icon-btn { background: var(--card); border: 1px solid var(--line); color: var(--text); border-radius: 10px; width: 38px; height: 38px; font-size: 18px; }

main { max-width: 1100px; margin: 0 auto; padding: 18px 14px 60px; }

/* ---------- Hub ---------- */
.hero { text-align: center; padding: 20px 10px 26px; }
.hero h1 { font-size: clamp(28px, 5vw, 46px); margin: 0 0 8px; font-weight: 900;
  background: linear-gradient(90deg, #fff, #c4b5fd, #67e8f9); -webkit-background-clip: text; background-clip: text; color: transparent; }
body.light .hero h1 { background: linear-gradient(90deg, #3b2bb8, #7c5cff, #0891b2); -webkit-background-clip: text; background-clip: text; }
.hero p { color: var(--muted); margin: 0; font-size: 16px; }
.stats-row { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.stat-pill { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; text-align: center; min-width: 120px; }
.stat-pill b { display: block; font-size: 22px; }
.stat-pill span { font-size: 12px; color: var(--muted); }

.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.game-card {
  position: relative; overflow: hidden; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; color: var(--text);
  transition: transform .15s, box-shadow .15s, border-color .15s; box-shadow: var(--shadow);
}
.game-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.game-card .gc-icon { font-size: 34px; width: 58px; height: 58px; display: grid; place-items: center; border-radius: 14px; margin-bottom: 12px; }
.game-card h3 { margin: 0 0 6px; font-size: 19px; font-weight: 800; }
.game-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.4; }
.game-card .gc-tag { position: absolute; top: 14px; right: 14px; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: var(--card2); color: var(--muted); }
.game-card .gc-best { margin-top: 10px; font-size: 12px; color: var(--accent2); font-weight: 700; }

/* ---------- Game shell ---------- */
.game-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.game-head .left { display: flex; align-items: center; gap: 10px; }
.game-head h2 { margin: 0; font-size: 24px; font-weight: 900; }
.back-btn { background: var(--card); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 8px 12px; font-weight: 700; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn {
  border: none; border-radius: 10px; padding: 10px 16px; font-weight: 800; font-size: 14px;
  background: var(--card2); color: var(--text); border: 1px solid var(--line); transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(.96); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #5b3df5); border-color: transparent; color: #fff; }
.btn.success { background: var(--green); border-color: transparent; color: #fff; }
.btn.danger { background: var(--red); border-color: transparent; color: #fff; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { background: transparent; border: none; color: var(--muted); padding: 7px 11px; border-radius: 8px; font-weight: 800; font-size: 13px; }
.seg button.active { background: var(--accent); color: #fff; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.center { text-align: center; }
.muted { color: var(--muted); }
.info-bar { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-bottom: 14px; }
.info-chip { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; font-weight: 800; }
.info-chip small { color: var(--muted); font-weight: 700; margin-right: 6px; }
.info-chip.warn { border-color: var(--red); color: var(--red); }

/* ---------- Keyboard ---------- */
.kb { display: flex; flex-direction: column; gap: 7px; margin: 16px auto 0; max-width: 620px; user-select: none; }
.kb-row { display: flex; gap: 5px; justify-content: center; }
.kb-key {
  flex: 1; max-width: 48px; height: 56px; border-radius: 8px; border: none;
  background: var(--card2); color: var(--text); font-weight: 800; font-size: 17px; border: 1px solid var(--line);
}
.kb-key.wide { max-width: 78px; flex: 1.6; font-size: 13px; }
.kb-key.correct { background: var(--green); color: #fff; border-color: transparent; }
.kb-key.present { background: var(--yellow); color: #fff; border-color: transparent; }
.kb-key.absent { background: var(--gray); color: #ffffffaa; border-color: transparent; }
.kb-key:active { transform: scale(.94); }

/* ---------- Wordle ---------- */
.wd-board { display: grid; gap: 6px; justify-content: center; margin: 6px auto; }
.wd-row { display: grid; gap: 6px; }
.wd-tile {
  width: clamp(44px, 12vw, 60px); height: clamp(44px, 12vw, 60px);
  border: 2px solid var(--line); border-radius: 8px; display: grid; place-items: center;
  font-size: clamp(22px, 6vw, 30px); font-weight: 900; text-transform: uppercase; background: transparent;
}
.wd-tile.filled { border-color: var(--muted); animation: pop .1s; }
.wd-tile.correct { background: var(--green); border-color: var(--green); color: #fff; }
.wd-tile.present { background: var(--yellow); border-color: var(--yellow); color: #fff; }
.wd-tile.absent { background: var(--gray); border-color: var(--gray); color: #fff; }
.wd-tile.flip { animation: flip .45s ease forwards; }
.wd-row.shake { animation: shake .4s; }
@keyframes pop { 50% { transform: scale(1.1); } }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes shake { 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }
.dist-row { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.dist-row .bar { background: var(--gray); color: #fff; font-weight: 800; padding: 2px 8px; border-radius: 4px; text-align: right; min-width: 24px; }
.dist-row .bar.hl { background: var(--green); }

/* ---------- Hangman ---------- */
.hm-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: center; }
.hm-svg { width: 100%; max-width: 260px; margin: 0 auto; display: block; }
.hm-svg .part { stroke: var(--text); stroke-width: 4; stroke-linecap: round; fill: none; opacity: 0; transition: opacity .3s; }
.hm-svg .part.show { opacity: 1; }
.hm-svg .base { stroke: var(--muted); stroke-width: 5; stroke-linecap: round; fill: none; }
.hm-word { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0 6px; }
.hm-letter { width: 40px; height: 50px; border-bottom: 4px solid var(--accent); display: grid; place-items: center; font-size: 28px; font-weight: 900; }
.hm-letter.miss { color: var(--red); }
.hm-cat { text-align: center; color: var(--accent2); font-weight: 800; margin-bottom: 4px; }
@media (max-width: 700px) { .hm-wrap { grid-template-columns: 1fr; } .hm-svg { max-width: 180px; } }

/* ---------- Word search ---------- */
.ws-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 18px; align-items: start; width: 100%; box-sizing: border-box; }
.ws-wrap > * { min-width: 0; max-width: 100%; box-sizing: border-box; }
.ws-grid { display: grid; gap: 2px; user-select: none; touch-action: none; margin: 0 auto; background: var(--card); padding: 6px; border-radius: 12px; border: 1px solid var(--line); width: min(100%, 480px); aspect-ratio: 1 / 1; box-sizing: border-box; }
.ws-cell { width: 100%; height: 100%; aspect-ratio: 1 / 1; min-width: 0; min-height: 0; display: grid; place-items: center; font-weight: 800; font-size: clamp(11px, 3.2vw, 18px); border-radius: 5px; cursor: pointer; box-sizing: border-box; }
.ws-cell.sel { background: var(--accent); color: #fff; }
.ws-cell.found { color: #fff; }
.ws-list { display: flex; flex-wrap: wrap; gap: 6px; }
.ws-word { padding: 5px 10px; border-radius: 8px; background: var(--card2); font-weight: 800; font-size: 14px; letter-spacing: .5px; }
.ws-word.found { text-decoration: line-through; opacity: .55; }
@media (max-width: 800px) { .ws-wrap { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Tiles (anagram, bir kelime) ---------- */
.tiles { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 12px 0; }
.tile {
  width: 54px; height: 60px; border-radius: 10px; display: grid; place-items: center; font-size: 28px; font-weight: 900;
  background: linear-gradient(180deg, #fde68a, #f59e0b); color: #4a2b00; border: none; box-shadow: 0 4px 0 #b45309; position: relative;
}
.tile.used { opacity: .25; transform: translateY(3px); box-shadow: none; }
.tile.joker { background: linear-gradient(180deg, #c4b5fd, #7c5cff); color: #fff; box-shadow: 0 4px 0 #4c1d95; }
.tile.slot { background: transparent; border: 2px dashed var(--line); box-shadow: none; color: var(--text); }
.tile.slot.filled { border-style: solid; border-color: var(--accent); background: var(--card2); }
.big-timer { font-size: 42px; font-weight: 900; text-align: center; }
.answer-input { width: 100%; max-width: 420px; display: block; margin: 8px auto; padding: 14px; font-size: 22px; font-weight: 800; text-align: center; border-radius: 12px; border: 2px solid var(--line); background: var(--bg2); color: var(--text); text-transform: uppercase; letter-spacing: 2px; outline: none; }
.answer-input:focus { border-color: var(--accent); }
.result-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-height: 220px; overflow: auto; padding: 4px; }
.chip { padding: 4px 10px; border-radius: 8px; background: var(--card2); font-weight: 800; font-size: 13px; text-transform: uppercase; }
.chip.good { background: var(--green); color: #fff; }
.chip.bad { background: var(--red); color: #fff; }
.chip.long { background: var(--accent); color: #fff; }

/* ---------- Wordscapes ---------- */
.wsc-slots { display: flex; flex-wrap: wrap; gap: 10px 18px; justify-content: center; margin-bottom: 18px; }
.wsc-word { display: flex; gap: 3px; }
.wsc-box { width: 32px; height: 34px; border-radius: 6px; background: var(--card2); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 900; text-transform: uppercase; font-size: 18px; }
.wsc-box.open { background: var(--accent); color: #fff; border-color: transparent; }
.wsc-box.hint { background: var(--accent2); color: #062b33; }
.wsc-current { min-height: 48px; text-align: center; font-size: 30px; font-weight: 900; letter-spacing: 4px; text-transform: uppercase; }
.wheel { position: relative; width: 270px; height: 270px; margin: 0 auto; border-radius: 50%; background: var(--card); border: 1px solid var(--line); touch-action: none; user-select: none; box-shadow: var(--shadow); }
.wheel svg { position: absolute; inset: 0; pointer-events: none; }
.wheel-letter { position: absolute; width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; font-size: 28px; font-weight: 900; background: var(--card2); border: 2px solid var(--line); transform: translate(-50%, -50%); cursor: pointer; }
.wheel-letter.on { background: var(--accent); color: #fff; border-color: transparent; }

/* ---------- Spelling bee ---------- */
.bee-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
.hive { position: relative; width: 280px; height: 290px; margin: 10px auto; }
.hex { position: absolute; width: 90px; height: 80px; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); background: var(--card2); color: var(--text); border: none; font-size: 30px; font-weight: 900; display: grid; place-items: center; text-transform: uppercase; transition: transform .1s; }
.hex:active { transform: scale(.92); }
.hex.center { background: var(--yellow); color: #3b2a00; }
.bee-input { text-align: center; font-size: 30px; font-weight: 900; min-height: 44px; letter-spacing: 2px; text-transform: uppercase; }
.bee-input .c { color: var(--yellow); }
.rank-bar { display: flex; align-items: center; gap: 4px; margin: 8px 0 12px; }
.rank-bar .dot { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.rank-bar .dot.on { background: var(--yellow); }
.found-list { columns: 2; font-weight: 700; text-transform: capitalize; font-size: 15px; max-height: 360px; overflow: auto; }
.found-list div.pg { color: var(--yellow); }
@media (max-width: 800px) { .bee-wrap { grid-template-columns: 1fr; } }

/* ---------- Boggle ---------- */
.bg-wrap { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: start; }
.bg-grid { display: grid; gap: 8px; touch-action: none; user-select: none; padding: 10px; background: var(--card); border-radius: 16px; border: 1px solid var(--line); width: min(100%, 340px); aspect-ratio: 1 / 1; margin: 0 auto; box-sizing: border-box; }
.bg-cell { width: 100%; height: 100%; aspect-ratio: 1 / 1; min-width: 0; min-height: 0; border-radius: 12px; display: grid; place-items: center; font-size: clamp(18px, 5.5vw, 28px); font-weight: 900; background: linear-gradient(180deg, #f8fafc, #cbd5e1); color: #1e293b; box-shadow: 0 4px 0 #64748b; cursor: pointer; text-transform: uppercase; box-sizing: border-box; }
.bg-cell.sel { background: linear-gradient(180deg, #a78bfa, #7c3aed); color: #fff; box-shadow: 0 4px 0 #4c1d95; }
@media (max-width: 760px) { .bg-wrap { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Chain ---------- */
.chain-log { display: flex; flex-direction: column; gap: 8px; max-height: 380px; overflow: auto; padding: 6px; }
.chain-msg { max-width: 75%; padding: 10px 14px; border-radius: 14px; font-weight: 800; font-size: 18px; text-transform: uppercase; }
.chain-msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chain-msg.cpu { align-self: flex-start; background: var(--card2); border-bottom-left-radius: 4px; }
.chain-msg.sys { align-self: center; background: transparent; color: var(--muted); font-size: 13px; text-transform: none; }
.chain-msg .last { color: var(--yellow); }
.timer-bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 8px 0; }
.timer-bar > div { height: 100%; background: linear-gradient(90deg, var(--green), var(--yellow), var(--red)); transition: width .2s linear; }

/* ---------- Toast & modal ---------- */
.toast { position: fixed; top: 76px; left: 50%; transform: translateX(-50%) translateY(-20px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 800; opacity: 0; pointer-events: none; transition: all .2s; z-index: 200; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.modal { position: fixed; inset: 0; background: rgba(5,7,20,.65); display: grid; place-items: center; z-index: 150; padding: 16px; }
.modal.hidden { display: none; }
.modal-card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px; width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.modal-card h2 { margin-top: 0; padding-right: 24px; }
.modal-close { position: absolute; top: 12px; right: 12px; background: transparent; border: none; color: var(--muted); font-size: 20px; }
.modal-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; margin: 12px 0; }
.modal-stats b { display: block; font-size: clamp(15px, 3.5vw, 22px); word-break: break-word; }
.modal-stats span { font-size: 11px; color: var(--muted); }
.how ul { padding-left: 18px; line-height: 1.6; }
footer.foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 30px; }

/* ---------- Mobil & Küçük Ekran Duyarlılığı ---------- */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

@media (max-width: 768px) {
  .topbar {
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .brand {
    min-width: 0;
    flex: 1;
    gap: 8px;
  }
  .brand-text {
    font-size: 15px;
    line-height: 1.15;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .bank-badge {
    display: none;
  }
  .icon-btn {
    width: 34px;
    height: 34px;
    font-size: 16px;
    flex-shrink: 0;
  }
  main {
    padding: 12px 10px 44px;
  }
  .hero {
    padding: 12px 6px 18px;
  }
  .hero h1 {
    font-size: clamp(22px, 6vw, 30px);
  }
  .hero p {
    font-size: 13.5px;
  }
  .stats-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 14px;
  }
  .stat-pill {
    min-width: 0;
    padding: 8px 10px;
  }
  .stat-pill b {
    font-size: 17px;
  }
  .game-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .game-card {
    padding: 15px;
  }
  .game-card .gc-tag {
    max-width: calc(100% - 86px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .game-head {
    gap: 8px;
    margin-bottom: 10px;
  }
  .game-head .left {
    width: 100%;
    justify-content: space-between;
  }
  .game-head h2 {
    font-size: 19px;
  }
  .toolbar {
    width: 100%;
    gap: 6px;
    justify-content: flex-start;
  }
  .btn {
    padding: 8px 11px;
    font-size: 12.5px;
  }
  .panel {
    padding: 12px 10px;
  }
  .ws-grid {
    max-width: 100%;
    overflow-x: auto;
  }
  .modal {
    padding: 10px;
  }
  .modal-card {
    padding: 16px 14px;
    max-height: 92vh;
  }
  .modal-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .brand-text span {
    display: none !important;
  }
  .game-card-body {
    padding: 12px 8px;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
  }
  .kb {
    gap: 5px;
    margin-top: 12px;
    width: 100%;
    max-width: 100%;
  }
  .kb-row {
    gap: 2.5px;
    width: 100%;
  }
  .kb-key {
    flex: 1 1 0;
    min-width: 0;
    height: 42px;
    font-size: 13px;
    border-radius: 6px;
    padding: 0 1px;
  }
  .kb-key.wide {
    font-size: 10.5px;
  }
  .wd-tile {
    width: clamp(34px, 10.5vw, 48px);
    height: clamp(38px, 11.5vw, 52px);
    font-size: clamp(18px, 5vw, 24px);
  }
  .wsc-box {
    width: clamp(24px, 7.2vw, 32px);
    height: clamp(26px, 7.8vw, 34px);
    font-size: 15px;
  }
  .hm-letter {
    width: clamp(26px, 7.5vw, 38px);
    height: 40px;
    font-size: 22px;
  }
  .tile {
    width: clamp(36px, 11vw, 44px);
    height: clamp(42px, 12.5vw, 50px);
    font-size: 20px;
  }
  .bg-cell {
    width: 100%;
    height: 100%;
    font-size: clamp(16px, 5vw, 24px);
  }
  .wheel {
    width: min(250px, 78vw);
    height: min(250px, 78vw);
  }
  .hive {
    transform: scale(0.9);
    transform-origin: top center;
  }
  .ws-grid,
  .cw-grid,
  .scr-board {
    max-width: 100%;
  }
}
