:root{
  --bg:#0b0f14;
  --card:#111826;
  --card2:#0f1623;
  --text:#e6edf3;
  --muted:#95a4b6;
  --accent:#4cc2ff;
  --good:#4ade80;
  --bad:#fb7185;
  --border:rgba(255,255,255,.08);
  --shadow: 0 12px 30px rgba(0,0,0,.35);
}

*{ box-sizing:border-box; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: radial-gradient(1000px 600px at 20% 0%, #12243a, var(--bg));
  color:var(--text);
}

.app{ min-height:100vh; }
.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:14px 18px;
  border-bottom:1px solid var(--border);
  background: rgba(0,0,0,.18);
  backdrop-filter: blur(8px);
}
.brand{ font-weight:800; letter-spacing:.5px; }
.status{ color:var(--muted); font-size:14px; }
.hidden{
  display:none !important;
}
.layout{
  display:grid;
  grid-template-columns: 340px 1fr;
  grid-template-rows: auto auto;
  gap:16px;
  padding:16px;
}
.card{
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow: var(--shadow);
  padding:14px;
}
.lobby{ grid-row: 1 / span 2; }
.board{ }
.hand{ }

h2{ margin:0 0 10px 0; font-size:18px; }
h3{ margin:14px 0 8px; font-size:14px; color:var(--muted); }
.muted{ color:var(--muted); font-size:13px; }

.row{ display:flex; gap:10px; margin:10px 0; }
.row.two{ display:grid; grid-template-columns: 1fr 1fr 1fr; gap:10px; }
input{
  width:100%;
  background: rgba(0,0,0,.25);
  border:1px solid var(--border);
  color:var(--text);
  border-radius:12px;
  padding:10px 12px;
  outline:none;
}
button{
  border:1px solid var(--border);
  background: rgba(255,255,255,.06);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
}
button:hover{ border-color: rgba(255,255,255,.2); }
button:disabled{ opacity:.5; cursor:not-allowed; }
button.primary{
  background: rgba(76,194,255,.18);
  border-color: rgba(76,194,255,.35);
}

ul{ padding-left:18px; margin:0; list-style-type: none;}
li{ margin:6px 0; color:var(--muted); list-style-type: none;}

.boardHeader{ display:flex; justify-content:space-between; align-items:baseline; }
.zones{ display:flex; flex-direction:column; gap:14px; margin-top:10px; }
.zoneTitle{
  font-size:12px;
  color:var(--muted);
  letter-spacing:.12em;
  text-transform:uppercase;
  margin-bottom:6px;
}
.zoneRow{
  min-height:92px;
  border-radius:14px;
  border:1px dashed rgba(255,255,255,.16);
  background: rgba(0,0,0,.18);
  padding:10px;
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}
@keyframes popIn {
  from { opacity:0; transform: translateY(8px) scale(.98); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}
.cardSlot{
  width:120px;
  height:72px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  position:relative;
  overflow:hidden;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:10px;
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease, filter .14s ease;
  animation: popIn .18s ease-out;
}
.cardSlot.faceDown{
  background: radial-gradient(300px 140px at 20% 20%, rgba(76,194,255,.22), rgba(255,255,255,.04));
}
.cardName{
  font-size:12px;
  text-align:center;
  line-height:1.2;
}
.cardSlot.clickable{
  cursor:pointer;
  border-color: rgba(76,194,255,.55);
  box-shadow: 0 0 0 1px rgba(76,194,255,.18), 0 10px 26px rgba(0,0,0,.35);
}
.cardSlot.clickable:hover{
  transform: translateY(-4px) scale(1.02);
  box-shadow:
    0 0 0 1px rgba(76,194,255,.28),
    0 0 22px rgba(76,194,255,.18),
    0 16px 34px rgba(0,0,0,.45);
}
@keyframes softPulse {
  0%   { box-shadow: 0 0 0 1px rgba(76,194,255,.16), 0 10px 26px rgba(0,0,0,.35); }
  50%  { box-shadow: 0 0 0 1px rgba(76,194,255,.30), 0 0 24px rgba(76,194,255,.18), 0 10px 26px rgba(0,0,0,.35); }
  100% { box-shadow: 0 0 0 1px rgba(76,194,255,.16), 0 10px 26px rgba(0,0,0,.35); }
}
.cardSlot.turnPulse{
  animation: softPulse 1.4s ease-in-out infinite;
}
.ownerTag{
  position:absolute;
  bottom:6px;
  left:8px;
  font-size:10px;
  color: rgba(255,255,255,.55);
}

.limboPill{
  width:52px; height:52px;
  border-radius:999px;
  display:flex; align-items:center; justify-content:center;
  font-weight:800;
  background: rgba(255,255,255,.06);
  border:1px solid var(--border);
}

.handRow{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  padding-top:10px;
}

.handCard{
  width:160px;
  height:96px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.14);
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(0,0,0,.2));
  padding:12px;
  cursor:pointer;
  position:relative;
  transition: transform .12s ease, opacity .2s ease;
}
.handCard:hover{ transform: translateY(-3px); border-color: rgba(76,194,255,.35); }
.handCard.disabled{ opacity:.35; cursor:not-allowed; }
.handCard .title{ font-weight:700; font-size:13px; }
.handCard .sub{ color:var(--muted); font-size:11px; margin-top:6px; }

.fadeOut{ opacity:0; transform: translateY(6px) scale(.98); }

.turnBanner{
  text-align:center;
  font-weight:800;
  letter-spacing:.08em;
  padding:10px 14px;
  border-bottom:1px solid var(--border);
  transform: translateY(-8px);
  opacity:0;
  transition: transform .18s ease, opacity .18s ease;
}

.turnBanner.myTurn{
  background: rgba(74,222,128,.18);
  color: var(--good);
}

.turnBanner.nextTurn{
  background: rgba(250,204,21,.18);
  color: #fde047;
}

.turnBanner.hidden{
  display:none;
}
.turnBanner:not(.hidden){
  transform: translateY(0);
  opacity:1;
}
.factionCardContent{
  display:flex;
  align-items:center;
  gap:10px;
}

.factionIcon{
  width:34px;
  max-width:55px;
  height:auto;
  flex-shrink:0;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.4));
}

/* Players list UX */
.playerItem{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:6px 8px;
  border-radius:10px;
}

.playerItem.active{
  background: rgba(74,222,128,.10);
  border: 1px solid rgba(74,222,128,.22);
}

.playerItem.next{
  background: rgba(250,204,21,.08);
  border: 1px solid rgba(250,204,21,.18);
}

.badges{
  display:flex;
  gap:6px;
  flex-shrink:0;
}

.badge{
  font-size:10px;
  font-weight:800;
  letter-spacing:.08em;
  padding:4px 8px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--muted);
}

.badge.active{
  background: rgba(74,222,128,.16);
  border-color: rgba(74,222,128,.30);
  color: var(--good);
}

.badge.next{
  background: rgba(250,204,21,.16);
  border-color: rgba(250,204,21,.30);
  color: #fde047;
}

.phaseBar{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin:10px 0 6px;
}

.phaseStep{
  font-size:10px;
  font-weight:800;
  letter-spacing:.08em;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.05);
  color: var(--muted);
}

.phaseStep.active{
  background: rgba(76,194,255,.16);
  border-color: rgba(76,194,255,.30);
  color: var(--text);
}

.phaseStep.done{
  opacity:.7;
}

.phaseHelp{
  color: var(--muted);
  font-size:13px;
  margin-bottom:10px;
}
.zone.activeZone .zoneRow{
  border-color: rgba(76,194,255,.38);
  box-shadow:
    0 0 0 1px rgba(76,194,255,.10),
    0 0 26px rgba(76,194,255,.12) inset;
}

.card.hand.activeHand{
  border-color: rgba(76,194,255,.28);
  box-shadow: 0 0 0 1px rgba(76,194,255,.10), var(--shadow);
}

/* =========================
   PHASE STATE OVERRIDES
   ========================= */
body.banPhase{
  --accent: #fb7185;
}
body.banPhase #zoneBan .zoneRow{
  border-color: rgba(251,113,133,.55);
  box-shadow:
    0 0 0 1px rgba(251,113,133,.35),
    0 0 28px rgba(251,113,133,.25),
    0 0 46px rgba(251,113,133,.15) inset;
}
body.banPhase .handCard:not(.disabled):hover{
  border-color: rgba(251,113,133,.55);
  box-shadow:
    0 0 0 1px rgba(251,113,133,.35),
    0 0 24px rgba(251,113,133,.25);
  transform: translateY(-3px) scale(1.03);
}
body.banPhase #zoneBan .cardSlot{
  background: linear-gradient(
    180deg,
    rgba(251,113,133,.18),
    rgba(0,0,0,.35)
  );
  border-color: rgba(251,113,133,.45);
}
body.pickPhase{
  --accent: #4ade80;
}
body.pickPhase #zonePool .cardSlot.clickable,
body.pickPhase #zoneSlice .cardSlot.clickable{
  border-color: rgba(74,222,128,.55);
  box-shadow:
    0 0 0 1px rgba(74,222,128,.35),
    0 10px 26px rgba(0,0,0,.35);
}
body.pickPhase #handCard{
  opacity:.35;
  filter: saturate(.7);
}
body.pickPhase #zonePool .cardSlot.clickable:hover,
body.pickPhase #zoneSlice .cardSlot.clickable:hover{
  transform: translateY(-4px) scale(1.04);
  box-shadow:
    0 0 0 1px rgba(74,222,128,.45),
    0 0 28px rgba(74,222,128,.35),
    0 18px 36px rgba(0,0,0,.45);
}
@keyframes softPulseGreen {
  0% {
    box-shadow:
      0 0 0 1px rgba(74,222,128,.18),
      0 10px 26px rgba(0,0,0,.35);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(74,222,128,.35),
      0 0 24px rgba(74,222,128,.25),
      0 10px 26px rgba(0,0,0,.35);
  }
  100% {
    box-shadow:
      0 0 0 1px rgba(74,222,128,.18),
      0 10px 26px rgba(0,0,0,.35);
  }
}

body.pickPhase .cardSlot.turnPulse{
  animation: softPulseGreen 1.4s ease-in-out infinite;
}
body.pickPhase .cardSlot:not(.clickable){
  opacity:.55;
  filter: saturate(.75);
}
body.pickPhase .zone.activeZone .zoneRow{
  border-color: rgba(74,222,128,.55);
  box-shadow:
    0 0 0 1px rgba(74,222,128,.35),
    0 0 26px rgba(74,222,128,.22),
    0 0 42px rgba(74,222,128,.14) inset;
}
/* =========================
   PHASE STATE OVERRIDES END
   ========================= */

   .shareCard{
  margin:10px 0;
  padding:12px;
  border-radius:16px;
  border:1px solid var(--border);
  background: rgba(0,0,0,.18);
}

.shareTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.shareLabel{
  font-size:11px;
  letter-spacing:.12em;
  text-transform:uppercase;
  color: var(--muted);
}

.shareCode{
  font-size:26px;
  font-weight:900;
  letter-spacing:.18em;
  margin-top:4px;
}

.copyBtn{
  white-space:nowrap;
}

.copyBtn:active{
  transform: translateY(1px);
}
.sliceCard{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:6px;
}

.sliceDot{
  width:26px;
  height:26px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.18);
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
}

.sliceLabel{
  font-size:12px;
  font-weight:700;
  color: var(--text);
  opacity:.9;
}

/* =========================
   PHASE INTRO OVERLAY
   ========================= */
.phaseIntro{
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.phaseIntroBackdrop{
  position:absolute;
  inset:0;
  background:
    radial-gradient(900px 420px at 50% 40%, rgba(76,194,255,.18), rgba(0,0,0,0) 60%),
    radial-gradient(1200px 650px at 50% 55%, rgba(0,0,0,.78), rgba(0,0,0,.92));
  opacity: 1;
  animation: introFadeIn .22s ease-out both;
}

/* “stjärn-noise” utan bilder */
.phaseIntroBackdrop::before{
  content:"";
  position:absolute;
  inset:0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.18) 0 1px, transparent 2px),
    radial-gradient(circle at 70% 20%, rgba(255,255,255,.12) 0 1px, transparent 2px),
    radial-gradient(circle at 40% 80%, rgba(255,255,255,.10) 0 1px, transparent 2px),
    radial-gradient(circle at 85% 65%, rgba(255,255,255,.10) 0 1px, transparent 2px),
    radial-gradient(circle at 10% 70%, rgba(255,255,255,.08) 0 1px, transparent 2px);
  background-size: 220px 220px;
  opacity:.22;
  filter: blur(.15px);
  mix-blend-mode: screen;
}

.phaseIntroBurst{
  position:absolute;
  width: 1200px;
  height: 1200px;
  border-radius: 999px;
  opacity: 1;
  transform: translateY(0) scale(1);
  background:
    radial-gradient(circle at 50% 50%,
      rgba(255,255,255,.12) 0%,
      rgba(76,194,255,.14) 18%,
      rgba(76,194,255,0) 60%);
  animation: introBurstIn .32s ease-out both;
}

.phaseIntroContent{
  position: relative;
  text-align: center;
  padding: 22px 28px;
}

.phaseIntroKicker{
  font-size: 13px;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: rgba(255,255,255,.72);
  margin-bottom: 12px;
  opacity: 1;
  animation: introTextIn .32s ease-out both;
}

.phaseIntroTitle{
  font-weight: 1000;
  font-size: clamp(64px, 10vw, 170px);
  letter-spacing: .08em;
  text-transform: uppercase;
  line-height: .88;
  color: #fff;
  text-shadow:
    0 16px 55px rgba(0,0,0,.55),
    0 0 22px rgba(76,194,255,.20);
  opacity: 1;
  animation: introTitleIn .40s cubic-bezier(.15,.85,.2,1) both;
}

.phaseIntroSub{
  margin-top: 14px;
  font-size: 14px;
  color: rgba(255,255,255,.70);
  opacity: 1;
  animation: introTextIn .36s ease-out both;
}

/* Variants per phase */
.phaseIntro.isBan .phaseIntroTitle{
  text-shadow:
    0 16px 55px rgba(0,0,0,.55),
    0 0 26px rgba(251,113,133,.24);
}
.phaseIntro.isBan .phaseIntroBurst{
  background:
    radial-gradient(circle at 50% 50%,
      rgba(255,255,255,.10) 0%,
      rgba(251,113,133,.16) 18%,
      rgba(251,113,133,0) 60%);
}

.phaseIntro.isPick .phaseIntroTitle{
  text-shadow:
    0 16px 55px rgba(0,0,0,.55),
    0 0 26px rgba(74,222,128,.22);
}
.phaseIntro.isPick .phaseIntroBurst{
  background:
    radial-gradient(circle at 50% 50%,
      rgba(255,255,255,.10) 0%,
      rgba(74,222,128,.16) 18%,
      rgba(74,222,128,0) 60%);
}

/* OUT state (JS lägger på .out) */
.phaseIntro.out .phaseIntroBackdrop{
  animation: introFadeOut .35s ease-in both;
}
.phaseIntro.out .phaseIntroBurst{
  animation: introFadeOut .35s ease-in both;
}
.phaseIntro.out .phaseIntroKicker,
.phaseIntro.out .phaseIntroTitle,
.phaseIntro.out .phaseIntroSub{
  animation: introTextOut .35s ease-in both;
}

/* Keyframes */
@keyframes introFadeIn{
  from { opacity:0; }
  to   { opacity:1; }
}
@keyframes introFadeOut{
  from { opacity:1; }
  to   { opacity:0; }
}
@keyframes introTextIn{
  from { opacity:0; transform: translateY(10px); filter: blur(1px); }
  to   { opacity:1; transform: translateY(0); filter: blur(0); }
}
@keyframes introTextOut{
  from { opacity:1; transform: translateY(0); filter: blur(0); }
  to   { opacity:0; transform: translateY(-8px); filter: blur(.6px); }
}
@keyframes introBurstIn{
  from { opacity:0; transform: translateY(18px) scale(.85); filter: blur(1px); }
  to   { opacity:1; transform: translateY(0) scale(1); filter: blur(0); }
}
@keyframes introTitleIn{
  from { opacity:0; transform: translateY(32px) scale(.92); filter: blur(2px); }
  to   { opacity:1; transform: translateY(0) scale(1); filter: blur(0); }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce){
  .phaseIntroBackdrop, .phaseIntroBurst, .phaseIntroKicker, .phaseIntroTitle, .phaseIntroSub{
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
}


.playerNameLine{
  display:flex;
  align-items:center;
  gap:8px;
}

.speakerIcon{
  width:16px;
  height:16px;
  flex-shrink:0;
  opacity:.92;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.55));
}

/* =========================
   MOBILE
   ========================= */
@media (max-width: 768px) {

  /* --- Grundlayout --- */
  .layout{
    display: block;
    padding: 0;
    padding-bottom: 72px; /* plats för bottom nav */
  }

  .card{
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
  }

  /* --- Topbar: hamburger-knapp --- */
  .topbar{
    padding: 12px 14px;
    position: sticky;
    top: 0;
    z-index: 200;
  }

  .hamburgerBtn{
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,.06);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    flex-shrink: 0;
  }

  .hamburgerBtn span{
    display: block;
    height: 2px;
    border-radius: 2px;
    background: var(--text);
    transition: transform .2s ease, opacity .2s ease;
  }

  .hamburgerBtn.open span:nth-child(1){ transform: translateY(7px) rotate(45deg); }
  .hamburgerBtn.open span:nth-child(2){ opacity: 0; }
  .hamburgerBtn.open span:nth-child(3){ transform: translateY(-7px) rotate(-45deg); }

  /* --- Drawer overlay --- */
  .drawerOverlay{
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 299;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
  }

  .drawerOverlay.open{
    opacity: 1;
    pointer-events: auto;
  }

  /* --- Lobby drawer --- */
  .lobby{
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 85vw);
    z-index: 300;
    overflow-y: auto;
    border-radius: 0 20px 20px 0;
    border: none;
    border-right: 1px solid rgba(255,255,255,.12);
    background: linear-gradient(160deg, rgba(17,24,38,.98), rgba(11,15,20,.98));
    backdrop-filter: blur(20px);
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.32,.72,0,1);
    padding: 14px;
    padding-top: 60px;
    grid-row: unset;
  }

  .lobby.drawerOpen{
    transform: translateX(0);
  }

  /* --- Board och Hand: tab-panel --- */
  .board, .hand{
    display: none;
    border-radius: 0;
  }

  .board.mobileActive, .hand.mobileActive{
    display: block;
  }

  /* --- Bottom nav --- */
  .mobileNav{
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: rgba(11,15,20,.95);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    height: 64px;
  }

  .mobileNavBtn{
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    border-radius: 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    cursor: pointer;
    padding: 8px 0;
    transition: color .15s ease;
    position: relative;
  }

  .mobileNavBtn.active{
    color: var(--accent);
  }

  .mobileNavBtn.active::after{
    content: "";
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    border-radius: 0 0 3px 3px;
    background: var(--accent);
  }

  .mobileNavBtn svg{
    width: 22px;
    height: 22px;
  }

  /* Puls-dot på Hand-tab när det är din tur att välja från handen */
  .mobileNavBtn .navDot{
    display: none;
    position: absolute;
    top: 8px;
    right: calc(50% - 18px);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--good);
    box-shadow: 0 0 6px var(--good);
    animation: navDotPulse 1.4s ease-in-out infinite;
  }

  .mobileNavBtn .navDot.visible{
    display: block;
  }

  @keyframes navDotPulse{
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .6; transform: scale(1.3); }
  }

  /* --- Kortjusteringar --- */
  .cardSlot{
    width: 100px;
    height: 64px;
  }

  .handCard{
    width: calc(50% - 5px);
    height: 88px;
  }

  .zoneRow{
    min-height: 80px;
    gap: 8px;
    padding: 8px;
    /* horisontell scroll om korten inte ryms */
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .zoneRow::-webkit-scrollbar{ display: none; }

  /* Tillåt wrap bara i pool (kan ha många kort) */
  #poolRow{
    flex-wrap: wrap;
  }

  .factionIcon{
    width: 28px;
  }

  .cardName{
    font-size: 11px;
  }

  /* --- Fas-stepper: horisontell scroll --- */
  .phaseBar{
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .phaseBar::-webkit-scrollbar{ display: none; }

  /* --- Turn banner --- */
  .turnBanner{
    font-size: 13px;
    padding: 8px 12px;
  }

  /* --- Status i topbar: kortare --- */
  .status{
    font-size: 12px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Desktop: dölj mobil-specifika element */
@media (min-width: 769px){
  .hamburgerBtn{ display: none; }
  .drawerOverlay{ display: none; }
  .mobileNav{ display: none; }
}
