:root {
  --bg: #17110d;
  --panel: #241a14;
  --cell: #33261c;
  --cell-alt: #2c2118;
  --gold: #e0b75e;
  --text: #ece2d2;
  --muted: #a49279;
  --gok: #5b8ee6;
  --yeralti: #c2453d;
  --mine: #5fd08a;
  --enemy: #ff6b5e;
  --energy: #4fb3ff;
  --up: #6fd36f;
  --down: #ff6b5e;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
/* iOS Safari: sayfa hiç kaymasın, adres çubuğu açılıp kapanırken düzen oynamasın */
body { position: fixed; inset: 0; }
body {
  background: radial-gradient(ellipse at center, #2b1f17 0%, var(--bg) 75%);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit; cursor: pointer; border: 1px solid var(--gold); color: var(--text);
  background: linear-gradient(#4a3624, #2e2116); border-radius: 6px; padding: 8px 14px;
}
button:hover:not(:disabled) { background: linear-gradient(#5d4530, #3a2a1c); }
button:disabled { opacity: .4; cursor: default; }
.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

#app {
  display: grid; grid-template-columns: 210px 1fr 270px; gap: 8px;
  height: 100vh; height: 100dvh; padding: 8px;
}
/* Eski iOS (15.4 öncesi) dvh bilmez: yüksekliği ui.js ölçer */
@supports not (height: 100dvh) { #app { height: var(--app-h, 100vh); } }

/* ---------- Sol panel ---------- */
#left { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.pinfo {
  background: var(--panel); border: 2px solid transparent; border-radius: 8px; padding: 10px;
  transition: border-color .2s;
}
.pinfo.active { border-color: var(--gold); box-shadow: 0 0 14px rgba(224,183,94,.35); }
.pname { font-weight: 700; font-size: 18px; }
.pfaction { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.energy { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 6px; align-items: center; }
.energy .pip { width: 12px; height: 12px; border-radius: 50%; background: #1e2a36; border: 1px solid #36506a; }
.energy .pip.on { background: radial-gradient(circle at 35% 35%, #bfe6ff, var(--energy)); border-color: #bfe6ff; }
.energy .num { margin-left: 6px; font-size: 13px; color: var(--energy); font-weight: 700; }
.stats { display: flex; gap: 10px; font-size: 13px; color: var(--muted); }
.zone-title { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 6px; }
#ping { font-size: 12px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
#ping .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
#ping.good .dot { background: var(--up); }
#ping.ok .dot { background: var(--gold); }
#ping.bad .dot { background: var(--down); }
#tools { display: flex; align-items: center; justify-content: center; gap: 8px; }
#tool-btns { display: flex; align-items: stretch; gap: 4px; }
#log-btn, #panel-close { display: none; }
#fs-btn, #quit-btn { display: inline-flex; align-items: center; justify-content: center; padding: 4px 8px; }
#quit-btn { font-size: 14px; line-height: 1; }
.fs-icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.lobby-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.lobby-tools button { display: inline-flex; align-items: center; gap: 6px; }
#actions { display: flex; flex-direction: column; gap: 6px; }
#ability-btn { width: 100%; min-height: 44px; padding: 6px; font-size: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; }
#ability-btn small { font-size: 11px; color: var(--energy); }
#end-btn { width: 100%; padding: 14px; font-size: 16px; font-weight: 700; }
#undo-btn { width: 100%; padding: 6px; font-size: 13px; }
#end-btn.glow:not(:disabled) { animation: pulse 1.2s infinite; background: linear-gradient(#8a6a2c, #5b431a); }

/* ---------- Kapılar ---------- */
#board { display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 0; }
.gates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; flex-shrink: 0; }
.gate {
  height: 40px; position: relative; border-radius: 8px; overflow: hidden;
  background: #1a120d; border: 2px solid #5a4636;
  display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700;
}
.gate .bar { position: absolute; left: 0; top: 0; bottom: 0; opacity: .35; transition: width .4s; }
.gates.mine .bar { background: var(--mine); }
.gates.enemy .bar { background: var(--enemy); }
.gate .label { position: relative; font-size: 12px; color: var(--muted); font-weight: 600; }
.gate .hp { position: relative; font-size: 18px; }
.gate.hit { animation: shake .4s; border-color: var(--enemy); }
.gate.down { background: repeating-linear-gradient(45deg, #2a1410, #2a1410 8px, #1a0c09 8px, #1a0c09 16px); border-color: #7a2a20; }
.gate.down .hp { color: var(--enemy); }
.gate.target { border-color: var(--gold); animation: pulse 1.2s infinite; }
.gate-pips { display: inline-flex; gap: 4px; margin-left: 4px; }

/* ---------- Saha ---------- */
#field { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lane {
  display: grid; grid-template-rows: repeat(5, 1fr); gap: 4px; min-height: 0;
  border-radius: 8px; padding: 4px; border: 2px solid transparent; background: rgba(0,0,0,.15);
}
.lane.target { border-color: var(--gold); cursor: pointer; animation: pulse 1.2s infinite; }
.cell {
  background: var(--cell); border-radius: 6px; min-height: 0; position: relative;
  display: flex; justify-content: center; align-items: center; padding: 3px;
}
.cell:nth-child(even) { background: var(--cell-alt); }
.cell.gate-mine { box-shadow: inset 0 -3px 0 rgba(95,208,138,.5); }
.cell.gate-enemy { box-shadow: inset 0 3px 0 rgba(255,107,94,.5); }
.cell.deploy { outline: 2px dashed var(--gold); outline-offset: -3px; }
.cell.t-forest { background: linear-gradient(160deg, #24452a, #1b3020); }
.cell.t-hill { background: linear-gradient(160deg, #5a4a33, #3d3223); }
.cell.t-river { background: linear-gradient(160deg, #1f3f5e, #16304a); }
.terrain-icon { position: absolute; right: 5px; bottom: 3px; font-size: 16px; opacity: .55; pointer-events: none; }
.lane-name { position: absolute; left: 6px; top: 2px; font-size: 10px; color: var(--muted); opacity: .7; }
.cell .card { height: 100%; width: auto; aspect-ratio: 5/6; max-width: 100%; }

@keyframes pulse { 50% { box-shadow: 0 0 16px rgba(224,183,94,.55); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); } 75% { transform: translateX(4px); }
}
@keyframes flash { 0% { filter: brightness(2) saturate(2) hue-rotate(-30deg); } 100% { filter: none; } }

/* ---------- El ---------- */
#prompt {
  height: 32px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 12px;
  font-size: 14px; color: var(--gold);
}
#prompt button { padding: 4px 14px; }
#hand {
  height: 150px; flex-shrink: 0; display: flex; gap: 6px; justify-content: center; align-items: flex-end;
  background: var(--panel); border-radius: 8px; padding: 8px; min-width: 0;
}
#hand .card { width: 96px; height: 132px; flex-shrink: 1; min-width: 50px; cursor: pointer; transition: transform .12s; }
@media (hover: hover) { #hand .card:hover { transform: translateY(-8px); } }
#hand .card.selected { transform: translateY(-14px); outline: 3px solid var(--gold); }
#hand .card.unplayable { filter: grayscale(.7) brightness(.6); }

/* ---------- Kart ---------- */
.card {
  position: relative; border-radius: 6px; overflow: hidden;
  background: linear-gradient(160deg, #4b3a2c, #241a13);
  border: 2px solid #9a8f80;
  container-type: inline-size;
}
.card.f-gok { border-color: var(--gok); background: linear-gradient(160deg, #2f4366, #161d2b); }
.card.f-yeralti { border-color: var(--yeralti); background: linear-gradient(160deg, #5a1f2a, #1f0a10); }
.flavor { font-style: italic; color: var(--muted); }
.card.spell { background: linear-gradient(160deg, #4a2f5c, #1d1226); }
.card.mine { border-color: var(--mine); box-shadow: 0 0 8px rgba(95,208,138,.35); }
.card.enemy { border-color: var(--enemy); box-shadow: 0 0 8px rgba(255,107,94,.35); }
.card.shielded { box-shadow: 0 0 0 3px rgba(190,220,255,.8), 0 0 12px rgba(190,220,255,.8); }
.card.target { outline: 3px solid var(--gold); cursor: pointer; animation: pulse 1.2s infinite; }
.card.hit { animation: flash .6s, shake .4s; }
.card .art {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 40cqw; padding-bottom: 18cqw;
}
.card.unit-on-board .art { padding-bottom: 6cqw; }
.card .cost {
  position: absolute; left: 3cqw; top: 3cqw; width: 28cqw; height: 28cqw; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 17cqw;
  background: radial-gradient(circle at 35% 35%, #bfe6ff, #1f7fd0); color: #fff; border: 1px solid #0b3a60;
  text-shadow: 0 1px 2px #000;
}
.card .atk, .card .hp {
  position: absolute; bottom: 3cqw; width: 30cqw; height: 30cqw; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 18cqw; color: #fff;
  text-shadow: 0 1px 2px #000; border: 1px solid #000; z-index: 1;
}
.card .atk { left: 3cqw; background: radial-gradient(circle at 35% 35%, #ffd27a, #b8860b); }
.card .hp { right: 3cqw; background: radial-gradient(circle at 35% 35%, #ff9b8a, #b3261a); }
.card .atk.up, .card .hp.up { color: #c9ffc9; }
.card .atk.down { color: #ffd0c9; }
.card .hp.down { color: #ffd0c9; }
.card .kw { position: absolute; right: 3cqw; top: 3cqw; display: flex; flex-direction: column; gap: 1cqw; font-size: 14cqw; }
.card .dir { position: absolute; left: 50%; top: 2cqw; transform: translateX(-50%); font-size: 12cqw; opacity: .8; }
.card .dir.mine { color: var(--mine); }
.card .dir.enemy { color: var(--enemy); }
.card .cname {
  position: absolute; left: 0; right: 0; bottom: 34cqw; padding: 2cqw 3cqw;
  background: rgba(0,0,0,.7); font-size: 10.5cqw; line-height: 1.1; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card.spell .cname { bottom: 3cqw; }
.card.unit-on-board .cname { display: none; }

/* ---------- Sağ panel ---------- */
#right { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
#detail { background: var(--panel); border-radius: 8px; padding: 12px; min-height: 300px; }
#detail h3 { margin: 8px 0 4px; }
#detail p { font-size: 13px; line-height: 1.4; margin: 6px 0; }
.d-card { display: flex; justify-content: center; }
.d-card .card { width: 120px; height: 160px; }
.d-meta { font-size: 13px; color: var(--muted); }
.hint { color: var(--gold); }
#log {
  flex: 1; min-height: 0; overflow-y: auto; background: var(--panel); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; line-height: 1.5; color: #cdbfa9;
}
#log div.me { color: #9cc3ff; }
#log div.op { color: #f1b27a; }
#log div.sys { color: var(--gold); font-weight: 600; }

/* ---------- Overlay / toast ---------- */
#overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; z-index: 10;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#overlay-box {
  background: var(--panel); border: 2px solid var(--gold); border-radius: 12px; padding: 28px 34px;
  text-align: center; max-width: 960px; max-height: 94vh; max-height: 94dvh; overflow-y: auto;
}
#overlay-box h1 { margin: 0 0 6px; color: var(--gold); letter-spacing: 2px; }
#overlay-box h2 { margin: 0 0 10px; color: var(--gold); }
.factions { display: flex; gap: 16px; margin-top: 18px; }
.faction-btn {
  flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 18px; border-color: var(--fc); text-align: left;
}
.faction-btn b { color: var(--fc); font-size: 18px; }
.faction-btn small { color: var(--muted); }
.faction-btn.picked { background: linear-gradient(#5d4530, #3a2a1c); box-shadow: 0 0 0 2px var(--fc), 0 0 16px var(--fc); }
.lobby { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.lobby label { display: flex; align-items: center; gap: 10px; justify-content: center; color: var(--muted); }
input {
  font: inherit; color: var(--text); background: #120c09; border: 1px solid #5a4636;
  border-radius: 6px; padding: 8px 10px;
}
input:focus { outline: none; border-color: var(--gold); }
.lobby-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.join-row { display: flex; gap: 6px; justify-content: center; margin: 8px 0; }
.ai-row { flex-basis: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.ai-pick { display: flex; gap: 6px; }
.ai-opt { min-height: 36px; min-width: 64px; padding: 6px 12px; font-size: 14px; border-color: var(--fc); }
.ai-opt.picked { background: linear-gradient(#5d4530, #3a2a1c); box-shadow: 0 0 0 2px var(--fc); font-weight: 700; }
#code-in { width: 90px; text-transform: uppercase; text-align: center; letter-spacing: 3px; font-weight: 700; }
#link-in { width: 320px; }
button.primary { background: linear-gradient(#8a6a2c, #5b431a); }
.invite-box { color: var(--gold); }
.big-code { font-size: 44px; font-weight: 800; letter-spacing: 8px; color: var(--gold); margin: 6px 0; }
.deck-link { color: var(--gold); cursor: pointer; text-decoration: underline dotted; }
.tabs { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 6px 0; }
.tab { padding: 5px 12px; font-size: 13px; }
.tab.on { background: linear-gradient(#8a6a2c, #5b431a); }
.gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px;
  text-align: left; margin: 10px 0 14px; max-height: 62vh; overflow-y: auto; padding-right: 4px;
}
.g-item { display: flex; gap: 10px; background: #1c140f; border: 1px solid #3d2e22; border-radius: 8px; padding: 8px; }
.g-card { position: relative; flex-shrink: 0; }
.g-card .card { width: 74px; height: 100px; }
.g-count {
  position: absolute; right: -6px; bottom: -6px; background: var(--gold); color: #1b130e;
  font-weight: 800; font-size: 12px; border-radius: 10px; padding: 1px 6px;
}
#deck-close, #gallery-back { position: sticky; bottom: 0; box-shadow: 0 -8px 16px var(--panel), 0 4px 12px rgba(0,0,0,.5); }
.g-info { font-size: 12px; line-height: 1.35; min-width: 0; }
.g-info b { font-size: 14px; }
.g-info p { margin: 3px 0; }
.rules { text-align: left; font-size: 13px; color: var(--muted); line-height: 1.55; margin-top: 18px; }
.rules ul { margin: 6px 0 0; padding-left: 18px; }

#toast {
  position: fixed; left: 50%; top: 45%; transform: translate(-50%, -50%);
  background: rgba(20,14,10,.92); border: 1px solid var(--gold); color: var(--text);
  padding: 10px 18px; border-radius: 8px; font-size: 15px; pointer-events: none;
  opacity: 0; transition: opacity .25s; z-index: 20; white-space: pre-line; text-align: center;
}
#toast.show { opacity: 1; }

/* =====================================================================
   TELEFON — YATAY
   ===================================================================== */
@media (max-height: 520px) and (orientation: landscape) {
  #app {
    grid-template-columns: 124px 1fr 128px;
    grid-template-rows: 24px 1fr 24px 20px;
    grid-template-areas: "left g1 hand" "left field hand" "left g0 hand" "left prompt hand";
    gap: 4px;
    padding: max(4px, env(safe-area-inset-top)) max(4px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
  }
  #board { display: contents; }
  #left { grid-area: left; gap: 4px; min-height: 0; }
  #gates-1 { grid-area: g1; } #field { grid-area: field; } #gates-0 { grid-area: g0; }
  #prompt { grid-area: prompt; } #hand { grid-area: hand; }

  .pinfo { padding: 6px; }
  .pname { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pfaction, .energy .pip { display: none; }
  .energy { margin-bottom: 2px; }
  .energy .num { margin-left: 0; font-size: 13px; }
  .stats { font-size: 11px; gap: 6px; flex-wrap: wrap; }
  #ping { font-size: 10px; }
  #log-btn { display: inline-block; padding: 2px 8px; font-size: 14px; }
  #actions { gap: 4px; }
  #ability-btn { min-height: 36px; padding: 2px; font-size: 12px; }
  #ability-btn small { font-size: 10px; }
  #end-btn { padding: 10px 4px; font-size: 13px; }
  #undo-btn { padding: 3px 2px; font-size: 12px; }

  .gates { gap: 4px; }
  .gate { height: 24px; border-width: 1px; }
  .gate .label { display: none; }
  .gate .hp { font-size: 12px; }
  #field { gap: 4px; }
  .lane { padding: 2px; gap: 2px; border-width: 1px; }
  .cell { padding: 1px; }
  .lane-name { font-size: 8px; left: 3px; top: 0; }
  .terrain-icon { font-size: 11px; right: 2px; bottom: 1px; }
  .card .atk, .card .hp { width: 36cqw; height: 36cqw; font-size: 22cqw; }

  #prompt { height: 20px; font-size: 11px; white-space: nowrap; overflow: hidden; gap: 6px; }
  #prompt button { padding: 1px 8px; font-size: 11px; }
  #hand {
    height: auto; display: grid; grid-template-columns: 1fr 1fr; align-content: start; align-items: start;
    gap: 4px; padding: 4px; overflow-y: auto; min-height: 0;
  }
  #hand .card { width: 100%; height: auto; aspect-ratio: 5/7; min-width: 0; }
  #hand .card.selected { transform: none; outline-offset: -3px; }

  /* Bilgi paneli: dokununca solda açılır */
  #right {
    position: fixed; left: max(4px, env(safe-area-inset-left)); top: max(4px, env(safe-area-inset-top)); bottom: max(4px, env(safe-area-inset-bottom)); width: 124px; z-index: 6;
    display: none; background: var(--panel); border: 1px solid var(--gold); border-radius: 8px; padding: 6px;
    box-shadow: 0 6px 24px rgba(0,0,0,.6);
  }
  #right.log-only { width: 280px; }
  #right.detail-only .d-card .card { width: 64px; height: 86px; }
  #right.detail-only #detail { padding: 2px; }
}

/* =====================================================================
   TELEFON — DİKEY
   ===================================================================== */
@media (max-width: 600px) and (orientation: portrait) {
  #app {
    grid-template-columns: 1fr auto 104px;
    grid-template-rows: auto 26px 1fr 26px 22px 100px auto;
    grid-template-areas: "op op op" "g1 g1 g1" "field field field" "g0 g0 g0" "prompt prompt prompt" "hand hand hand" "me tools end";
    gap: 4px;
    padding: max(4px, env(safe-area-inset-top)) max(4px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
  }
  #board, #left { display: contents; }
  .spacer { display: none; }
  #info-1 { grid-area: op; } #info-0 { grid-area: me; } #tools { grid-area: tools; flex-direction: column; gap: 4px; }
  #actions { grid-area: end; gap: 4px; }
  #ability-btn { min-height: 36px; padding: 2px; font-size: 12px; }
  #ability-btn small { font-size: 10px; }
  #end-btn { padding: 8px 4px; font-size: 14px; }
  #undo-btn { padding: 3px 2px; font-size: 12px; }
  #gates-1 { grid-area: g1; } #field { grid-area: field; } #gates-0 { grid-area: g0; }
  #prompt { grid-area: prompt; } #hand { grid-area: hand; }

  .pinfo { padding: 6px 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; }
  .pname { font-size: 14px; }
  .pfaction, .energy .pip { display: none; }
  .energy, .stats { margin: 0 !important; }
  .energy .num { margin-left: 0; font-size: 13px; }
  .stats { font-size: 12px; gap: 8px; }
  #ping { font-size: 10px; }
  #log-btn { display: inline-block; padding: 2px 10px; font-size: 14px; }

  .gates { gap: 4px; }
  .gate { height: 26px; border-width: 1px; }
  .gate .label { display: none; }
  .gate .hp { font-size: 13px; }
  #field { gap: 4px; min-height: 0; }
  .lane { padding: 2px; gap: 2px; border-width: 1px; }
  .cell { padding: 1px; }
  .lane-name { font-size: 9px; left: 3px; top: 0; }
  .terrain-icon { font-size: 12px; right: 2px; bottom: 1px; }
  .card .atk, .card .hp { width: 34cqw; height: 34cqw; font-size: 21cqw; }

  #prompt { height: 22px; font-size: 11px; white-space: nowrap; overflow: hidden; gap: 6px; }
  #prompt button { padding: 1px 8px; font-size: 11px; }
  #hand { height: 100px; justify-content: flex-start; align-items: center; overflow-x: auto; padding: 4px; gap: 4px; }
  #hand .card { width: 66px; height: 90px; flex-shrink: 0; min-width: 0; }
  #hand .card.selected { transform: none; outline-offset: -3px; }

  /* Bilgi paneli: dokununca alttan açılır (el ve alt çubuğun üstüne) */
  #right {
    position: fixed; left: 0; right: 0; bottom: 0; height: min(48vh, 340px); height: min(48dvh, 340px); z-index: 6;
    display: none; background: var(--panel); border-top: 2px solid var(--gold); border-radius: 12px 12px 0 0;
    padding: 8px 10px max(8px, env(safe-area-inset-bottom)); box-shadow: 0 -6px 24px rgba(0,0,0,.6);
  }
  /* Kart bilgisi: kısa yatay şerit, sadece el + alt çubuğun üstünü kaplar */
  #right.detail-only { height: auto; max-height: 156px; padding-top: 6px; }
  #right.detail-only #detail {
    display: grid; grid-template-columns: 62px 1fr; grid-template-rows: auto auto 1fr; column-gap: 10px;
    align-content: start; overflow-y: auto; padding: 0 30px 0 0;
  }
  #right.detail-only .d-card { grid-row: 1 / 4; align-self: start; }
  #right.detail-only .d-card .card { width: 62px; height: 84px; }
  #right.detail-only #detail h3 { margin: 0; }
  #right.detail-only #detail p { margin: 2px 0; }
}

/* Ortak telefon ayarları */
@media (max-height: 520px) and (orientation: landscape), (max-width: 600px) and (orientation: portrait) {
  #right.show { display: flex; }
  #right { gap: 4px; }
  #panel-close { display: block; position: absolute; right: 6px; top: 6px; padding: 2px 9px; font-size: 13px; z-index: 1; }
  #detail { min-height: 0; padding: 4px 6px; flex-shrink: 0; max-height: 60%; overflow-y: auto; }
  #right.log-only #detail { display: none; }
  #right.detail-only #log, #right.detail-only .zone-title { display: none; }
  #right.detail-only #detail { max-height: none; flex: 1; }
  #detail h3 { font-size: 14px; margin: 4px 0 2px; }
  #detail p { font-size: 11.5px; margin: 3px 0; }
  .d-meta { font-size: 11px; }
  .d-card .card { width: 70px; height: 94px; }
  #right .zone-title { margin: 0; font-size: 10px; }
  #log { font-size: 11px; padding: 4px 6px; }

  #overlay-box { max-width: 96vw; max-height: 94vh; max-height: 94dvh; overflow-y: auto; padding: 14px 16px; }
  .gallery { max-height: none; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .g-card .card { width: 58px; height: 78px; }
  #overlay-box h1 { font-size: 22px; }
  .factions { gap: 8px; margin-top: 8px; }
  .faction-btn { padding: 10px; }
  .faction-btn b { font-size: 15px; }
  .faction-btn small { font-size: 11px; }
  .lobby { gap: 8px; margin-top: 6px; }
  .rules { font-size: 11px; margin-top: 10px; }
  .big-code { font-size: 34px; }
  #link-in { width: 60vw; }
  #toast { font-size: 13px; max-width: 90vw; }
}
@media (max-width: 600px) and (orientation: portrait) {
  .factions { flex-direction: column; }
}

/* ---------- Adım adım oynatma ---------- */
#fx { position: fixed; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
.fx-ghost { position: fixed; margin: 0; z-index: 2; box-shadow: 0 0 0 2px #fff, 0 6px 18px rgba(0,0,0,.6); }
.fx-mark { outline: 3px solid #fff !important; outline-offset: -1px; box-shadow: 0 0 16px rgba(255,255,255,.7); }
.fx-actor { outline: 3px solid var(--gold); outline-offset: -1px; }
.fx-chip {
  position: fixed; z-index: 4; transform: translate(-50%, -100%); padding: 2px 7px; border-radius: 4px;
  background: var(--gold); color: #1c130c; font-size: 11px; font-weight: 800; letter-spacing: .4px; white-space: nowrap;
}
.fx-shot { position: fixed; z-index: 3; font-size: 24px; color: #ffe9a8; text-shadow: 0 0 8px #ffb84d; transform: translate(-50%,-50%); }
.fx-float {
  position: fixed; z-index: 5; font-size: 30px; font-weight: 900; white-space: nowrap;
  transform: translate(-50%,-50%); text-shadow: 0 0 3px #000, 0 2px 4px #000, 0 0 10px #000;
}
.fx-float.dmg, .fx-float.heal { text-shadow: none; }
.fx-float.dmg { color: #fff; background: #c3271b; border: 2px solid #fff; border-radius: 8px; padding: 0 8px; }
.fx-float.heal { color: #fff; background: #23894a; border: 2px solid #fff; border-radius: 8px; padding: 0 8px; }
.fx-float.buff { color: #1c130c; background: var(--gold); border-radius: 8px; padding: 0 8px; font-size: 22px; }
.fx-float.shield { color: #10243a; background: #cfe6ff; border-radius: 8px; padding: 2px 8px; font-size: 16px; text-shadow: none; }
.fx-float.boom { font-size: 36px; }
.fx-show {
  position: fixed; left: 50%; top: 45%; z-index: 6; transform: translate(-50%,-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 16px;
  background: rgba(20,13,9,.92); border: 2px solid var(--gold); border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.7);
}
.fx-show .card { width: 130px; height: 178px; }
.fx-show-who { font-size: 13px; color: var(--muted); }
.fx-show-name { font-size: 16px; font-weight: 800; color: var(--gold); }
.pb-cap { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
#prompt #pb-speed, #prompt #pb-skip { flex: none; white-space: nowrap; padding-left: 8px; padding-right: 8px; }
#log div.now { background: rgba(224,183,94,.2); border-radius: 3px; color: var(--text); }
@media (max-height: 520px) and (orientation: landscape), (max-width: 600px) and (orientation: portrait) {
  .fx-float { font-size: 22px; }
  .fx-float.buff { font-size: 17px; }
  .fx-float.shield { font-size: 13px; }
  .fx-float.boom { font-size: 26px; }
  .fx-chip { font-size: 9px; padding: 1px 4px; }
  .fx-shot { font-size: 18px; }
  .fx-show { padding: 6px 10px; gap: 3px; }
  .fx-show .card { width: 84px; height: 116px; }
  .fx-show-who { font-size: 11px; }
  .fx-show-name { font-size: 13px; }
}

/* ---------- Ortak kartlar ve yeni durumlar ---------- */
.card.common { box-shadow: inset 0 0 0 2px var(--gold); }
.g-title { color: var(--gold); margin: 14px 0 6px; font-size: 15px; }
.g-title small { font-weight: 400; }
.card.frozen { filter: saturate(.45) brightness(1.15); border-color: #9fdcff !important; box-shadow: 0 0 0 2px #9fdcff, 0 0 12px rgba(159,220,255,.8); }
.card .frost { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); font-size: 42cqw; z-index: 1; opacity: .9; }
.gate.warded { border-color: #6fe08a; box-shadow: 0 0 10px rgba(111,224,138,.7), inset 0 0 8px rgba(111,224,138,.4); }

/* ---------- Birikimli enerji ---------- */
.energy .burn { margin-left: 6px; font-size: 11px; color: #ffb36b; white-space: nowrap; }
.fx-float.energy { color: #06283f; background: #8fd3ff; border-radius: 8px; padding: 0 8px; font-size: 20px; text-shadow: none; }

/* ---------- Rakip bağlantısı ---------- */
#banner {
  position: fixed; left: 50%; top: max(6px, env(safe-area-inset-top)); transform: translateX(-50%); z-index: 8;
  background: #5b2a16; color: #ffe2c4; border: 1px solid var(--gold); border-radius: 8px; padding: 4px 12px;
  font-size: 13px; font-weight: 700; white-space: nowrap; pointer-events: none;
}

/* ---------- Kalıcı saldırı değişikliği ---------- */
.card .mod { position: absolute; left: 3cqw; bottom: 35cqw; padding: 0 6cqw; border-radius: 6cqw; font-size: 15cqw; font-weight: 800; z-index: 1; color: #fff; text-shadow: 0 1px 1px #000; }
.card .mod.up { background: #23894a; }
.card .mod.down { background: #a8291e; }
