:root {
  --bg: #0b0a09;
  --panel: rgba(20, 17, 14, .92);
  --panel-2: rgba(32, 27, 21, .95);
  --line: #3b3226;
  --line-2: #5a4a33;
  --text: #e8dfcf;
  --muted: #a3967f;
  --gold: #d9a441;
  --gold-2: #f3cf7a;
  --karus: #c0392b;
  --elmo: #2e86de;
  --ok: #5cb85c;
  --bad: #d9534f;
  --radius: 8px;
  --font: 'Inter', system-ui, sans-serif;
  --title: 'Cinzel', Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg) url('../img/bg.jpg') center top / cover fixed no-repeat;
  color: var(--text); font: 14px/1.45 var(--font);
}
body::before { content: ''; position: fixed; inset: 0; background: linear-gradient(180deg, rgba(8,7,6,.55), rgba(8,7,6,.92) 60%); z-index: -1; }
a { color: var(--gold-2); text-decoration: none; }
h1, h2, h3 { font-family: var(--title); color: var(--gold-2); letter-spacing: .04em; margin: 0 0 .5em; }
h1 { font-size: 26px; } h2 { font-size: 19px; } h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* üst çubuk */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: rgba(10, 9, 8, .94); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); }
.brand { font-family: var(--title); font-weight: 800; font-size: 20px; color: var(--gold-2); letter-spacing: .08em; white-space: nowrap; }
.brand span { color: var(--gold); margin: 0 2px; }
#topbar-mid { flex: 1; min-width: 0; }
#topbar-user { display: flex; gap: 8px; align-items: center; white-space: nowrap; }

main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }
.loading { padding: 60px; text-align: center; color: var(--muted); }

/* düğmeler & form */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 6px;
  border: 1px solid var(--line-2); background: linear-gradient(#3a2f22, #241d15); color: var(--gold-2); font: 600 13px var(--font);
  cursor: pointer; transition: filter .15s, transform .05s; }
.btn:hover:not(:disabled) { filter: brightness(1.25); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(#c98f2c, #8a5d14); color: #1b1309; border-color: #e3b24d; }
.btn.ghost { background: transparent; }
.btn.danger { background: linear-gradient(#7a2620, #4d1612); color: #ffd9d3; border-color: #a6392f; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
input, select, textarea { background: #0f0d0b; color: var(--text); border: 1px solid var(--line-2); border-radius: 6px;
  padding: 8px 10px; font: 14px var(--font); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--gold); }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel + .panel { margin-top: 16px; }
.center-box { max-width: 420px; margin: 6vh auto 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 10px 14px; font: 600 14px var(--font); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--gold-2); border-bottom-color: var(--gold); }

/* toast */
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 100; max-width: calc(100vw - 32px); }
.toast { background: var(--panel-2); border: 1px solid var(--line-2); border-left: 4px solid var(--gold); padding: 10px 14px; border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,.5); animation: tin .2s ease-out; }
.toast.err { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

/* sunucu listesi */
.servers { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.server { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.server.mine { border-color: var(--gold); }
.server h2 { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: #241d15; border: 1px solid var(--line-2); color: var(--muted); }
.chip b { color: var(--gold-2); }
.nation-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: #222; }
.nation-bar i { display: block; }

/* karakter oluşturma */
.nations { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.nation-card { position: relative; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; min-height: 240px;
  background: center / cover; display: flex; align-items: flex-end; transition: transform .15s, border-color .15s; }
.nation-card:hover { transform: translateY(-2px); }
.nation-card.karus { border-color: #6d2019; } .nation-card.karus:hover { border-color: var(--karus); }
.nation-card.elmo { border-color: #1b4d80; } .nation-card.elmo:hover { border-color: var(--elmo); }
.nation-card .cap { width: 100%; padding: 16px; background: linear-gradient(transparent, rgba(0,0,0,.92)); }
.nation-card h2 { font-size: 26px; margin: 0; }
.create { display: grid; grid-template-columns: 260px 1fr 300px; gap: 16px; align-items: start; }
.pick-list { display: grid; gap: 6px; }
.pick { text-align: left; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); cursor: pointer; font: 500 14px var(--font); }
.pick.on { border-color: var(--gold); color: var(--gold-2); background: #2c2417; }
.pick:disabled { opacity: .4; cursor: not-allowed; }
.preview { position: relative; height: 520px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden;
  background: radial-gradient(ellipse at 50% 85%, #3a2c1c 0%, #120f0c 60%, #080706 100%); }
.preview canvas { width: 100%; height: 100%; display: block; }
.preview .hint { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: 12px; color: var(--muted); pointer-events: none; }
.preview .look { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.stat { display: grid; grid-template-columns: 50px 1fr auto auto auto; gap: 6px; align-items: center; margin: 4px 0; }
.stat b { color: var(--gold-2); text-align: right; min-width: 28px; }
.stat .main { color: var(--gold); }

/* oyun */
.game { display: grid; grid-template-columns: 220px 1fr; gap: 16px; }
.side { display: grid; gap: 12px; align-content: start; }
.side nav { display: grid; gap: 4px; }
.side nav button { text-align: left; padding: 10px 12px; border-radius: 6px; border: 1px solid transparent; background: none; color: var(--text); font: 600 14px var(--font); cursor: pointer; }
.side nav button.on { background: #2c2417; border-color: var(--line-2); color: var(--gold-2); }
.res-bar { display: flex; gap: 14px; flex-wrap: wrap; font-weight: 600; justify-content: center; }
.res-bar span { display: inline-flex; gap: 5px; align-items: center; white-space: nowrap; }
.res-bar small { color: var(--muted); font-weight: 400; }
.buildings { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.bcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.bcard.main { border-color: var(--gold); grid-column: 1 / -1; }
.bcard.locked { opacity: .55; }
.bhead { display: flex; gap: 10px; align-items: center; }
.bicon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; background: #241d15; border: 1px solid var(--line-2); flex: none; overflow: hidden; }
.bicon img { width: 100%; height: 100%; object-fit: cover; }
.lvl { font: 800 13px var(--title); color: var(--gold); }
.cost { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; }
.cost .no { color: var(--bad); }
.reqs { font-size: 12px; color: var(--bad); }
.reqs .ok { color: var(--ok); }
.queue-item { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); }
.progress { height: 6px; background: #241d15; border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, #8a5d14, var(--gold-2)); }

/* dünya haritası */
.map-wrap { position: relative; height: calc(100vh - 170px); min-height: 420px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #0d1a24; }
.map-wrap canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.map-wrap canvas.drag { cursor: grabbing; }
.map-tip { position: absolute; pointer-events: none; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 8px 10px; font-size: 12px; display: none; min-width: 160px; }
.map-tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.map-info { position: absolute; left: 10px; bottom: 10px; max-width: 300px; }

/* admin */
.admin { display: grid; grid-template-columns: 230px 1fr; gap: 16px; }
.admin-nav h3 { font-size: 12px; color: var(--muted); margin: 14px 0 4px; font-family: var(--font); text-transform: uppercase; letter-spacing: .08em; }
.admin-nav button { display: block; width: 100%; text-align: left; padding: 7px 10px; border-radius: 5px; border: 0; background: none; color: var(--text); cursor: pointer; font: 500 13px var(--font); }
.admin-nav button.on { background: #2c2417; color: var(--gold-2); }
.grid-wrap { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--line); border-radius: 6px; }
table.grid { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 13px; }
table.grid th { position: sticky; top: 0; background: #1d1813; color: var(--gold-2); text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line-2); white-space: nowrap; font-weight: 600; z-index: 1; }
table.grid td { border-bottom: 1px solid #241e17; padding: 2px 4px; vertical-align: middle; }
table.grid tr:hover td { background: #1a1511; }
table.grid input, table.grid select { padding: 4px 6px; font-size: 13px; border-color: transparent; background: transparent; min-width: 70px; }
table.grid input:hover, table.grid select:hover { border-color: var(--line); }
table.grid input:focus, table.grid select:focus { background: #0f0d0b; }
table.grid td.saved input, table.grid td.saved select { background: rgba(92,184,92,.18); }
table.grid td.err input, table.grid td.err select { background: rgba(217,83,79,.25); }
table.grid input[type=checkbox] { width: auto; min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 12px; }
fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 4px 12px 12px; margin: 12px 0; }
legend { color: var(--gold-2); font-weight: 600; padding: 0 6px; }

@media (max-width: 960px) {
  .create { grid-template-columns: 1fr; }
  .preview { height: 380px; }
  .game, .admin { grid-template-columns: 1fr; }
  .side nav { grid-auto-flow: column; overflow-x: auto; }
  .nations { grid-template-columns: 1fr; }
  #topbar-mid { display: none; }
}
@media (max-width: 520px) {
  .topbar { gap: 8px; padding: 8px 12px; }
  main { padding: 12px 12px 40px; }
}
