:root {
  --bg: #0f1a33;
  --bg2: #14213d;
  --panel: #1b2a4a;
  --panel2: #22345a;
  --line: #2f4470;
  --text: #eef2fb;
  --muted: #9fb0d0;
  --accent: #ffb703;
  --accent2: #fb8500;
  --ok: #4ade80;
  --bad: #f87171;
  --board: #2b5b4f;
  --board-cell: #234c42;
  --card: #fbf8f1;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 20% -10%, #1f3260 0%, var(--bg) 60%) fixed;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
h1, h2, h3 { margin: 0 0 .6rem; }
h2 small, h3 small { color: var(--muted); font-weight: 400; font-size: .8em; }
.hint { color: var(--muted); font-size: .85rem; margin: .6rem 0 0; }
.center { text-align: center; }
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap { gap: .5rem; }
.wrap { flex-wrap: wrap; }

/* ---------- butonlar & girdiler ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  padding: .6rem 1rem; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
  transition: transform .05s, background .15s, opacity .15s;
}
.btn:hover:not(:disabled) { background: #2b416c; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--accent), var(--accent2)); color: #1a1205; border-color: transparent; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.07); background: linear-gradient(180deg, var(--accent), var(--accent2)); }
.btn.ghost { background: transparent; }
.btn.danger { background: #7f1d1d; border-color: #b91c1c; }
.btn.small { padding: .4rem .7rem; font-size: .85rem; }
.btn.big { width: 100%; padding: .85rem 1rem; font-size: 1.05rem; margin-top: .8rem; }
.btn.link { background: none; border: none; color: var(--muted); text-decoration: underline; margin-top: 1rem; }
input, select {
  font: inherit; color: var(--text); background: #0d1730; border: 1px solid var(--line);
  border-radius: 10px; padding: .6rem .75rem; outline: none; min-width: 0;
}
input:focus, select:focus { border-color: var(--accent); }

/* ---------- genel yerleşim ---------- */
.screen { min-height: 100%; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .6rem 1rem; background: rgba(10, 18, 38, .7); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; backdrop-filter: blur(6px);
}
.brand { font-weight: 800; letter-spacing: .5px; color: var(--accent); }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: center; }
.chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: .2rem .6rem; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.chip b { color: var(--text); }
.chip.timer { color: #1a1205; background: var(--accent); border-color: transparent; font-weight: 700; }
.chip.timer.low { background: var(--bad); color: white; }

/* ---------- giriş ---------- */
.home { display: grid; place-items: center; padding: 1.5rem 1rem; }
.home-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 1.6rem; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.home-card h1 { font-size: 2.2rem; letter-spacing: 1px; margin-top: .4rem; }
.tagline { color: var(--muted); margin: 0 0 1.2rem; }
.logo { display: flex; justify-content: center; gap: .5rem; }
.tile-demo { width: 56px; height: 56px; }
.field { display: flex; flex-direction: column; text-align: left; gap: .3rem; font-size: .85rem; color: var(--muted); }
.field input { font-size: 1rem; }
.or { display: flex; align-items: center; gap: .6rem; color: var(--muted); margin: 1rem 0; font-size: .8rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.join-row { display: flex; gap: .5rem; }
.join-row input { flex: 1; text-transform: uppercase; letter-spacing: 4px; text-align: center; font-weight: 700; }

/* ---------- lobi ---------- */
.lobby-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: 1rem; max-width: 1000px; margin: 0 auto; }
.chat-panel { max-width: 968px; margin: 0 auto 1rem; }
@media (max-width: 760px) { .lobby-grid { grid-template-columns: 1fr; } .chat-panel { margin: 0 1rem 1rem; } }
.room-code b { font-size: 1.3rem; letter-spacing: 3px; color: var(--accent); }
.plist { list-style: none; margin: 0 0 .8rem; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.plist li { display: flex; align-items: center; gap: .5rem; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem; }
.plist .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: .7rem; padding: .1rem .45rem; border-radius: 999px; background: #0d1730; color: var(--muted); border: 1px solid var(--line); }
.badge.host { color: var(--accent); border-color: var(--accent); }
.badge.off { color: var(--bad); border-color: var(--bad); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; }
.dot.off { background: var(--bad); }
.cfg { display: grid; grid-template-columns: 1fr auto; gap: .55rem .8rem; align-items: center; font-size: .9rem; }
.cfg label { color: var(--muted); }
.cfg input[type=number] { width: 80px; text-align: center; }
.cfg select { width: 140px; }
.cfg .sep { grid-column: 1 / -1; border-top: 1px solid var(--line); margin: .2rem 0; color: var(--accent); font-size: .78rem; padding-top: .5rem; text-transform: uppercase; letter-spacing: .5px; }
.cfg input:disabled, .cfg select:disabled { opacity: .75; }
.cfg-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }

/* ---------- oyun ---------- */
.game-grid {
  display: grid; gap: 1rem; padding: 1rem; max-width: 1400px; margin: 0 auto;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-areas: "board side" "hand side";
}
.board-area { grid-area: board; display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.side { grid-area: side; display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.hand-area { grid-area: hand; }
@media (min-width: 1250px) {
  .game-grid { grid-template-columns: 260px minmax(0, 1fr) 330px; grid-template-areas: "hand board side"; max-width: 1600px; }
  .hand-area { align-self: start; position: sticky; top: 4.2rem; }
  .hand { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 980px) {
  .game-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "board" "action" "hand" "scores" "log"; padding: .6rem; gap: .6rem; }
  .side { display: contents; }
  .side .action { grid-area: action; position: sticky; bottom: .5rem; z-index: 4; box-shadow: 0 -6px 24px rgba(0,0,0,.4); }
  .side .scores-panel { grid-area: scores; }
  .side .log-panel { grid-area: log; }
  .bar .brand { display: none; }
}

.turn-banner { font-weight: 700; padding: .45rem 1rem; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); text-align: center; }
.turn-banner.mine { background: linear-gradient(180deg, var(--accent), var(--accent2)); color: #1a1205; border-color: transparent; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,183,3,.5); } 50% { box-shadow: 0 0 0 8px rgba(255,183,3,0); } }

.board {
  --gap: clamp(1px, .35vw, 4px);
  width: min(100%, calc(100vh - 150px), 820px);
  min-width: 280px;
  aspect-ratio: 1;
  display: grid; grid-template-columns: repeat(11, 1fr); grid-template-rows: repeat(11, 1fr);
  gap: var(--gap); padding: var(--gap);
  background: var(--board); border-radius: 14px;
  box-shadow: inset 0 0 0 3px #1c3f36, 0 18px 50px rgba(0,0,0,.4);
  container-type: inline-size;
  user-select: none; touch-action: manipulation;
}
@media (max-width: 980px) { .board { width: 100%; min-width: 0; } }
.cell { position: relative; border-radius: 6px; background: var(--board-cell); cursor: pointer; }
.cell.center-mark::after { content: ""; position: absolute; inset: 30%; border-radius: 50%; border: 1px dashed rgba(255,255,255,.18); }
.cell.reach { background: rgba(74, 222, 128, .28); box-shadow: inset 0 0 0 2px var(--ok); }
.cell.reach::before { content: ""; position: absolute; inset: 38%; border-radius: 50%; background: var(--ok); opacity: .8; }
.cell.vacated { background: rgba(255,255,255,.08); }

.tile {
  position: absolute; inset: 0; border-radius: 9%;
  box-shadow: 0 1px 2px rgba(0,0,0,.35);
  transition: transform .12s, box-shadow .12s;
}
.tile svg, .hcard svg, .tile-demo svg { display: block; width: 100%; height: 100%; }
.tile.mine { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px #111; }
.tile.mine::after {
  content: ""; position: absolute; top: -3px; right: -3px; width: 26%; height: 26%;
  border-radius: 50%; background: #fff; border: 2px solid #111; box-sizing: border-box;
}
.tile.sel { transform: scale(.9); box-shadow: 0 0 0 3px #fff, 0 0 0 6px #22d3ee; z-index: 2; }
.tile.sel.ok { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ok); }
.tile.sel.bad { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--bad); }
.tile.hl { animation: hl 1s ease-in-out infinite; z-index: 3; }
@keyframes hl { 50% { transform: scale(1.12); box-shadow: 0 0 0 4px var(--accent); } }
.tile.moved { animation: moved .6s ease-out; }
@keyframes moved { from { box-shadow: 0 0 0 6px #22d3ee; } }
.cell.claimed { animation: claimed 1.4s ease-out; }
.tile.hl::after, .tile.sel::after { display: none; }
@keyframes claimed { from { background: var(--accent); } }

/* el kartları ve demo */
.hand { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: .45rem; }
.hcard { position: relative; aspect-ratio: 1; border-radius: 10%; cursor: pointer; outline: 3px solid transparent; outline-offset: 2px; transition: transform .1s; }
.hcard.on-sel { outline-color: #22d3ee; }
.hcard.swap-mode { outline: 3px dashed var(--accent); }
.hcard:hover { transform: translateY(-2px); }
.tile-demo { display: block; }
.hand-head { display: flex; justify-content: space-between; align-items: center; }
.sort { font-size: .8rem; color: var(--muted); display: flex; align-items: center; gap: .4rem; }
.sort select { padding: .25rem .4rem; }

/* aksiyon paneli */
.sel-info { min-height: 3.2rem; font-size: .92rem; margin-bottom: .7rem; line-height: 1.4; }
.sel-info .k { font-weight: 800; }
.sel-info .ok { color: var(--ok); }
.sel-info .bad { color: var(--bad); }
.turn-status { color: var(--muted); font-size: .8rem; margin-top: .6rem; }

/* skor */
.scores li.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.scores li.me .name { font-weight: 700; }
.scores li.left { opacity: .5; }
.score { font-weight: 800; font-size: 1.15rem; color: var(--accent); min-width: 2ch; text-align: right; }
.hc { font-size: .75rem; color: var(--muted); }

/* olaylar & sohbet */
.log-panel { display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: .3rem; margin-bottom: .6rem; }
.tab { background: none; border: 1px solid transparent; color: var(--muted); font: inherit; padding: .3rem .7rem; border-radius: 8px; cursor: pointer; }
.tab.active { background: var(--panel2); border-color: var(--line); color: var(--text); }
.log { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow: auto; font-size: .82rem; display: flex; flex-direction: column; gap: .35rem; }
.log li { padding: .35rem .5rem; border-radius: 8px; background: rgba(255,255,255,.03); border-left: 3px solid var(--line); }
.log li.claim { border-left-color: var(--accent); }
.log li.move { border-left-color: #22d3ee; }
.log li.system { border-left-color: #a78bfa; color: var(--muted); }
.log li.pass, .log li.swap { color: var(--muted); }
.chat-list { max-height: 220px; overflow: auto; font-size: .85rem; display: flex; flex-direction: column; gap: .3rem; margin-bottom: .5rem; }
.chat-list .msg b { color: var(--accent); }
.chat-form { display: flex; gap: .4rem; }
.chat-form input { flex: 1; padding: .45rem .6rem; }

/* diyaloglar */
.dlg { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 1.3rem; width: min(380px, calc(100vw - 2rem)); }
.dlg.wide { width: min(760px, calc(100vw - 2rem)); }
.dlg::backdrop { background: rgba(4, 8, 20, .7); backdrop-filter: blur(2px); }
.rules { font-size: .92rem; line-height: 1.55; max-height: 65vh; overflow: auto; margin-bottom: 1rem; }
.res-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin: .5rem 0 1rem; display: block; overflow-x: auto; }
.res-table th, .res-table td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.res-table td:nth-child(2), .res-table th:nth-child(2) { text-align: left; width: 100%; }
.res-table tr.win td { color: var(--accent); font-weight: 700; }
.res-summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.res-summary div { background: var(--panel2); border-radius: 10px; padding: .5rem .7rem; font-size: .8rem; color: var(--muted); }
.res-summary b { display: block; font-size: 1.1rem; color: var(--text); }

/* toast & bağlantı */
.toasts { position: fixed; top: 4rem; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: .4rem; align-items: center; pointer-events: none; width: min(92vw, 460px); }
.toast { background: #0b1328; border: 1px solid var(--line); padding: .6rem 1rem; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.4); font-size: .9rem; animation: tin .2s ease-out; text-align: center; }
.toast.error { border-color: var(--bad); color: #fecaca; }
.toast.good { border-color: var(--ok); color: #bbf7d0; }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } }
.conn { position: fixed; bottom: 0; left: 0; right: 0; background: #7f1d1d; color: white; text-align: center; padding: .4rem; z-index: 60; font-size: .85rem; }
