/* Káosz Kozmosz — egyedi kártya- és játéktér-stílusok (a Tailwind mellé) */

/* ---- általános ---- */
html, body { height: 100%; -webkit-tap-highlight-color: transparent; }
/* iOS PWA: a dinamikus viewport-magasság a pontos (nincs cím-sáv ugrálás) */
html, body { height: 100dvh; }
/* kivágás (notch) melletti biztonsági sávok minden tájolásban */
#view-game {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-top: env(safe-area-inset-top);
}
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }

/* ---- kozmikus hátterek ----------------------------------------- */

/* Alap: az egész app (játék közben is) finom, pislákoló csillagmezőt kap.
   Két fix réteg a body mögött — a tartalom fölötte marad. */
body { position: relative; background: #070b18; }
body::before {
  content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 55% at 15% -10%, rgba(124,58,237,.22), transparent 60%),
    radial-gradient(ellipse 70% 50% at 95% 15%,  rgba(34,211,238,.13), transparent 60%),
    radial-gradient(ellipse 90% 60% at 50% 115%, rgba(30,41,99,.85), rgba(11,16,32,.95) 60%, #070b18 100%),
    #070b18;
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 12% 22%, rgba(255,255,255,.8) 50%, transparent 51%),
    radial-gradient(1px 1px at 33% 71%, rgba(255,255,255,.55) 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 47% 12%, rgba(253,230,138,.75) 50%, transparent 51%),
    radial-gradient(1px 1px at 61% 48%, rgba(255,255,255,.6) 50%, transparent 51%),
    radial-gradient(1.6px 1.6px at 74% 83%, rgba(186,230,253,.7) 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 33%, rgba(255,255,255,.5) 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 8% 88%, rgba(255,255,255,.6) 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 92%, rgba(253,230,138,.5) 50%, transparent 51%),
    radial-gradient(1.3px 1.3px at 92% 64%, rgba(255,255,255,.65) 50%, transparent 51%),
    radial-gradient(1px 1px at 25% 45%, rgba(186,230,253,.5) 50%, transparent 51%);
  background-size: 340px 340px;
  animation: twinkle 6s ease-in-out infinite;
}
@keyframes twinkle { 0%, 100% { opacity: .9; } 50% { opacity: .45; } }

/* Lobby / váró: látványosabb nebula a csillagréteg fölé. */
.starfield {
  background:
    radial-gradient(2px 2px at 18% 28%, rgba(255,255,255,.9) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 68% 58%, rgba(253,230,138,.85) 50%, transparent 51%),
    radial-gradient(2.2px 2.2px at 42% 78%, rgba(186,230,253,.8) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 84% 18%, rgba(255,255,255,.7) 50%, transparent 51%),
    radial-gradient(1.8px 1.8px at 8% 62%, rgba(255,255,255,.75) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 92% 82%, rgba(253,230,138,.6) 50%, transparent 51%),
    radial-gradient(ellipse 60% 45% at 78% 8%,  rgba(124,58,237,.32), transparent 65%),
    radial-gradient(ellipse 55% 40% at 12% 32%, rgba(34,211,238,.16), transparent 65%),
    radial-gradient(ellipse 65% 45% at 50% 105%, rgba(225,29,72,.14), transparent 60%),
    radial-gradient(ellipse at 50% 120%, #1e2963 0%, #0b1020 55%, transparent 100%);
}

/* ---- gombok ---- */
.btn-primary, .btn-secondary, .btn-danger, .btn-ghost {
  border-radius: 0.9rem; padding: 0.8rem 1.1rem; font-weight: 700; font-size: 0.95rem;
  transition: transform .08s ease, filter .12s ease; touch-action: manipulation;
}
.btn-primary  { background: linear-gradient(135deg, #7c3aed, #4f46e5); color: #fff; box-shadow: 0 6px 18px rgba(124,58,237,.35); }
.btn-secondary{ background: #1b2547; color: #e2e8f0; border: 1px solid rgba(255,255,255,.12); }
.btn-danger   { background: linear-gradient(135deg, #e11d48, #be123c); color: #fff; }
.btn-ghost    { background: transparent; color: #94a3b8; border: 1px dashed rgba(255,255,255,.15); }
.btn-exit {
  border-radius: 0.9rem; padding: 0.95rem 1.2rem; font-weight: 800; font-size: 1.05rem;
  background: rgba(225, 29, 72, 0.18); color: #fecdd3;
  border: 1.5px solid rgba(251, 113, 133, 0.65);
  box-shadow: 0 6px 18px rgba(225, 29, 72, 0.18);
  transition: transform .08s ease, filter .12s ease; touch-action: manipulation;
}
.btn-exit:active { transform: scale(.96); }
.btn-primary:active, .btn-secondary:active, .btn-danger:active, .btn-ghost:active, .btn-request:active { transform: scale(.96); }
.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled { filter: grayscale(.7) brightness(.6); pointer-events: none; }
a.btn-primary, a.btn-secondary, a.btn-ghost, a.btn-request {
  display: block; text-align: center; text-decoration: none; box-sizing: border-box;
}
.btn-request {
  border-radius: 0.9rem; padding: 0.85rem 1.1rem; font-weight: 800; font-size: 0.98rem;
  background: linear-gradient(135deg, #f59e0b, #d97706); color: #1a1208;
  box-shadow: 0 6px 18px rgba(245, 158, 11, .28);
  border: 1px solid rgba(255, 255, 255, .22);
  transition: transform .08s ease, filter .12s ease; touch-action: manipulation;
}
.lobby-code-request {
  display: flex; flex-direction: column; gap: 0.55rem;
  padding: 0.85rem 0.9rem; border-radius: 1rem;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.35);
}
.lobby-code-mail-link { color: #fde68a; font-weight: 700; text-decoration: underline; }

/* akciósáv kompakt gombjai */
.act-btn {
  border-radius: 0.8rem; padding: 0.7rem 1.15rem; font-weight: 700; font-size: 1rem;
  white-space: nowrap; touch-action: manipulation; transition: transform .08s ease, filter .12s;
}
.act-btn:active { transform: scale(.95); }

/* A body select-none, a naplómezőt mégis ki lehessen jelölni. */
.ai-log-text {
  -webkit-user-select: text;
  user-select: text;
  resize: none;
  border: 1px solid rgba(255,255,255,.1);
  outline: none;
}
.act-btn:disabled { filter: grayscale(.8) brightness(.55); pointer-events: none; }

/* Következő kötelező lépés: húzás / kijátszás / eldobás — pulzál, hogy ne maradjon le. */
#action-bar .kk-next-act,
.pile.kk-next-act .pile-card {
  animation: kk-next-act-pulse 1.15s ease-in-out infinite;
}
#action-bar .kk-next-act-text {
  display: inline-block;
  font-size: .95rem;
  font-weight: 800;
  line-height: 1.25;
  color: #fde68a;
  animation: kk-next-act-text 1.15s ease-in-out infinite;
}
@keyframes kk-next-act-pulse {
  0%, 100% { filter: brightness(1); box-shadow: 0 0 0 0 rgba(251,191,36,.2); }
  50% { filter: brightness(1.22); box-shadow: 0 0 0 4px rgba(251,191,36,.55), 0 0 20px rgba(251,191,36,.45); }
}
@keyframes kk-next-act-text {
  0%, 100% { opacity: .82; text-shadow: 0 0 0 rgba(251,191,36,0); transform: scale(1); }
  50% { opacity: 1; text-shadow: 0 0 14px rgba(253,230,138,.85); transform: scale(1.04); }
}
@media (prefers-reduced-motion: reduce) {
  #action-bar .kk-next-act,
  .pile.kk-next-act .pile-card,
  #action-bar .kk-next-act-text { animation: none; }
  #action-bar .kk-next-act,
  .pile.kk-next-act .pile-card { box-shadow: 0 0 0 3px rgba(251,191,36,.7); }
}

.chip { border-radius: 999px; padding: .3rem .8rem; font-size: .88rem; font-weight: 700;
  background: #1b2547; color: #94a3b8; border: 1px solid rgba(255,255,255,.1); }
.chip.chip-turn { background: linear-gradient(135deg,#f59e0b,#ef4444); color:#fff; border: none;
  animation: pulse-chip 1.4s ease-in-out infinite; }
@keyframes pulse-chip { 50% { filter: brightness(1.25); } }

.game-top {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  padding: .5rem .5rem .25rem;
  flex-shrink: 0;
  position: relative;
}
.game-top-opponents {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  gap: .2rem;
}
.game-fold-toggle {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  width: 100%;
  padding: .35rem .55rem;
  border-radius: .65rem;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(11, 16, 32, .72);
  color: #cbd5e1;
  font-size: .78rem;
  font-weight: 700;
  text-align: left;
}
.game-fold-chevron {
  flex: 0 0 auto;
  font-size: .7rem;
  color: #94a3b8;
  transition: transform .15s ease;
}
.game-top-opponents--open .game-fold-chevron { transform: rotate(180deg); }
.game-tools-wrap {
  display: flex;
  align-items: flex-start;
  flex-shrink: 0;
}
.game-tools-toggle { display: none; }
#game-tools {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-shrink: 0;
}

/* Harci lánc: támadás / védekezés / áttörés egymásra csúsztatva.
   Balra tolva, hogy a középső infó (várakozás, eseménynapló) ne takaródjon. */
.combat-stack {
  position: fixed;
  left: max(.55rem, env(safe-area-inset-left));
  right: auto;
  top: max(5.6rem, calc(env(safe-area-inset-top) + 4.4rem));
  transform: none;
  z-index: 52;
  pointer-events: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: flex-end;
  gap: 1.4rem 1.6rem;
  max-width: min(52vw, 28rem);
  padding: 0 .4rem 1.6rem;
}
.combat-stack.hidden { display: none; }
.combat-chain {
  --ox: 1.2rem;
  --oy: 1.35rem;
  --cw: 8.6rem;
  --ch: 12.1rem;
  position: relative;
  width: calc(var(--cw) + (var(--chain-n) - 1) * var(--ox));
  height: calc(var(--ch) + (var(--chain-n) - 1) * var(--oy));
  margin-bottom: 1.15rem;
  filter: drop-shadow(0 14px 28px rgba(0,0,0,.55));
}
.combat-chain .card-combat {
  position: absolute;
  left: 0;
  bottom: 0;
  width: var(--cw);
  height: var(--ch);
  border-radius: 1rem;
  transform: translate(calc(var(--i) * var(--ox)), calc(var(--i) * -1 * var(--oy)));
  z-index: calc(var(--i) + 1);
  pointer-events: none;
}
.combat-chain .card-combat.is-top {
  box-shadow: 0 0 0 2px #fbbf24, 0 12px 28px rgba(0,0,0,.5);
}
.combat-chain .card-combat.is-top.is-linger {
  animation: combat-linger-pop .45s ease-out;
}
@keyframes combat-linger-pop {
  from {
    transform: translate(calc(var(--i) * var(--ox)), calc(var(--i) * -1 * var(--oy))) scale(.86);
    opacity: .35;
  }
  to {
    transform: translate(calc(var(--i) * var(--ox)), calc(var(--i) * -1 * var(--oy))) scale(1);
    opacity: 1;
  }
}
.card-combat.has-img .card-name { display: none; }
.card-combat .card-icon { font-size: 3.2rem; }
.combat-bt-badge {
  position: absolute; top: .3rem; left: 50%; transform: translateX(-50%);
  z-index: 4; white-space: nowrap; pointer-events: none;
  background: rgba(124, 58, 237, .95); color: #fff; font-weight: 800;
  font-size: .62rem; padding: .12rem .45rem; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.35); box-shadow: 0 2px 8px rgba(0,0,0,.45);
}
.combat-chain-label {
  position: absolute;
  left: 0; right: 0;
  bottom: -1.2rem;
  text-align: center;
  font-size: .72rem;
  font-weight: 800;
  color: #fde68a;
  text-shadow: 0 1px 6px #000, 0 0 10px rgba(0,0,0,.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#react-modal:not(.hidden) {
  z-index: 57;
}
#react-modal.react-modal--dock {
  align-items: flex-end;
  background-color: rgba(0, 0, 0, .42);
  backdrop-filter: blur(3px);
  padding-bottom: max(.75rem, env(safe-area-inset-bottom));
}
#react-modal.react-modal--dock .react-modal-panel {
  max-height: min(88dvh, calc(100dvh - env(safe-area-inset-top) - 2.5rem));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.react-modal-head {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
}
.react-modal-copy {
  min-width: 0;
  flex: 1 1 auto;
}
.react-attack-preview {
  flex: 0 0 auto;
}
.react-attack-preview .react-attack-card {
  width: 4.6rem;
  height: 6.45rem;
  border-radius: .65rem;
  pointer-events: none;
}
.react-attack-preview .react-attack-card .card-icon { font-size: 1.8rem; }
.react-attack-preview .react-attack-card .card-name { font-size: .52rem; }
body.react-modal-open .combat-stack {
  z-index: 48;
  opacity: .72;
}
@media (orientation: portrait) and (max-width: 480px) {
  #react-modal.react-modal--dock #react-title {
    font-size: 1.2rem;
    line-height: 1.3;
  }
  #react-modal.react-modal--dock #react-desc {
    font-size: .9rem;
    margin-top: .35rem;
  }
  .react-attack-preview .react-attack-card {
    width: 4.1rem;
    height: 5.75rem;
  }
}
.wait-banner-hand {
  border-radius: 999px;
  padding: .35rem .9rem;
  font-size: .78rem;
  font-weight: 800;
  color: #fde68a;
  background: rgba(0, 0, 0, .28);
  border: 1px solid rgba(251, 191, 36, .45);
  touch-action: manipulation;
}
.wait-banner-hand:active { transform: scale(.96); }

@media (orientation: portrait) {
  .combat-stack {
    top: max(5.2rem, calc(env(safe-area-inset-top) + 3.8rem));
    left: max(.4rem, env(safe-area-inset-left));
    max-width: calc(100vw - 4.4rem);
  }
  .combat-chain { --cw: 6.6rem; --ch: 9.3rem; --ox: .95rem; --oy: 1.05rem; }
  .combat-chain--compact { --cw: 5.4rem; --ch: 7.6rem; --ox: .75rem; --oy: .85rem; }
  .card-combat .card-icon { font-size: 2.4rem; }
  .combat-bt-badge { font-size: .55rem; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .combat-stack {
    top: max(3.4rem, calc(env(safe-area-inset-top) + 2.4rem));
    gap: .7rem 1rem;
    left: max(4.6rem, calc(env(safe-area-inset-left) + 3.8rem));
    max-width: min(46vw, 22rem);
  }
  .combat-chain { --cw: 5.1rem; --ch: 7.2rem; --ox: .7rem; --oy: .78rem; margin-bottom: .85rem; }
  .combat-chain-label { font-size: .62rem; bottom: -1rem; }
  .card-combat .card-icon { font-size: 1.9rem; }
  .combat-bt-badge { font-size: .5rem; padding: .06rem .32rem; }
}
@media (orientation: landscape) {
  .combat-stack {
    left: max(5.2rem, calc(env(safe-area-inset-left) + 4.4rem));
    max-width: min(42vw, 26rem);
  }
}
@media (orientation: landscape) and (max-width: 820px) {
  .combat-chain { --cw: 6.2rem; --ch: 8.7rem; --ox: .85rem; --oy: .95rem; }
}

/* ---- kártyák ---- */
.card {
  position: relative; flex: 0 0 auto;
  width: 6.2rem; height: 8.7rem; border-radius: .8rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 3px 10px rgba(0,0,0,.45);
  color: #fff; text-align: center; padding: .3rem .15rem;
  touch-action: manipulation; transition: transform .1s ease, box-shadow .15s ease;
}
.card:active { transform: scale(.95); }
.card.is-new-draw {
  animation: new-draw-pop .4s ease-out;
}
@keyframes new-draw-pop {
  from { transform: translateY(.35rem) scale(.94); opacity: .55; }
  to   { transform: none; opacity: 1; }
}
/* valódi kártyakép: teljesen kitölti a lapot, az ikon+név csak tartalék */
.card { overflow: hidden; }
.card .card-img { position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; border-radius: inherit; pointer-events: none; }
.card.has-img .card-icon { display: none; }

/* Kártyatípus-jel a sarokban (bolygó / lopás / pusztítás / védekezés) */
.card-type-badge {
  position: absolute;
  top: .18rem;
  left: .18rem;
  z-index: 3;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .58rem;
  font-weight: 900;
  line-height: 1;
  pointer-events: auto;
  cursor: help;
  background: rgba(6, 10, 22, .62);
  border: 1px solid rgba(255, 255, 255, .28);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .45);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .85);
  backdrop-filter: blur(2px);
}
.card-type-tip {
  position: fixed;
  z-index: 10050;
  transform: translate(-50%, -100%);
  min-width: max-content;
  max-width: 12rem;
  padding: .32rem .55rem;
  border-radius: .42rem;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.25;
  color: #f1f5f9;
  background: rgba(8, 12, 24, .96);
  border: 1px solid rgba(148, 163, 184, .4);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .6);
  white-space: nowrap;
  pointer-events: none;
}
.card-type-tip.hidden { display: none; }
.card.has-type-badge:hover { z-index: 4; }
.card-type-planet { color: #e9d5ff; }
.card-type-acquire { color: #a5f3fc; }
.card-type-destroy { color: #fecaca; }
.card-type-defense { color: #bbf7d0; }
.card-sm .card-type-badge {
  top: .1rem;
  left: .1rem;
  width: .72rem;
  height: .72rem;
  font-size: .42rem;
  border-width: .75px;
}
.card-lg .card-type-badge,
.card-combat .card-type-badge,
.flip-in .card-type-badge {
  top: .28rem;
  left: .28rem;
  width: 1.35rem;
  height: 1.35rem;
  font-size: .72rem;
}

.card.has-img .card-name { position: absolute; left: 0; right: 0; bottom: 0;
  padding: .2rem .15rem; background: linear-gradient(transparent, rgba(0,0,0,.78));
  font-size: .62rem; }
.card-sm.has-img .card-name { display: none; }

/* Plotuh: a helyettesített bolygó neve mindenki számára látható */
.joker-named {
  position: absolute; top: .2rem; left: 50%; transform: translateX(-50%);
  z-index: 2; white-space: nowrap; pointer-events: none;
  background: rgba(124,58,237,.92); color: #fff; font-weight: 800;
  font-size: .58rem; padding: .12rem .4rem; border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0,0,0,.5); border: 1px solid rgba(255,255,255,.35);
}
.card-sm .joker-named { font-size: .44rem; padding: .08rem .28rem; }
.card-lg .joker-named { font-size: .85rem; padding: .2rem .6rem; }
/* Nagyított / felfedett lap: a névcsík takarja a grafikát — a név a lapon kívül van. */
.card-lg.has-img .card-name,
.flip-in.has-img .card-name { display: none; }
.card .card-icon { font-size: 2.2rem; line-height: 1; filter: drop-shadow(0 2px 3px rgba(0,0,0,.5)); }
.card .card-name { font-size: .72rem; font-weight: 800; line-height: 1.15; letter-spacing: .01em;
  text-shadow: 0 1px 2px rgba(0,0,0,.7); word-break: break-word; }

.card-sm { width: 3.1rem; height: 4.4rem; border-radius: .5rem; gap: 0; padding: .1rem; }
.card-sm .card-icon { font-size: 1.3rem; }
.card-sm .card-name { font-size: .48rem; }

.card-lg { width: 11rem; height: 15.5rem; border-radius: 1.1rem; gap: .4rem; }
.card-lg .card-icon { font-size: 4.5rem; }
.card-lg .card-name { font-size: 1.05rem; }

/* Nagyított kártya a képernyő közepén */
.card-zoom {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(.5rem, env(safe-area-inset-top)) max(.6rem, env(safe-area-inset-right)) max(.75rem, env(safe-area-inset-bottom)) max(.6rem, env(safe-area-inset-left));
  pointer-events: auto;
}
.card-zoom.is-reaction-peek {
  z-index: 62;
}
#sheet-backdrop.is-reaction-peek {
  z-index: 61;
}
.card-zoom-inner {
  pointer-events: auto;
  width: min(28rem, 100%);
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .55rem;
  padding: .35rem .2rem .2rem;
}
.card-zoom-frame { position: relative; flex: 0 0 auto; }
.card-zoom-side {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .45rem;
}
.card-zoom-x {
  position: absolute;
  top: -.45rem;
  right: -.45rem;
  z-index: 3;
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 999px;
  border: 2px solid #f8fafc;
  background: #0b1020;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(0,0,0,.55);
  cursor: pointer;
  touch-action: manipulation;
}
.card-zoom-x:active { transform: scale(.94); }
.card-zoom:not(.is-list) #sheet-card .card-lg {
  width: min(22rem, calc(100vw - 2.4rem), calc((100dvh - 9.5rem) * 5 / 7));
  height: auto;
  aspect-ratio: 5 / 7;
  border-radius: 1.15rem;
  pointer-events: none;
}
.card-zoom:not(.is-list) #sheet-card .card-lg:active { transform: none; }
.card-zoom #sheet-title {
  margin: 0;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 8px #000;
}
.card-zoom #sheet-desc {
  margin: 0;
  text-align: center;
  font-size: .95rem;
  line-height: 1.4;
  color: #cbd5e1;
  max-width: 26rem;
}
.card-zoom #sheet-form { margin-top: .15rem; width: 100%; }
.card-zoom #sheet-actions { display: grid; gap: .5rem; margin-top: .1rem; width: 100%; }
.card-zoom.is-list .card-zoom-frame { width: 100%; }
.card-zoom.is-list .card-zoom-x {
  position: fixed;
  top: max(.55rem, env(safe-area-inset-top));
  right: max(.55rem, env(safe-area-inset-right));
}
.card-zoom.is-list #sheet-card:empty { display: none; }
.card-zoom.is-list .card-zoom-inner {
  background: rgba(15, 23, 42, .92);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 1.25rem;
  padding: 1.1rem .9rem .9rem;
  width: min(36rem, 100%);
}
.systems-board {
  width: 100%;
  display: grid;
  gap: .45rem;
  padding: .45rem .5rem .5rem;
  border-radius: 1rem;
  background: rgba(2, 6, 23, .55);
  border: 1px solid rgba(251, 191, 36, .28);
  max-height: min(42dvh, 22rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.systems-board-title {
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #fde68a;
}
.systems-board-row {
  display: grid;
  gap: .28rem;
  padding: .4rem .45rem;
  border-radius: .75rem;
  background: rgba(255,255,255,.04);
}
.systems-board-row.is-me {
  background: rgba(251, 191, 36, .12);
  outline: 1px solid rgba(251, 191, 36, .35);
}
.systems-board-who {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .82rem;
  font-weight: 800;
  color: #e2e8f0;
}
.systems-board-self {
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: #fbbf24;
  background: rgba(251, 191, 36, .15);
  border-radius: 999px;
  padding: .12rem .4rem;
}
.systems-board-planets {
  display: flex;
  flex-wrap: wrap;
  gap: .28rem;
}
.systems-board-chip {
  border-radius: 999px;
  padding: .28rem .55rem;
  font-size: .78rem;
  font-weight: 800;
  color: #f8fafc;
  background: #1b2547;
  border: 1px solid rgba(255,255,255,.14);
  touch-action: manipulation;
}
.systems-board-chip.is-pick {
  background: #0e7490;
  border-color: #67e8f9;
}
.systems-board-empty {
  font-size: .72rem;
  color: #94a3b8;
}
.systems-board-glitch {
  font-size: .72rem;
  font-weight: 800;
  color: #f9a8d4;
}
@media (orientation: portrait) {
  .card-zoom.is-meteor:not(.is-list) #sheet-card .card-lg {
    width: min(6.8rem, 26vw);
  }
  .card-zoom.is-meteor:not(.is-list) #sheet-title { font-size: 1.12rem; }
  .card-zoom.is-meteor:not(.is-list) #sheet-desc { font-size: .8rem; max-width: none; }
  .card-zoom.is-meteor .systems-board { max-height: min(48dvh, 24rem); }
}
@media (orientation: landscape) {
  .card-zoom.is-meteor:not(.is-list) .card-zoom-side {
    max-width: min(28rem, 58vw);
  }
  .card-zoom.is-meteor .systems-board { max-height: min(58dvh, 20rem); }
}
@media (orientation: landscape) {
  .card-zoom:not(.is-list) {
    align-items: stretch;
  }
  .card-zoom:not(.is-list) .card-zoom-inner {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
    gap: .65rem 1rem;
  }
  .card-zoom:not(.is-list) .card-zoom-frame {
    flex: 0 0 auto;
  }
  .card-zoom:not(.is-list) #sheet-card .card-lg {
    width: min(15.5rem, 44vw, calc((100dvh - 1.2rem) * 5 / 7));
    height: auto;
  }
  .card-zoom:not(.is-list) .card-zoom-side {
    flex: 1 1 14rem;
    min-width: 11.5rem;
    max-width: 24rem;
    max-height: calc(100dvh - 1rem);
    overflow-y: auto;
    align-items: stretch;
    justify-content: center;
  }
  .card-zoom:not(.is-list) #sheet-title,
  .card-zoom:not(.is-list) #sheet-desc {
    text-align: left;
  }
  .card-zoom:not(.is-list) #sheet-actions .btn-primary,
  .card-zoom:not(.is-list) #sheet-actions .btn-secondary,
  .card-zoom:not(.is-list) #sheet-actions .btn-danger,
  .card-zoom:not(.is-list) #sheet-actions .btn-ghost {
    padding: .55rem .8rem;
    font-size: .88rem;
  }
}

/* fajták szerinti hátterek */
.kind-planet  { background: linear-gradient(160deg, #155e75, #0e7490 45%, #164e63); }
.kind-sun     { background: linear-gradient(160deg, #f59e0b, #d97706 50%, #92400e); }
.kind-joker   { background: linear-gradient(160deg, #a21caf, #7e22ce 55%, #4c1d95); }
.kind-attack  { background: linear-gradient(160deg, #be123c, #9f1239 55%, #500724); }
.kind-defense { background: linear-gradient(160deg, #15803d, #166534 55%, #052e16); }
.kind-special { background: linear-gradient(160deg, #4338ca, #3730a3 55%, #1e1b4b); }

/* Kategória-aura: piros támadó, zöld védekező, pink bolygó */
.card.aura-attack {
  box-shadow: 0 0 0 2.5px #ef4444, 0 0 14px 4px rgba(239, 68, 68, .62), 0 3px 10px rgba(0,0,0,.4);
}
.card.aura-defense {
  box-shadow: 0 0 0 2.5px #22c55e, 0 0 14px 4px rgba(34, 197, 94, .55), 0 3px 10px rgba(0,0,0,.4);
}
.card.aura-planet {
  box-shadow: 0 0 0 2.5px #a855f7, 0 0 14px 4px rgba(168, 85, 247, .6), 0 3px 10px rgba(0,0,0,.4);
}
.card-sm.aura-attack { box-shadow: 0 0 0 2px #ef4444, 0 0 8px 2px rgba(239, 68, 68, .55); }
.card-sm.aura-defense { box-shadow: 0 0 0 2px #22c55e, 0 0 8px 2px rgba(34, 197, 94, .5); }
.card-sm.aura-planet { box-shadow: 0 0 0 2px #a855f7, 0 0 8px 2px rgba(168, 85, 247, .55); }
.combat-chain .card-combat.is-top.aura-attack {
  box-shadow: 0 0 0 2px #fbbf24, 0 0 16px 4px rgba(239, 68, 68, .55), 0 12px 28px rgba(0,0,0,.5);
}
.combat-chain .card-combat.is-top.aura-defense {
  box-shadow: 0 0 0 2px #fbbf24, 0 0 16px 4px rgba(34, 197, 94, .5), 0 12px 28px rgba(0,0,0,.5);
}

.card-back {
  background:
    radial-gradient(circle at 50% 35%, rgba(139,92,246,.5), transparent 60%),
    repeating-linear-gradient(45deg, #121a33 0 6px, #1b2547 6px 12px);
  background-size: cover; background-position: center;
  background-image: url('../img/box-front.jpg');
}

/* Márkaillusztráció a lobby / váró / szabály / admin fejlécekben */
.kk-logo-hero {
  width: min(100%, 22rem);
  height: auto;
  border-radius: 1rem;
  display: block;
  margin-inline: auto;
}
.kk-logo-md {
  width: min(100%, 14rem);
  height: auto;
  border-radius: .75rem;
  display: block;
  margin-inline: auto;
}
.kk-logo-sm {
  height: 2.75rem;
  width: auto;
  border-radius: .45rem;
  background: #070b18;
}

/* Honlapra vezető sáv a playtest tetején */
.kk-home-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .85rem;
  width: 100%;
  flex-shrink: 0;
  padding: calc(.65rem + env(safe-area-inset-top, 0px)) 1rem .7rem;
  background: rgba(18, 26, 51, .94);
  border-bottom: 2px solid rgba(251, 191, 36, .55);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  text-decoration: none;
  color: inherit;
  z-index: 30;
}
.kk-home-bar img {
  height: 2.85rem;
  width: auto;
  max-width: 9.5rem;
  object-fit: contain;
  background: #f7faf6;
  border-radius: .5rem;
  padding: .2rem .45rem;
  flex-shrink: 0;
}
.kk-home-bar-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
  min-width: 0;
}
.kk-home-bar-text strong {
  color: #fde68a;
  font-size: 1.05rem;
  font-weight: 800;
}
.kk-home-bar-text span {
  color: #cbd5e1;
  font-size: .88rem;
}
.kk-home-bar:hover,
.kk-home-bar:focus-visible {
  background: rgba(39, 53, 106, .95);
  outline: none;
}
.kk-home-bar:active { transform: scale(.995); }

.kk-rules-cta {
  display: block;
  width: 100%;
  max-width: 64rem;
  text-align: center;
  text-decoration: none;
  border-radius: 0.95rem;
  padding: 0.95rem 1.25rem;
  font-weight: 800;
  font-size: 1.15rem;
  color: #0b1020;
  background: linear-gradient(135deg, #fde68a, #fbbf24);
  box-shadow: 0 6px 20px rgba(251, 191, 36, .35);
  border: 1px solid rgba(253, 230, 138, .7);
  touch-action: manipulation;
}
.kk-rules-cta:active { transform: scale(.97); }

.btn-rules-ingame {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  flex-shrink: 0;
  border-radius: 999px;
  padding: .42rem .7rem;
  font-weight: 800;
  font-size: .78rem;
  font-family: inherit;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
  color: #0b1020;
  background: linear-gradient(135deg, #fde68a, #fbbf24);
  border: 1px solid rgba(253, 230, 138, .75);
  box-shadow: 0 4px 14px rgba(251, 191, 36, .35);
  touch-action: manipulation;
  white-space: nowrap;
}
.btn-rules-ingame:active { transform: scale(.96); }

.rules-modal {
  position: fixed;
  inset: 0;
  z-index: 54;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: max(.4rem, env(safe-area-inset-top)) max(.4rem, env(safe-area-inset-right)) max(.4rem, env(safe-area-inset-bottom)) max(.4rem, env(safe-area-inset-left));
  background: rgba(0, 0, 0, .78);
}
.rules-modal.hidden { display: none; }
.rules-modal-panel {
  display: flex;
  flex-direction: column;
  width: min(52rem, 100%);
  height: 100%;
  border-radius: 1rem;
  overflow: hidden;
  background: #070b18;
  border: 1px solid rgba(255, 255, 255, .12);
}
.rules-modal-bar {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-shrink: 0;
  padding: .55rem .7rem;
  background: #121a33;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.rules-modal-bar h2 {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: .95rem;
  font-weight: 800;
  color: #fde68a;
}
.rules-modal-bar #rules-modal-close {
  flex-shrink: 0;
  white-space: nowrap;
}
.rules-modal-frame {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #070b18;
}

/* kiválasztott lap a kézben */
.card.is-selected { transform: translateY(-.6rem) scale(1.05); box-shadow: 0 0 0 2px #fbbf24, 0 10px 24px rgba(0,0,0,.6); }
/* zárolt lap (Féreglyuk) */
.card.is-locked { filter: saturate(.5) brightness(.75); }
.card.is-locked::after { content: '🔒'; position: absolute; top: .2rem; right: .2rem; font-size: .7rem; }
/* húzás alatt álló lap az átrendezésnél */
.card.is-dragging { opacity: .65; transform: scale(1.1); z-index: 5;
  box-shadow: 0 0 0 2px #38bdf8, 0 12px 28px rgba(0,0,0,.7); }
/* Glitch figyelmeztető keret */
.card.is-glitch { animation: glitch-glow 1.6s ease-in-out infinite; }
@keyframes glitch-glow { 50% { filter: brightness(1.18) saturate(1.2); } }

/* ---- paklik ---- */
.pile { position: relative; display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.pile-card { width: 4.6rem; height: 6.5rem; border-radius: .7rem; border: 1px solid rgba(255,255,255,.15);
  box-shadow: 2px 2px 0 #0d1430, 4px 4px 0 #0a0f26; }
.pile-card-discard { background: linear-gradient(160deg,#334155,#1e293b); }
.pile-count { position: absolute; top: 2.3rem; font-size: 1.5rem; font-weight: 900;
  text-shadow: 0 2px 4px rgba(0,0,0,.8); }
.pile-label { font-size: .82rem; color: #94a3b8; font-weight: 600; }

/* ---- ellenfél-panelek ---- */
.opp {
  flex: 0 0 auto; min-width: 10rem; max-width: 16rem;
  background: rgba(18,26,51,.85); border: 1px solid rgba(255,255,255,.08);
  border-radius: .9rem; padding: .5rem .7rem;
}
.opp.is-turn { border-color: #f59e0b; box-shadow: 0 0 12px rgba(245,158,11,.35); }
.opp.is-target { border-color: #f43f5e; box-shadow: 0 0 0 2px #f43f5e; }
.opp-row { display: flex; align-items: center; gap: .4rem; font-size: .95rem; font-weight: 700; }
.opp-hand { margin-left: auto; font-weight: 600; color: #94a3b8; font-size: .85rem; }
.opp-planets {
  font-weight: 700; font-size: .8rem; color: #fbbf24;
  background: rgba(251, 191, 36, .12); border: 1px solid rgba(251, 191, 36, .35);
  border-radius: 999px; padding: .1rem .5rem; white-space: nowrap;
}
.opp-glitch {
  font-size: .95rem; line-height: 1;
  background: rgba(217, 70, 239, .2); border: 1px solid rgba(217, 70, 239, .6);
  border-radius: 999px; padding: .1rem .4rem;
  animation: glitch-pulse 1.4s ease-in-out infinite;
}
.opp-next {
  flex: 0 0 auto;
  align-self: center;
  color: #64748b;
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1;
  opacity: .8;
  pointer-events: none;
}
@keyframes glitch-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 70, 239, .5); }
  50% { box-shadow: 0 0 10px 2px rgba(217, 70, 239, .7); }
}
.opp-system { display: flex; gap: .2rem; margin-top: .3rem; overflow-x: auto; scrollbar-width: none; }

/* saját naprendszer: hosszú nyomásos drag — kijelölés/callout tiltva */
#my-system .card,
#my-system .card * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
#my-system .card img { pointer-events: none; }
.opp-system::-webkit-scrollbar { display: none; }

/* ---- animációk ---- */
@keyframes pop { 0% { transform: scale(.85); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.animate-pop { animation: pop .18s ease-out; }

@keyframes flip-in {
  0%   { transform: rotateY(90deg) scale(.8); opacity: 0; }
  100% { transform: rotateY(0) scale(1); opacity: 1; }
}
.flip-in { animation: flip-in .35s ease-out backwards; }

@keyframes spin-slow { to { transform: rotate(90deg); } }
.animate-spin-slow { animation: spin-slow 1.2s ease-in-out infinite alternate; }

@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }
.shake { animation: shake .3s ease; }

@keyframes turn-nudge-shake {
  0%, 100% { transform: translateX(0); }
  12% { transform: translateX(-12px) rotate(-0.5deg); }
  24% { transform: translateX(12px) rotate(0.5deg); }
  36% { transform: translateX(-9px) rotate(-0.35deg); }
  48% { transform: translateX(9px) rotate(0.35deg); }
  60% { transform: translateX(-6px); }
  72% { transform: translateX(6px); }
  84% { transform: translateX(-3px); }
}
#view-game.turn-nudge {
  animation: turn-nudge-shake .5s ease-in-out infinite;
}
.turn-nudge-banner {
  position: fixed;
  left: 50%;
  top: max(5.8rem, calc(env(safe-area-inset-top) + 4.6rem));
  transform: translateX(-50%);
  z-index: 61;
  pointer-events: none;
  max-width: min(26rem, calc(100% - 1.5rem));
  padding: .85rem 1.25rem;
  border-radius: 1.15rem;
  text-align: center;
  font-weight: 900;
  font-size: 1.45rem;
  line-height: 1.2;
  letter-spacing: .02em;
  color: #fff7ed;
  background: linear-gradient(135deg, rgba(220, 38, 38, .94), rgba(234, 88, 12, .92));
  border: 2px solid rgba(254, 243, 199, .85);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .35), 0 16px 40px rgba(0,0,0,.55);
  animation: turn-nudge-pulse 1s ease-in-out infinite;
}
.turn-nudge-banner.is-mine { pointer-events: auto; }
.turn-nudge-here {
  display: block;
  margin: .7rem auto 0;
  padding: .55rem .9rem;
  border-radius: .8rem;
  border: 1.5px solid rgba(254, 243, 199, .9);
  background: rgba(255, 255, 255, .16);
  color: #fffbeb;
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
  pointer-events: auto;
}
.turn-nudge-here:active { transform: scale(.96); filter: brightness(1.15); }
.turn-nudge-here.hidden,
.turn-nudge-banner:not(.is-mine) .turn-nudge-here { display: none; }
.my-system-label {
  display: flex;
  align-items: center;
  gap: .35rem;
  min-width: 0;
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
}
.my-system-label:active { opacity: .75; }
.turn-nudge-banner small {
  display: block;
  margin-top: .25rem;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: 0;
  color: #ffedd5;
}
@keyframes turn-nudge-pulse {
  50% { filter: brightness(1.18); transform: translateX(-50%) scale(1.04); }
}

/* =====================================================================
   Reszponzív játéktér — a játékos szabadon választhat álló/fekvő tájolást
   ===================================================================== */

/* Az ellenfél-sáv sose nyomja össze a játékteret. */
#opponents { align-items: flex-start; max-height: 34dvh; overflow-y: auto; }
#opponents .opp { overflow: hidden; }
@media (max-height: 500px) {
  #opponents { max-height: 30dvh; }
}

/* Telefonon az ellenfelek mini kártyasora rejtve — csak név + számlálók
   (🪐 lent lévő lapok, ✋ kéz, 👾 Glitch); koppintásra nyílik a grafikus nézet. */
@media (max-width: 820px), (max-height: 500px) {
  .opp .opp-mini { display: none; }
  .opp { min-width: 0; max-width: none; }
}
/* A saját naprendszer sora mindig kapjon helyet. */
#my-system { min-height: 5rem; }

/* ---- FEKVŐ telefon (alacsony viewport): minden kompaktabb ---- */
@media (max-height: 500px) {
  #btn-my-system {
    color: #fde68a;
    border-style: solid;
    border-color: rgba(251, 191, 36, .5);
    background: rgba(251, 191, 36, .12);
  }
  #hand .card { width: 4.9rem; height: 6.9rem; }
  #hand .card.has-img .card-name { font-size: .5rem; padding: .15rem .1rem; }
  #my-system .card { width: 4.2rem; height: 5.9rem; }
  #my-system .card.has-img .card-name { font-size: .46rem; }
  #my-system { min-height: 4.2rem; }
  .pile-card { width: 3.4rem; height: 4.8rem; }
  .pile-count { top: 1.55rem; font-size: 1.1rem; }
  .pile-label { font-size: .7rem; }
  #piles { width: 4.6rem; gap: .4rem; }
  .opp { min-width: 8rem; max-width: 12rem; padding: .3rem .5rem; }
  .opp-row { font-size: .78rem; }
  .opp-hand { font-size: .72rem; }
  .opp-planets { font-size: .68rem; padding: .05rem .4rem; }
  .opp-system .card-sm { width: 2.2rem; height: 3.1rem; }
  .act-btn { padding: .5rem .85rem; font-size: .85rem; }
}

/* ---- ÁLLÓ tájolás: paklik vízszintben, nagyobb kéz, több sor hely ---- */
@media (orientation: portrait) {
  /* a játéktér oszloppá válik: paklik felül egy sorban, alatta a rendszer */
  #view-game main { flex-direction: column; gap: .25rem; }
  #piles {
    flex-direction: row; width: 100%; justify-content: center;
    align-items: flex-start; gap: 2.5rem; padding: .25rem 0;
  }
  .pile { flex-direction: column; }
  .pile-card { width: 3.6rem; height: 5.1rem; }
  .pile-count { top: 1.7rem; font-size: 1.15rem; }
  .pile-label { font-size: .72rem; }
  /* a saját naprendszer 2 sorba törhet, függőlegesen görgethető */
  #my-system { flex-wrap: wrap; overflow-y: auto; overflow-x: hidden;
    align-content: flex-start; justify-content: center; }
  #my-system .card { width: 4.4rem; height: 6.2rem; }
  #my-system .card.has-img .card-name { font-size: .48rem; }
  .opp { min-width: 8.5rem; max-width: 13rem; padding: .35rem .55rem; }
  .opp-row { font-size: .82rem; }
  .opp-system .card-sm { width: 2.4rem; height: 3.4rem; }
}

/* ---- ÁLLÓ mobiltelefon: több hely a játéktérnek, kevésbé fontos panelek lenyithatók ---- */
@media (orientation: portrait) and (max-width: 820px) {
  .game-top {
    padding: .35rem .4rem .2rem;
    gap: .35rem;
    align-items: stretch;
  }
  .game-fold-toggle { display: flex; }
  .game-tools-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.35rem;
    padding: .4rem .5rem;
    font-size: 1.1rem;
    line-height: 1;
  }
  .game-tools-wrap {
    position: relative;
    align-self: flex-start;
  }
  #game-tools.game-tools-menu {
    display: none;
    position: absolute;
    top: calc(100% + .25rem);
    right: 0;
    z-index: 45;
    flex-direction: column;
    align-items: stretch;
    gap: .28rem;
    min-width: 9.5rem;
    padding: .35rem;
    border-radius: .75rem;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(11, 16, 32, .96);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .45);
  }
  .game-tools-wrap--open #game-tools.game-tools-menu { display: flex; }
  #game-tools .act-btn,
  #game-tools .btn-rules-ingame {
    padding: .42rem .55rem;
    min-width: 0;
    text-align: center;
    background: rgba(18, 26, 51, .9);
  }
  #game-tools .btn-rules-ingame {
    background: linear-gradient(135deg, #fde68a, #fbbf24);
    color: #0b1020;
  }
  #opponents.opponents-strip {
    max-height: 0 !important;
    overflow: hidden;
    opacity: 0;
    padding: 0;
    transition: max-height .2s ease, opacity .15s ease;
  }
  .game-top-opponents--open #opponents.opponents-strip {
    max-height: 13dvh !important;
    overflow-x: auto;
    overflow-y: auto;
    opacity: 1;
    padding-bottom: .1rem;
  }
  #view-game main {
    flex-direction: column;
    gap: .2rem;
    padding-left: .35rem;
    padding-right: .35rem;
  }
  #view-game main > section {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  #piles {
    flex-direction: row;
    width: 100%;
    justify-content: center;
    align-items: flex-start;
    gap: 1.75rem;
    padding: .15rem 0;
    flex-shrink: 0;
  }
  .pile-card { width: 3.2rem; height: 4.55rem; }
  .pile-count { top: 1.45rem; font-size: 1rem; }
  .pile-label { font-size: .68rem; }
  #my-system {
    flex: 1 1 auto;
    min-height: 4.5rem;
    flex-wrap: wrap;
    overflow-y: auto;
    overflow-x: hidden;
    align-content: flex-start;
    justify-content: center;
    padding-top: .1rem;
    padding-bottom: .1rem;
  }
  #my-system .card { width: 4rem; height: 5.65rem; }
  #my-system .card.has-img .card-name { font-size: .44rem; }
  #btn-my-system-label span:not(.font-semibold) { display: none; }
  #view-game main > section > .flex.items-center {
    font-size: .76rem;
    padding-top: 0;
    gap: .35rem;
    flex-wrap: wrap;
  }
  #match-timer { font-size: .7rem; margin-left: 0; }
  #turn-chip {
    font-size: .72rem;
    padding: .18rem .5rem;
    max-width: 100%;
    white-space: normal;
    line-height: 1.2;
  }
  #status-line {
    font-size: .7rem;
    padding-bottom: 0;
    flex-shrink: 0;
  }
  #hand .card { width: 4.75rem; height: 6.7rem; }
  #hand .card.has-img .card-name { font-size: .5rem; }
  #hand { padding-top: .25rem; padding-bottom: .45rem; }
  #action-bar {
    padding: .2rem .35rem;
    flex-wrap: wrap;
    gap: .35rem;
  }
  #action-bar .act-btn { padding: .45rem .7rem; font-size: .82rem; }
  #action-bar .kk-next-act-text { font-size: .75rem; line-height: 1.25; }
  .combat-stack {
    top: max(4.2rem, calc(env(safe-area-inset-top) + 3.2rem));
    max-width: min(72vw, 20rem);
  }
}

/* Nagyon keskeny álló kijelzőn még kompaktabb kéz. */
@media (orientation: portrait) and (max-width: 420px) {
  #hand .card { width: 4.45rem; height: 6.25rem; }
  #hand .card.has-img .card-name { font-size: .46rem; }
  #my-system .card { width: 3.7rem; height: 5.2rem; }
}

/* Lobby: létrehozás és csatlakozás egymás mellett (fekvő / széles nézet). */
.lobby-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: start;
}
@media (orientation: landscape), (min-width: 720px) {
  .lobby-actions { grid-template-columns: 1fr 1fr; }
}
.lobby-rank { grid-column: 1 / -1; }

#view-lobby.is-invite #lobby-howto,
#view-lobby.is-invite #lobby-create,
#view-lobby.is-invite #lobby-rankboard,
#view-lobby.is-invite #lobby-tried-counter,
#view-lobby.is-invite .kk-rules-cta,
#view-lobby.is-invite .kk-spar-callout,
#view-lobby.is-invite .lobby-invite-hide,
#view-lobby.is-invite #lobby-code-wrap {
  display: none !important;
}
#view-lobby.is-invite .lobby-actions {
  grid-template-columns: 1fr;
  max-width: 28rem;
  margin-inline: auto;
}

.kk-invite {
  width: 100%;
  text-align: center;
  padding: 1.1rem 1.05rem 1.15rem;
  border-radius: 1.15rem;
  background: linear-gradient(165deg, rgba(251, 191, 36, .22), rgba(11, 16, 32, .88) 55%);
  border: 2px solid rgba(251, 191, 36, .75);
  box-shadow: 0 10px 32px rgba(251, 191, 36, .22);
}
.kk-invite-kicker {
  margin: 0;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #fde68a;
}
.kk-invite-title {
  margin: .2rem 0 .45rem;
  font-size: 1.35rem;
  font-weight: 900;
  color: #fff7ed;
  line-height: 1.2;
}
.kk-invite-lead {
  margin: 0 0 .85rem;
  font-size: .92rem;
  line-height: 1.45;
  color: #e2e8f0;
}
.kk-invite-url {
  display: block;
  width: 100%;
  margin: 0 0 .85rem;
  padding: .7rem .75rem;
  border-radius: .8rem;
  border: 1px solid rgba(253, 230, 138, .45);
  background: rgba(7, 11, 24, .75);
  color: #fde68a;
  font-size: .82rem;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-all;
  text-align: left;
  user-select: all;
  -webkit-user-select: all;
  touch-action: manipulation;
}
.kk-invite-url:active { transform: scale(.995); }
.kk-invite-actions {
  display: grid;
  gap: .5rem;
}
.kk-invite-banner {
  text-align: left;
  padding: .8rem .9rem;
  border-radius: .9rem;
  background: linear-gradient(165deg, rgba(34, 211, 238, .18), rgba(11, 16, 32, .7));
  border: 1px solid rgba(34, 211, 238, .45);
}
.kk-invite-banner p { margin: 0; color: #e2e8f0; font-size: .9rem; line-height: 1.4; }
.kk-invite-banner .kk-invite-kicker { margin-bottom: .2rem; color: #67e8f9; }

/* Nyilvános ranglista (lobby + honlap közös osztályok) */
.kk-rankboard { display: grid; gap: .7rem; color: inherit; }
.kk-rankboard-podium {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: .4rem;
}
.kk-rankboard-podium li,
.kk-rankboard-list li {
  display: grid;
  grid-template-columns: 2.1rem 1fr auto;
  align-items: baseline;
  gap: .55rem;
  padding: .35rem .55rem;
  border-radius: .7rem;
  background: rgba(255,255,255,.05);
}
.kk-rankboard-podium .is-gold { background: rgba(251,191,36,.16); }
.kk-rankboard-podium .is-silver { background: rgba(203,213,225,.12); }
.kk-rankboard-podium .is-bronze { background: rgba(180,83,9,.16); }
.kk-rankboard-place { font-weight: 800; font-variant-numeric: tabular-nums; color: #fde68a; }
.kk-rankboard-name { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kk-rankboard-pts { font-variant-numeric: tabular-nums; color: #cbd5e1; font-size: .9em; }
.kk-rankboard-empty { margin: 0; font-size: .85rem; color: #94a3b8; }
.kk-tried-counter {
  margin: 0;
  width: 100%;
  max-width: 64rem;
  padding: .7rem .85rem;
  border-radius: .75rem;
  background: rgba(251, 191, 36, .16);
  color: #fde68a;
  font-size: .95rem;
  line-height: 1.35;
  text-align: center;
}
.kk-tried-counter strong {
  color: #fff;
  font-size: 1.35rem;
  font-weight: 800;
}
.kk-idle-note {
  width: 100%;
  max-width: 32rem;
  text-align: left;
  padding: .95rem 1.05rem;
  border-radius: .95rem;
  background: linear-gradient(165deg, rgba(251, 191, 36, .2), rgba(11, 16, 32, .86) 58%);
  border: 1.5px solid rgba(251, 191, 36, .6);
  box-shadow: 0 8px 24px rgba(251, 191, 36, .14);
  color: #e2e8f0;
  font-size: .95rem;
  line-height: 1.5;
}
.kk-idle-note-title {
  margin: 0 0 .4rem;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #fde68a;
}
.kk-idle-note p { margin: 0; }
.kk-idle-note strong { color: #fff7ed; font-weight: 800; }

.kk-spar-callout {
  margin: 0;
  width: 100%;
  max-width: 64rem;
  padding: .85rem 1rem;
  border-radius: .75rem;
  background: rgba(251, 191, 36, .2);
  border: 1px solid rgba(251, 191, 36, .45);
  color: #fde68a;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}
.kk-rankboard-full, .kk-rankboard-how {
  border: 1px solid rgba(255,255,255,.1);
  border-radius: .8rem;
  padding: .15rem .7rem .55rem;
  background: rgba(7,11,24,.35);
}
.kk-rankboard-full summary,
.kk-rankboard-how summary {
  cursor: pointer;
  font-weight: 700;
  padding: .45rem 0;
  color: #fde68a;
}
.kk-rankboard-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: .28rem;
  max-height: 16rem; overflow: auto;
}
.kk-rankboard-how p { margin: .35rem 0; font-size: .82rem; line-height: 1.45; color: #cbd5e1; }
.kk-rankboard-how table { width: 100%; border-collapse: collapse; font-size: .82rem; margin: .4rem 0; }
.kk-rankboard-how th, .kk-rankboard-how td {
  text-align: left; padding: .22rem .35rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.kk-rankboard-how ul { margin: .2rem 0 0; padding-left: 1.1rem; font-size: .8rem; color: #94a3b8; line-height: 1.4; }
.kk-match-rank {
  border: 1px solid rgba(253,230,138,.25);
  background: rgba(251,191,36,.08);
  border-radius: .9rem;
  padding: .7rem .8rem;
}
.kk-match-rank h3 { margin: 0 0 .4rem; font-size: .95rem; color: #fde68a; }
.kk-match-rank p { margin: 0 0 .4rem; }
.kk-match-rank-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: .4rem;
  font-size: .85rem;
  padding: .2rem 0;
  border-top: 1px solid rgba(255,255,255,.08);
}
.kk-match-rank-row.is-you { color: #fde68a; font-weight: 700; }
.kk-match-rank-delta { font-variant-numeric: tabular-nums; }
.kk-match-rank-total { font-variant-numeric: tabular-nums; color: #cbd5e1; }
@media (orientation: landscape) and (max-height: 500px) {
  #view-lobby { gap: 0; }
  #view-lobby .kk-logo-hero { width: min(100%, 11rem); }
  #lobby-howto { display: none; }
  #lobby-code, #create-code { font-size: 1.15rem; padding: .4rem .55rem; }
  .kk-home-bar { padding: calc(.35rem + env(safe-area-inset-top, 0px)) .75rem .4rem; gap: .55rem; }
  .kk-home-bar img { height: 2.1rem; max-width: 7.5rem; }
  .kk-home-bar-text strong { font-size: .92rem; }
  .kk-home-bar-text span { font-size: .75rem; }
  .kk-rules-cta { padding: .55rem .9rem; font-size: 1rem; }
}

/* Állandó eseménynapló (chat) — fekvőn jobb oszlop, állón alsó sáv */
.event-feed {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 0 0 15.25rem;
  width: 15.25rem;
  max-width: 100%;
  background: rgba(11, 16, 32, .78);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: .85rem;
  overflow: hidden;
}
.event-feed-head {
  display: block;
  width: 100%;
  text-align: left;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #94a3b8;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  padding: .4rem .65rem;
  cursor: pointer;
}
.event-feed-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: .4rem .5rem .55rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.event-line {
  background: rgba(27, 37, 71, .55);
  border: 1px solid rgba(255, 255, 255, .08);
  border-left: 3px solid rgba(139, 92, 246, .55);
  border-radius: .55rem;
  padding: .4rem .5rem;
}
.event-line--you {
  border-left-color: #fbbf24;
  background: rgba(251, 191, 36, .08);
}
.event-line--new {
  animation: event-flash 1.6s ease-out;
}
.event-line-head {
  display: flex;
  align-items: baseline;
  gap: .4rem;
}
.event-line-time {
  flex: 0 0 auto;
  font-size: .65rem;
  font-family: ui-monospace, monospace;
  color: #64748b;
}
.event-line-title {
  font-weight: 700;
  font-size: .8rem;
  line-height: 1.3;
  color: #e2e8f0;
}
.event-line-body {
  margin-top: .18rem;
  font-size: .72rem;
  line-height: 1.35;
  color: #94a3b8;
}
.event-line-empty {
  font-size: .75rem;
  color: #64748b;
  padding: .35rem .15rem;
}
@keyframes event-flash {
  from { box-shadow: 0 0 0 1px rgba(167, 139, 250, .55); background: rgba(139, 92, 246, .18); }
  to   { box-shadow: none; }
}

/* Megfigyelőnek külön élő napló van a kéz helyén */
#view-game.is-spectate .event-feed { display: none; }

/* Álló: alsó, keskeny chat-sáv — alapból csak fejléc, koppintásra nyílik */
@media (orientation: portrait) {
  .event-feed {
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    max-height: none;
  }
  .event-feed-log {
    display: none;
    max-height: min(28dvh, 11rem);
  }
  .event-feed--expanded .event-feed-log {
    display: flex;
  }
  .event-feed--expanded {
    height: auto;
    max-height: min(32dvh, 12rem);
  }
  .event-feed-head::after {
    content: " · koppints a megnyitáshoz";
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: #64748b;
  }
  .event-feed--expanded .event-feed-head::after {
    content: " · koppints a bezáráshoz";
  }
}

@media (orientation: portrait) and (max-width: 820px) {
  .event-feed-head {
    padding: .32rem .55rem;
    font-size: .64rem;
  }
  .event-feed-log {
    max-height: min(22dvh, 9rem);
    padding: .3rem .45rem .4rem;
  }
  .event-feed--expanded {
    max-height: min(28dvh, 10.5rem);
  }
}

/* Fekvő telefon: keskenyebb jobb oszlop, kisebb betű */
@media (orientation: landscape) and (max-height: 500px) {
  .event-feed {
    flex-basis: 11.25rem;
    width: 11.25rem;
  }
  .event-line { padding: .28rem .4rem; }
  .event-line-title { font-size: .7rem; }
  .event-line-body { font-size: .64rem; }
  .event-feed-head { padding: .28rem .5rem; }
}

@media (orientation: landscape) and (max-width: 820px) {
  .event-feed {
    flex-basis: 12rem;
    width: 12rem;
  }
}

@media (orientation: landscape) and (max-width: 700px) and (max-height: 430px) {
  .event-line-body { display: none; }
}

#view-game.is-spectate #hand {
  display: flex; flex-direction: column; align-items: stretch;
  max-height: 32vh; overflow: hidden; gap: .25rem; padding-bottom: .4rem;
}
.live-log-head {
  font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: #fbbf24; padding: 0 .5rem;
}
.live-log {
  flex: 1; overflow-y: auto; background: rgba(11,16,32,.75);
  border: 1px solid rgba(255,255,255,.08); border-radius: .7rem;
  padding: .35rem .5rem; min-height: 4.5rem;
}
.live-log-line { display: flex; gap: .45rem; align-items: baseline; line-height: 1.35; }
.live-log-time { flex: 0 0 3.4rem; font-size: .65rem; font-family: ui-monospace, monospace; color: #64748b; }
.live-log-who { flex: 0 0 auto; max-width: 9rem; font-size: .7rem; font-weight: 700; color: #fbbf24; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-log-text { font-size: .72rem; color: #e2e8f0; }

.spar-prize-warn {
  font-size: .88rem;
  color: #fde68a;
  text-align: left;
  line-height: 1.4;
  margin: 0 0 .6rem;
}
.spar-prize-mail {
  width: 100%;
  padding: .75rem .8rem;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: .8rem;
  background: rgba(11,16,32,.55);
  margin-bottom: .7rem;
}
.spar-survey-modal {
  position: fixed; inset: 0; z-index: 72;
  display: flex; align-items: flex-start; justify-content: center;
  background: rgba(0,0,0,.78); backdrop-filter: blur(8px);
  padding: 1rem; overflow: auto;
}
.spar-survey-modal.hidden { display: none; }
.spar-survey-panel {
  width: min(42rem, 100%);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: #121a33;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 1.1rem;
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
}
.spar-survey-bar { padding: 1rem 1.1rem .4rem; }
.spar-survey-bar h2 { margin: 0; font-size: 1.15rem; color: #fde68a; }
.spar-survey-intro { padding: 0 1.1rem 0.8rem; font-size: .88rem; color: #cbd5e1; line-height: 1.45; }
.spar-survey-intro p { margin: 0 0 .45rem; }
.spar-survey-req { color: #fda4af !important; font-weight: 700; }
.spar-survey-form { padding: 0 1.1rem 1rem; display: grid; gap: .9rem; }
.spar-q {
  margin: 0; padding: .75rem .8rem;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: .8rem;
  background: rgba(11,16,32,.55);
}
.spar-q legend { font-weight: 700; color: #e2e8f0; padding-bottom: .4rem; }
.spar-opt { display: flex; gap: .45rem; align-items: flex-start; font-size: .88rem; color: #cbd5e1; padding: .15rem 0; }
.spar-text {
  width: 100%; min-height: 4.5rem;
  border-radius: .7rem; border: 1px solid rgba(255,255,255,.12);
  background: #0b1020; color: #f1f5f9; padding: .55rem .7rem; font-size: .9rem;
}
.spar-scale { display: grid; gap: .35rem; }
.spar-scale-end { font-size: .75rem; color: #94a3b8; }
.spar-scale-nums {
  display: flex; flex-wrap: wrap; gap: .35rem;
}
.spar-scale-opt {
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  font-size: .75rem; min-width: 1.8rem;
}
.spar-survey-actions {
  display: flex; flex-wrap: wrap; gap: .5rem;
  padding: 0 1.1rem 1.1rem;
}

.kk-lang-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: .45rem .6rem;
  width: 100%;
  max-width: 28rem;
  margin: .15rem auto 0;
  padding: .55rem .7rem;
  border-radius: 1.1rem;
  border: 2px solid rgba(253, 230, 138, .7);
  background: linear-gradient(165deg, rgba(251, 191, 36, .18), rgba(11, 16, 32, .88));
  box-shadow: 0 8px 24px rgba(251, 191, 36, .18);
}
.kk-lang-kicker {
  width: 100%;
  text-align: center;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #fde68a;
}
.kk-lang-btn {
  flex: 1;
  min-width: 7.5rem;
  padding: .55rem .9rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(7, 11, 24, .65);
  color: #cbd5e1;
  font-weight: 800;
  font-size: .95rem;
  letter-spacing: .03em;
  touch-action: manipulation;
}
.kk-lang-btn.is-active {
  background: linear-gradient(135deg, #fde68a, #fbbf24);
  color: #0b1020;
  border-color: transparent;
}
.kk-lang-switch--compact {
  width: auto;
  max-width: none;
  margin: 0;
  padding: .2rem;
  gap: .2rem;
  border-width: 1px;
  box-shadow: none;
}
.kk-lang-switch--compact .kk-lang-kicker { display: none; }
.kk-lang-switch--compact .kk-lang-btn {
  flex: 0 0 auto;
  min-width: 0;
  padding: .28rem .55rem;
  font-size: .7rem;
}
