/* BrightBlocks yönetim paneli — harici bağımlılık yok */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --border: #e3e7f0;
  --text: #1d2433;
  --muted: #667085;
  --primary: #5b5bf0;
  --primary-ink: #ffffff;
  --primary-soft: #ececfe;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --success: #2f9e6b;
  --success-soft: #e6f6ee;
  --warning: #d98a00;
  --warning-soft: #fff4dc;
  --red: #ff6b6b;
  --yellow: #ffc93c;
  --green: #4cc38a;
  --blue: #5b7cfa;
  --pink: #ff7eb6;
  --theme-meadow: #4cc38a;
  --theme-snow: #7cc4f5;
  --theme-desert: #e9b45c;
  --theme-candy: #ff7eb6;
  --theme-forest: #2e7d4f;
  --theme-city: #64748b;
  --theme-park: #c14fe0;
  --theme-airport: #1e88e5;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .06);
  --radius: 14px;
  --radius-sm: 9px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151d;
    --surface: #1a1f2b;
    --surface-2: #202636;
    --border: #2d3446;
    --text: #e8ecf5;
    --muted: #98a2b8;
    --primary: #8585ff;
    --primary-ink: #0f1020;
    --primary-soft: #2a2b55;
    --danger: #ff6b70;
    --danger-soft: #3a2024;
    --success: #4fd197;
    --success-soft: #19352a;
    --warning: #f2b544;
    --warning-soft: #3a2f17;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85em; }
.nowrap { white-space: nowrap; }

/* ---------- marka (renkli bloklar) */
.brand { display: grid; grid-template-columns: repeat(2, 12px); gap: 3px; flex: none; }
.brand .blk { width: 12px; height: 12px; border-radius: 3px; }
.brand-lg { grid-template-columns: repeat(2, 22px); gap: 5px; margin: 0 auto 12px; width: max-content; }
.brand-lg .blk { width: 22px; height: 22px; border-radius: 6px; }
.b1 { background: var(--red); } .b2 { background: var(--yellow); }
.b3 { background: var(--green); } .b4 { background: var(--blue); }

/* ---------- giriş */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 28px; box-shadow: var(--shadow); text-align: center;
}
.login-card .field { text-align: left; margin-top: 18px; }
.login-card .btn { margin-top: 14px; }

/* ---------- üst bar + sekmeler */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 12px 16px 6px; display: flex; align-items: center; gap: 12px; }
.topbar .title { display: flex; flex-direction: column; line-height: 1.15; margin-right: auto; }
.topbar .title .muted { font-size: .8rem; }
.tabs {
  max-width: 1240px; margin: 0 auto; padding: 0 12px; display: flex; gap: 2px;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 600;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }

.main { max-width: 1240px; margin: 0 auto; padding: 20px 16px 60px; outline: none; }
.section-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { margin: 0 auto 0 0; }

/* ---------- kartlar */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 860px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { position: relative; overflow: hidden; padding: 16px 18px; }
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--accent, var(--primary)); }
.stat .value { font-size: 1.9rem; font-weight: 750; letter-spacing: -.02em; }
.stat .label { color: var(--muted); font-size: .88rem; }

/* ---------- seviye grafiği */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 220px; padding: 8px 4px 0; overflow-x: auto; }
.chart .col { flex: 1 0 34px; max-width: 70px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.chart .bar-area { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.chart .bar {
  width: 100%; min-height: 3px; border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, var(--primary), var(--blue)); transition: height .4s ease;
}
.chart .col:nth-child(4n+2) .bar { background: linear-gradient(180deg, var(--green), #2fa874); }
.chart .col:nth-child(4n+3) .bar { background: linear-gradient(180deg, var(--yellow), #f0a92a); }
.chart .col:nth-child(4n+4) .bar { background: linear-gradient(180deg, var(--pink), #f0569b); }
.chart .count { font-size: .8rem; font-weight: 700; margin-bottom: 4px; }
.chart .lvl { font-size: .78rem; color: var(--muted); margin-top: 6px; white-space: nowrap; }

/* ---------- form */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-weight: 600; font-size: .9rem; }
.field .help { color: var(--muted); font-size: .8rem; font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px 16px; }
.form-grid .span-all { grid-column: 1 / -1; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px; width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; padding: 0; accent-color: var(--primary); }
input[type="range"] { padding: 0; accent-color: var(--primary); background: transparent; border: 0; }
.invalid { outline: 2px solid var(--danger) !important; }
.form-error { color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-sm); padding: 8px 10px; margin: 10px 0 0; font-size: .9rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1 1 180px; }
.range-row { display: flex; gap: 10px; align-items: center; }
.range-row output { min-width: 2.6em; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check .txt { display: flex; flex-direction: column; }
.check .txt b { font-weight: 600; font-size: .92rem; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0 0 16px; }
legend { font-weight: 700; padding: 0 6px; }
details summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 3px; background: var(--surface-2); }
.seg label { padding: 5px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--muted); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--primary); color: var(--primary-ink); }

/* ---------- düğmeler */
.btn {
  font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 8px 14px; cursor: pointer; background: var(--surface-2); color: var(--text); border-color: var(--border);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { padding: 5px 10px; font-size: .85rem; }
.btn-block { width: 100%; }

/* ---------- tablo */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sorted { color: var(--primary); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
tr.is-banned td { opacity: .6; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td select { min-width: 120px; padding: 5px 8px; }
td input.note { min-width: 140px; padding: 5px 8px; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--text); font-weight: 600; cursor: pointer; text-align: left; }
.linkish:hover { color: var(--primary); text-decoration: underline; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type="search"] { flex: 1 1 220px; }
.toolbar select { width: auto; }
.bulkbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 12px;
  background: var(--primary-soft); border-radius: var(--radius); font-weight: 600;
}
.bulkbar select { width: auto; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }

/* anahtar (toggle) */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider { position: absolute; inset: 0; background: var(--border); border-radius: 999px; cursor: pointer; transition: background .2s; }
.switch .slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; }
.switch input:checked + .slider { background: var(--danger); }
.switch input:focus-visible + .slider { outline: 2px solid var(--primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch.good input:checked + .slider { background: var(--success); }

/* rozetler */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-coin { background: var(--warning-soft); color: var(--text); border-color: var(--yellow); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

/* ---------- çevrimiçi durumu */
.dot-online { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.badge-online { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-online .dot { width: 8px; height: 8px; box-shadow: none; }
.who { display: inline-flex; align-items: center; gap: 8px; }
.name-cell { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; }
.online-card .card-head { display: flex; align-items: baseline; gap: 6px 12px; flex-wrap: wrap; margin-bottom: 10px; }
.online-card .card-head h3 { margin: 0 auto 0 0; }
.online-card .empty { padding: 18px 12px; }
.online-card .empty p { margin: 0 0 6px; }
@media (prefers-reduced-motion: no-preference) {
  .who .dot-online { animation: online-pulse 2s ease-in-out infinite; }
}
@keyframes online-pulse { 50% { box-shadow: 0 0 0 6px transparent; } }

/* ---------- seçenek kartları (mesaj teslim şekli) */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.choice {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
}
.choice input { margin-top: 2px; flex: none; }
.choice .txt { display: flex; flex-direction: column; gap: 2px; }
.choice .txt b { font-weight: 600; font-size: .92rem; }
.choice .txt small { font-size: .8rem; }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice:has(input:focus-visible) { outline: 2px solid var(--primary); }

/* ---------- ada kartları */
.islands { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.card.island { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.island .band { height: 10px; background: var(--theme, var(--primary)); }
.island .body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.island .head { display: flex; align-items: flex-start; gap: 8px; }
.island .head h3 { margin: 0; }
.island .head .sub { font-size: .8rem; }
.island .players { margin-left: auto; text-align: right; }
.island .players b { font-size: 1.4rem; display: block; line-height: 1; }
.island .badges { display: flex; gap: 6px; flex-wrap: wrap; }
.params { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 14px; font-size: .86rem; margin: 0; }
.params div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed var(--border); padding: 2px 0; }
.params dt { color: var(--muted); }
.params dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.island .desc { font-size: .88rem; color: var(--muted); margin: 0; }
.island .btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.theme-meadow { --theme: var(--theme-meadow); } .theme-snow { --theme: var(--theme-snow); }
.theme-desert { --theme: var(--theme-desert); } .theme-candy { --theme: var(--theme-candy); }
.theme-forest { --theme: var(--theme-forest); } .theme-city { --theme: var(--theme-city); }
.theme-park { --theme: var(--theme-park); } .theme-airport { --theme: var(--theme-airport); }
/* takımadada olmayan ada: soluk (üzerine gelince/odakta normal) */
.card.island.is-disabled { opacity: .62; }
.card.island.is-disabled .band { background: repeating-linear-gradient(135deg, var(--theme) 0 10px, var(--border) 10px 20px); }
.card.island.is-disabled:hover, .card.island.is-disabled:focus-within { opacity: 1; }

/* ---------- oyuncu seçici */
.picker { position: relative; }
.picker .results {
  position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; z-index: 5; max-height: 240px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.picker .results button { display: flex; width: 100%; gap: 8px; justify-content: space-between; padding: 8px 10px; border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.picker .results button:hover, .picker .results button:focus { background: var(--primary-soft); }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 5px 6px 5px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.chip button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 4px; }

/* ---------- mesaj önizleme + simge seçici */
.icon-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-picker label { cursor: pointer; }
.icon-picker input { position: absolute; opacity: 0; pointer-events: none; }
.icon-picker .ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; border: 2px solid var(--border); background: var(--surface-2); }
.icon-picker label:has(input:checked) .ico { border-color: var(--primary); background: var(--primary-soft); }
.icon-picker label:has(input:focus-visible) .ico { outline: 2px solid var(--primary); }
.ico svg { width: 26px; height: 26px; }
.ico-info { color: var(--blue); } .ico-star { color: #f0a92a; } .ico-gift { color: var(--pink); }
.ico-party { color: var(--green); } .ico-warning { color: var(--warning); }

.preview-stage {
  border-radius: var(--radius); padding: 28px 16px; display: grid; place-items: center; min-height: 260px;
  background: linear-gradient(160deg, #8fd3ff 0%, #b8f0c9 60%, #ffe39c 100%);
}
.popup {
  width: 100%; max-width: 320px; background: #fff; color: #263044; border-radius: 22px; padding: 22px 20px 18px;
  text-align: center; box-shadow: 0 10px 30px rgba(30, 40, 80, .25); border: 4px solid #ffd45c;
}
.popup .ico { width: 64px; height: 64px; margin: -54px auto 8px; border-radius: 50%; background: #fff; border: 4px solid #ffd45c; display: grid; place-items: center; }
.popup .ico svg { width: 36px; height: 36px; }
.popup h3 { font-size: 1.3rem; margin: 0 0 6px; overflow-wrap: anywhere; }
.popup p { margin: 0 0 14px; white-space: pre-wrap; overflow-wrap: anywhere; color: #4a5672; }
.popup .ok { display: inline-block; background: #4cc38a; color: #fff; font-weight: 800; border-radius: 999px; padding: 8px 26px; box-shadow: 0 4px 0 #2f9e6b; }

/* ---------- modal */
.modal {
  border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--text);
  width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.modal::backdrop { background: rgba(15, 20, 35, .5); }
.modal form, .modal .modal-body { padding: 20px; }
.modal .modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal .modal-head h2 { margin: 0 auto 0 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: .92rem; margin: 0 0 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- bildirimler */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: calc(100vw - 32px); }
.toast {
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow);
  font-weight: 600; animation: toast-in .2s ease-out; max-width: 380px;
}
.toast.ok { background: var(--success); color: #fff; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

.loading { padding: 40px; text-align: center; color: var(--muted); }

@media (max-width: 600px) {
  .main { padding: 14px 12px 50px; }
  .card { padding: 14px; }
  .stat .value { font-size: 1.5rem; }
  .params { grid-template-columns: 1fr; }
  .modal form, .modal .modal-body { padding: 16px; }
  .toasts { left: 16px; right: 16px; }
}
