/* ── RESET & BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #07080f;
  --surface: #10111e;
  --surface2: #171826;
  --accent: #7c5cfc;
  --accent2: #f062a4;
  --gold: #ffc94a;
  --gold2: #e6a830;
  --green: #2de88b;
  --red: #f0526a;
  --text: #edeaff;
  --muted: #7a78a8;
  --border: rgba(124,92,252,0.22);
  --border2: rgba(240,98,164,0.22);
  --r: 14px;
  --card-w: clamp(96px, 20vh, 176px);
  --card-h: var(--card-w);
  --card-radius: 50%;
  --emoji-size: clamp(80px, 17vh, 150px);
}

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  background: #07080f;
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* ── SCREENS ── */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  text-align: center;
  z-index: 1;
}

.screen.active {
  display: flex;
}

/* animated background glow */
.bg-fx {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 30% 30%, rgba(124,92,252,0.12) 0%, transparent 70%),
    radial-gradient(ellipse 50% 35% at 75% 70%, rgba(240,98,164,0.09) 0%, transparent 70%);
  animation: bgpulse 8s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes bgpulse {
  0%,100% { opacity:1; }
  50% { opacity:0.6; }
}

/* ── LOGO ── */
.logo {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.logo-row {
  font-size: clamp(28px, 7vw, 52px);
  display: flex;
  align-items: center;
  gap: 16px;
  letter-spacing: 2px;
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.logo-title {
  font-size: clamp(32px, 8vw, 64px);
  font-weight: 900;
  letter-spacing: 8px;
  background: linear-gradient(135deg, #b8a4ff 0%, #7c5cfc 40%, #f062a4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-emoji-img {
  width: clamp(36px, 8vw, 64px);
  height: clamp(36px, 8vw, 64px);
  object-fit: contain;
  filter: drop-shadow(0 4px 16px rgba(255,201,74,0.4));
  animation: float 4s ease-in-out infinite;
  animation-delay: 0.2s;
}

.tagline {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 3px;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}

/* ── NAME INPUT ── */
.name-row {
  position: relative;
  z-index: 1;
}

.set-row {
  position: relative;
  z-index: 1;
  width: min(300px, 86vw);
}

.lang-row {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  width: min(420px, 92vw);
}

.lang-btn {
  width: 42px;
  height: 42px;
  padding: 3px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.06);
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}

.lang-btn img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.lang-btn.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(255,201,74,0.18);
}

.lang-btn:hover { transform: translateY(-2px); }

.music-toggle {
  position: absolute;
  z-index: 3;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.065);
  color: var(--gold);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.18s, border-color 0.18s, background 0.18s, color 0.18s;
}

.music-toggle:hover {
  transform: translateY(-2px);
  border-color: rgba(255,201,74,0.6);
  background: rgba(255,201,74,0.12);
}

.music-toggle.off {
  color: var(--muted);
  border-color: rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.035);
}

.set-select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  outline: none;
}

.name-input {
  width: 280px;
  padding: 13px 18px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 2px;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.name-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,92,252,0.2);
}

/* ── BUTTONS ── */
.btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 15px 32px;
  border: none;
  border-radius: var(--r);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.2s;
  min-width: 220px;
}

.btn:active { transform: scale(0.97) !important; }

.btn-cpu {
  background: linear-gradient(135deg, #7c5cfc, #5a3dd4);
  color: #fff;
  box-shadow: 0 6px 24px rgba(124,92,252,0.4);
}

.btn-cpu:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(124,92,252,0.55);
}

.btn-friend {
  background: linear-gradient(135deg, #f062a4, #c0427f);
  color: #fff;
  box-shadow: 0 6px 24px rgba(240,98,164,0.35);
}

.btn-friend:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(240,98,164,0.5);
}

.btn-create {
  background: linear-gradient(135deg, #2de88b, #1cb869);
  color: #050f08;
  box-shadow: 0 6px 24px rgba(45,232,139,0.3);
  font-size: 15px;
}

.btn-create:hover { transform: translateY(-3px); }

.btn-join {
  background: linear-gradient(135deg, #ffc94a, #e6a830);
  color: #1a0f00;
  font-size: 15px;
  min-width: unset;
  padding: 14px 24px;
  box-shadow: 0 6px 20px rgba(255,201,74,0.3);
}

.btn-join:hover { transform: translateY(-3px); }

.menu-bottom-row {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

.btn-ghost {
  background: rgba(255,255,255,0.06);
  color: var(--muted);
  border: 1.5px solid rgba(255,255,255,0.1);
  min-width: 180px;
  font-size: 14px;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border);
  transform: translateY(-2px);
}

.btn-continue {
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: #1a0f00;
  font-size: 15px;
  padding: 14px 36px;
  min-width: unset;
  box-shadow: 0 8px 24px rgba(255,201,74,0.4);
  border-radius: 12px;
}

.btn-continue:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(255,201,74,0.55); }

.menu-btns {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mode-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(620px, 92vw);
}

.mode-card {
  min-height: 104px;
  padding: 14px;
  border: 1.5px solid rgba(255,255,255,0.09);
  border-radius: var(--r);
  background: rgba(255,255,255,0.045);
  color: var(--text);
  cursor: pointer;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 12px;
  text-align: left;
  transition: transform 0.18s, border-color 0.18s, background 0.18s;
}

.mode-card:hover {
  transform: translateY(-2px);
  border-color: var(--border);
  background: rgba(255,255,255,0.07);
}

.mode-card.searching {
  border-color: rgba(255,201,74,0.75);
  background: rgba(255,201,74,0.13);
  box-shadow: 0 0 28px rgba(255,201,74,0.24), inset 0 0 20px rgba(255,201,74,0.08);
}

.mode-card.searching span {
  background: rgba(255,201,74,0.22);
}

.mode-card.searching b {
  color: var(--gold);
}

.mode-card.searching em {
  color: #d9c079;
}

.btn.pending {
  opacity: 0.86;
  pointer-events: none;
  filter: saturate(1.15);
}

.mode-card span {
  grid-row: 1 / span 2;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(124,92,252,0.16);
  font-size: 24px;
}

.mode-card b {
  min-width: 0;
  font-size: 15px;
  letter-spacing: 0.5px;
}

.mode-card em {
  min-width: 0;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  line-height: 1.35;
}

.mode-card-wrap {
  position: relative;
}

.mode-card-wrap .mode-card-main {
  width: 100%;
  padding-right: 48px;
}

.mode-bot-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.12);
  background: rgba(124,92,252,0.18);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.18s, transform 0.18s;
  z-index: 2;
}

.mode-bot-btn:hover {
  background: rgba(124,92,252,0.38);
  transform: translateY(-50%) scale(1.12);
}

.private-panel {
  position: relative;
  z-index: 1;
  width: min(620px, 92vw);
  display: grid;
  gap: 12px;
}

.private-panel.hidden,
.pool-panel.hidden { display: none; }

.private-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 10px;
  align-items: stretch;
}

.code-box.compact {
  padding: 16px 18px;
  border-radius: var(--r);
}

.code-box.compact .code-display {
  font-size: 34px;
  letter-spacing: 8px;
}

.seq-count-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
}

.btn-mini {
  min-width: 0;
  padding: 12px 10px;
  font-size: 13px;
}

.lan-hint {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1px;
  min-height: 18px;
}

/* ── FRIEND PANEL ── */
.sub-title {
  position: relative;
  z-index: 1;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.back-btn {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 2;
  background: none;
  border: 1.5px solid var(--border);
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.back-btn:hover { color: var(--text); border-color: var(--accent); }

.friend-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 300px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 2px;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.join-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.code-input {
  flex: 1;
  padding: 14px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  color: var(--gold);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 6px;
  text-align: center;
  outline: none;
  transition: border-color 0.25s;
}

.code-input:focus { border-color: var(--gold); }

/* ── WAITING ── */
.code-box {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 40px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 20px;
}

.code-label {
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
}

.code-display {
  font-size: 52px;
  font-weight: 900;
  letter-spacing: 12px;
  color: var(--gold);
  text-shadow: 0 0 30px rgba(255,201,74,0.5);
}

.code-hint {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 1px;
}

.match-status {
  position: relative;
  z-index: 1;
  font-size: 18px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 2px;
}

.waiting-dots {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 10px;
}

.waiting-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: dotpulse 1.4s ease-in-out infinite;
}

.waiting-dots span:nth-child(2) { animation-delay: 0.2s; background: var(--accent2); }
.waiting-dots span:nth-child(3) { animation-delay: 0.4s; background: var(--gold); }

@keyframes dotpulse {
  0%,80%,100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── GAME SCREEN ── */
#s-game {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  gap: 10px;
  background:
    radial-gradient(ellipse 70% 30% at 50% 0%, rgba(124,92,252,0.12) 0%, transparent 60%),
    rgba(5,6,12,0.55);
}

#s-game.active {
  display: flex;
}

/* Normal (1v1) arena: stacks opp card above my card like seq */
.normal-arena {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex: 1;
}

/* Score row inside normal HUD badges */
.normal-score-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.normal-pts {
  font-size: 20px;
  font-weight: 900;
  color: var(--text);
}
.normal-sets {
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--gold);
}
.normal-hidden {
  font-style: normal;
  font-size: clamp(18px, 3vw, 26px);
  color: var(--muted);
  opacity: 0.5;
}
.normal-chosen {
  font-style: normal;
  font-size: 18px;
  color: var(--accent);
  font-weight: 900;
}

/* Emoji images — 1em inherits from the parent span's font-size in each context */
img.tw-emoji {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.1em;
  object-fit: contain;
}

.game-top {
  grid-area: top;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

/* HUD */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 20px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--r);
  flex-shrink: 0;
  gap: 8px;
}

.hud-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.hud-col-r {
  align-items: flex-end;
  text-align: right;
}

.hud-name {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-my  { color: #9d82ff; }
.hud-opp { color: #f47ab8; }

.hud-sub {
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: var(--muted);
}

.hud-set-num {
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
}

.hud-set-word {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.hud-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.hud-pts {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 38px;
  font-weight: 900;
}

.hp-my   { color: #9d82ff; }
.hp-opp  { color: #f47ab8; }
.hp-dash { color: var(--muted); font-size: 22px; }

.hud-brand {
  font-size: 9px;
  letter-spacing: 4px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

/* PLAYER ZONES */
.player-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  flex-shrink: 0;
}

.my-zone {
  grid-area: hand;
}

/* slim row for the "✓ Seçti" indicator — takes no meaningful height */
.ind-row {
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.opp-indicator {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--green);
  transition: all 0.3s;
}

.cards-row {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: nowrap;
}

/* Emoji tokens */
.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), filter 0.25s;
  position: relative;
  overflow: visible;
  flex-shrink: 0;
  touch-action: none;
}

.card::before {
  display: none;
}

.card-mine {
  background: transparent;
  border: 0;
}

.card-mine:hover {
  transform: translateY(-10px) scale(1.12);
  filter: drop-shadow(0 16px 22px rgba(124,92,252,0.42));
}

.card.dragging {
  opacity: 0.96;
  cursor: grabbing;
  filter: drop-shadow(0 28px 28px rgba(124,92,252,0.55));
  touch-action: none;
}

.card-placeholder {
  opacity: 0;
  pointer-events: none;
}

.card.snap-back {
  animation: snapBackPulse 0.18s ease-out both;
}

@keyframes snapBackPulse {
  0% { transform: scale(0.96); }
  100% { transform: scale(1); }
}

.card-mine.chosen {
  transform: translateY(-12px) scale(1.12);
  filter: drop-shadow(0 22px 24px rgba(255,201,74,0.55));
  animation: chosenpulse 2s ease-in-out infinite;
}

@keyframes chosenpulse {
  0%,100% { filter: drop-shadow(0 22px 24px rgba(255,201,74,0.45)); }
  50% { filter: drop-shadow(0 28px 34px rgba(255,201,74,0.75)); }
}

.card-mine.locked {
  opacity: 0.38;
  filter: grayscale(0.65) brightness(0.65);
  cursor: default;
  pointer-events: none;
}

.card-opp {
  background: transparent;
  border: 0;
  cursor: default;
}

.c-emoji { font-size: var(--emoji-size); line-height: 1; }
.c-name {
  display: none;
}

/* BATTLE ZONE */
.battle-zone {
  grid-area: battle;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 100%;
  flex-shrink: 0;
}

.battle-slot {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s cubic-bezier(0.34,1.56,0.64,1);
  position: relative;
  overflow: hidden;
}

.battle-slot.my-slot {
  transform: translateX(0);
}

.battle-slot.opp-slot {
  transform: translateX(0);
}

.battle-slot .slot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.card-face {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.slot-q {
  display: none;
}

.b-emoji { font-size: var(--emoji-size); line-height: 1; }
.b-name { display: none; }

.battle-slot.filled {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.battle-slot.b-win {
  border-color: var(--gold);
  background: rgba(255,201,74,0.1);
  box-shadow: 0 0 30px rgba(255,201,74,0.4);
}

.battle-slot.b-win .card-face {
  animation: seqWinPulse 0.7s ease-in-out both;
  filter: drop-shadow(0 0 28px rgba(255,201,74,0.58));
}

.battle-slot.b-lose {
  border-color: rgba(240,82,106,0.4);
  background: rgba(240,82,106,0.05);
}

.battle-slot.b-lose .card-face {
  animation: seqShatter 0.65s 0.25s ease-in forwards;
}

@keyframes normalWinnerReturn {
  0% { transform: scale(1); }
  55% { transform: scale(1.18) translateY(-8px); }
  100% { transform: scale(0.9) translateY(-22px); opacity: 0.9; }
}

@keyframes normalLoserVanish {
  0% { transform: scale(1); opacity: 1; filter: brightness(1); }
  35% { transform: scale(1.08) rotate(-5deg); opacity: 0.8; filter: brightness(1.8); }
  100% { transform: scale(0.05) rotate(18deg); opacity: 0; filter: brightness(0.6); }
}

.battle-vs {
  display: none;
}

/* RESULT OVERLAY */
.result-overlay {
  position: absolute;
  inset: 0;
  background: rgba(7,8,15,0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
  animation: fadein 0.3s ease;
}

.result-overlay.hidden { display: none; }

@keyframes fadein { from { opacity:0; } to { opacity:1; } }

.result-title {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 4px;
  animation: popin 0.5s cubic-bezier(0.34,1.56,0.64,1) both;
}

.result-title.win { color: var(--gold); text-shadow: 0 0 30px rgba(255,201,74,0.6); }
.result-title.lose { color: var(--red); text-shadow: 0 0 30px rgba(240,82,106,0.5); }
.result-title.tie { color: var(--muted); }

@keyframes popin {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.result-scores {
  font-size: 26px;
  font-weight: 900;
  color: var(--muted);
  animation: popin 0.5s 0.25s cubic-bezier(0.34,1.56,0.64,1) both;
}

/* SET / GAME OVER SCREENS */
.result-icon {
  position: relative;
  z-index: 1;
  font-size: 80px;
  animation: float 3s ease-in-out infinite;
}

.result-heading {
  position: relative;
  z-index: 1;
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 3px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-sets {
  position: relative;
  z-index: 1;
  font-size: 52px;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 20px;
}

.result-sets .rs-my { color: #9d82ff; }
.result-sets .rs-sep { color: var(--muted); font-size: 24px; }
.result-sets .rs-opp { color: #f47ab8; }

.go-btns {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

/* ── FRIEND PANEL RESPONSIVE ── */
.friend-panel {
  width: min(300px, 92vw);
}

/* ── RESPONSIVE ── */

/* Mobile portrait — fix card overflow by switching to vw-based sizing */
@media (max-width: 600px) {
  :root {
    --card-w: clamp(64px, 20vw, 104px);
    --card-h: var(--card-w);
    --card-radius: 50%;
    --emoji-size: clamp(58px, 17vw, 96px);
  }
  .card {
    width: var(--card-w);
    height: var(--card-h);
    border-radius: var(--card-radius);
    gap: 4px;
  }
  .battle-slot {
    width: var(--card-w);
    height: var(--card-h);
    border-radius: var(--card-radius);
  }
  .c-emoji { font-size: var(--emoji-size); }
  .b-emoji { font-size: var(--emoji-size); }
  .slot-q  { font-size: calc((100vw - 48px) / 3 * 0.22); }
  .cards-row { gap: 6px; }
  .battle-zone { gap: 0; }
  .hud-name { font-size: 13px; }
  .hud-pts  { font-size: 24px; gap: 6px; }
  .hud-set-num { font-size: 14px; }
  .mode-panel { grid-template-columns: 1fr; }
  .mode-card { min-height: 82px; }
  .private-actions { grid-template-columns: 1fr; }
  .music-toggle {
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    font-size: 18px;
  }
  /* Stack join row vertically so button doesn't go off-screen */
  .join-row { flex-direction: column; }
  .btn-join { width: 100%; min-width: 0; }
  .code-input { width: 100%; }
}

/* Short screens (landscape phone) */
@media (max-height: 500px) {
  .hud { padding: 6px 12px; }
  .hud-pts { font-size: 22px; }
  .hud-name { font-size: 13px; }
  .hud-set-num { font-size: 13px; }
  .cards-row { gap: 6px; }
}

/* ── SEQUENTIAL MODE ─────────────────────────────────────────────────────── */

.btn-seq {
  background: linear-gradient(135deg, #ff9a3c, #d4600a);
  color: #fff;
  box-shadow: 0 6px 24px rgba(255,154,60,0.35);
}
.btn-seq:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(255,154,60,0.5); }

.btn-duel {
  background: linear-gradient(135deg, #2de88b, #118a5b);
  color: #04120a;
  box-shadow: 0 6px 24px rgba(45,232,139,0.28);
}
.btn-duel:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(45,232,139,0.42); }

.btn-boss {
  background: linear-gradient(135deg, #ff5b5b, #7c2cff);
  color: #fff;
  box-shadow: 0 6px 24px rgba(255,91,91,0.3);
}
.btn-boss:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(255,91,91,0.46); }

.seq-desc {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 1px;
  max-width: 300px;
}

/* Waiting room player list */
.seq-wait-list {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 260px;
}
.seq-wait-player {
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
}
.seq-wait-empty {
  color: var(--muted);
  border-style: dashed;
  font-weight: 400;
  font-size: 12px;
  text-align: center;
}

.pool-panel {
  position: relative;
  z-index: 1;
  width: min(520px, 94vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
}

.pool-list {
  display: grid;
  gap: 8px;
}

.pool-player {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: left;
}

.pool-player span {
  color: var(--gold);
  font-weight: 900;
}

.pool-player b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pool-player em {
  font-style: normal;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--green);
}

.pool-player.pool-cpu em {
  color: var(--gold);
}

.pool-remove {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  background: rgba(240,82,106,0.12);
  color: var(--red);
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.pool-empty-action {
  grid-column: 1 / -1;
  padding: 11px 12px;
  color: var(--muted);
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.pool-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pool-cpu-btn {
  width: 100%;
}

.pool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.library-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(5,6,12,0.78);
  backdrop-filter: blur(8px);
}

.library-modal.hidden {
  display: none;
}

.library-panel {
  width: min(980px, 96vw);
  max-height: min(760px, 88vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 14px;
  background: #10111e;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 22px 80px rgba(0,0,0,0.45);
}

.library-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.library-head b {
  font-size: 18px;
}

.library-head button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
}

.library-content {
  overflow: auto;
  padding: 16px;
  display: grid;
  gap: 18px;
}

.library-set h3 {
  margin-bottom: 10px;
  font-size: 15px;
  text-align: left;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.library-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  text-align: center;
}

.library-card span {
  font-size: clamp(36px, 5vw, 64px);
  line-height: 1;
}

.library-card em {
  color: var(--gold);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
  text-align: center;
}

/* Game screen */
#s-seq-game,
#s-duel-game,
#s-boss-game {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  gap: 12px;
  background:
    radial-gradient(ellipse 60% 30% at 50% 0%, rgba(255,154,60,0.1) 0%, transparent 60%),
    rgba(5,6,12,0.55);
}

#s-seq-game.active,
#s-duel-game.active,
#s-boss-game.active {
  display: flex;
}

#s-seq-game {
  --card-w: clamp(124px, 24vh, 220px);
  --card-h: var(--card-w);
  --emoji-size: clamp(108px, 21vh, 190px);
}

/* HUD badges */
.seq-hud {
  grid-area: hud;
  display: flex;
  gap: 8px;
  width: 100%;
}
.seq-badge {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 9px 7px;
  background: var(--surface);
  border: 1.5px solid transparent;
  border-radius: 10px;
  transition: border-color 0.2s, background 0.2s;
}

#s-seq-game .mini-hand span img,
#s-seq-game .mini-hand i img {
  width: clamp(36px, 6vw, 56px);
  height: clamp(36px, 6vw, 56px);
}
.seq-badge-active {
  border-color: #ff9a3c;
  background: rgba(255,154,60,0.1);
}
.seq-badge-me { border-color: var(--accent); }
.seq-badge-me.seq-badge-active { border-color: #ff9a3c; }
.seq-badge-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.mini-hand {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 34px;
  overflow: visible;
}

.mini-hand span,
.mini-hand i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-style: normal;
  line-height: 1;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}

.mini-hand span img,
.mini-hand i img {
  width: clamp(28px, 4.5vw, 44px);
  height: clamp(28px, 4.5vw, 44px);
  display: block;
}

/* Turn bar */
.seq-turn-bar {
  grid-area: turn;
  width: 100%;
  padding: 9px 16px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  transition: background 0.3s, color 0.3s;
}
.seq-turn-mine {
  background: rgba(255,154,60,0.15);
  color: #ff9a3c;
}
.seq-turn-win  { background: rgba(45,232,139,0.15); color: var(--green); }
.seq-turn-lose { background: rgba(240,82,106,0.15); color: var(--red); }

#seqTurnBar,
.seq-turn-empty,
.boss-turn-empty {
  display: none;
}

/* Arena — two-card animation system */
.seq-arena {
  grid-area: arena;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
}

.seq-ac, .seq-ap {
  position: absolute;
  transition: transform 0.44s cubic-bezier(0.34,1.56,0.64,1), opacity 0.36s ease;
}

.seq-arena.seq-reset .seq-ac,
.seq-arena.seq-reset .seq-ap {
  transition: none;
}

.seq-ac .slot-inner,
.seq-ap .slot-inner {
  width: var(--card-w);
  height: var(--card-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: var(--card-radius);
}

/* Idle: champion centered, played card hidden by direction of origin */
.seq-ac { transform: translateX(0); opacity: 1; }
.seq-ap { transform: translateX(calc(var(--card-w) * 1.35)); opacity: 0; pointer-events: none; }

/* Entry direction: from my hand (below) or opponent's hand (above) */
.seq-ap.from-me  { transform: translateY(calc(var(--card-w) * 2.4)); opacity: 0; }
.seq-ap.from-opp { transform: translateY(calc(var(--card-w) * -2.4)); opacity: 0; }

/* Battle: both slide into confrontation positions */
.seq-arena.battle .seq-ac { transform: translateX(calc(var(--card-w) * -0.55)); }
.seq-arena.battle .seq-ap { transform: translateX(calc(var(--card-w) * 0.55)); opacity: 1; pointer-events: auto; }
.seq-arena.player-won .seq-ac { transform: translateX(calc(var(--card-w) * -1.1)); opacity: 0; }
.seq-arena.player-won .seq-ap { transform: translateX(0); opacity: 1; pointer-events: auto; }
.seq-arena.center-won .seq-ac,
.seq-arena.merge-done .seq-ac { transform: translateX(0); opacity: 1; }
.seq-arena.center-won .seq-ap,
.seq-arena.merge-done .seq-ap { transform: translateX(0); opacity: 0; }
.seq-arena.merge .seq-ac,
.seq-arena.merge .seq-ap {
  transform: translateX(0);
  opacity: 1;
}

.seq-arena.side-mode .seq-ac.left,
.seq-arena.side-mode .seq-ap.left {
  transform: translateX(calc(var(--card-w) * -0.62));
}

.seq-arena.side-mode .seq-ac.right,
.seq-arena.side-mode .seq-ap.right {
  transform: translateX(calc(var(--card-w) * 0.62));
}

.seq-arena.side-mode .seq-ap.left,
.seq-arena.side-mode .seq-ap.right {
  opacity: 0;
  pointer-events: none;
}

.seq-arena.side-mode.battle .seq-ac.left,
.seq-arena.side-mode.battle .seq-ap.left {
  transform: translateX(calc(var(--card-w) * -0.62));
}

.seq-arena.side-mode.battle .seq-ac.right,
.seq-arena.side-mode.battle .seq-ap.right {
  transform: translateX(calc(var(--card-w) * 0.62));
}

.seq-arena.side-mode.battle .seq-ap.left,
.seq-arena.side-mode.battle .seq-ap.right {
  opacity: 1;
  pointer-events: auto;
}

.seq-arena.side-mode.player-won .seq-ac {
  opacity: 0;
}

.seq-arena.side-mode.player-won .seq-ap.left,
.seq-arena.side-mode.player-won .seq-ap.right {
  opacity: 1;
}

.seq-arena.side-mode.center-won .seq-ac.left,
.seq-arena.side-mode.center-won .seq-ac.right,
.seq-arena.side-mode.merge-done .seq-ac.left,
.seq-arena.side-mode.merge-done .seq-ac.right {
  opacity: 1;
}

.seq-arena.side-mode.center-won .seq-ap.left,
.seq-arena.side-mode.center-won .seq-ap.right,
.seq-arena.side-mode.merge-done .seq-ap.left,
.seq-arena.side-mode.merge-done .seq-ap.right {
  opacity: 0;
}

/* Win glow on the champion */
.seq-ac.b-win .slot-inner,
.seq-ap.b-win .slot-inner,
.seq-center-card.target-win .slot-inner {
  filter: drop-shadow(0 0 22px rgba(45,232,139,0.62));
  animation: seqWinPulse 0.7s ease-in-out infinite;
}

/* Loser shatters and vanishes */
.seq-ac.b-lose .slot-inner,
.seq-ap.b-lose .slot-inner,
.seq-center-card.target-lose .slot-inner {
  filter: drop-shadow(0 0 22px rgba(240,82,106,0.62));
  animation: seqShatter 0.65s 0.25s ease-in forwards;
}

/* Merge: champion absorbs the duplicate */
.seq-ac.b-merge .slot-inner {
  animation: seqMergeAbsorb 0.65s 0.38s ease-in-out both;
  filter: drop-shadow(0 0 26px rgba(255,201,74,0.68));
}
.seq-ap.b-merge .slot-inner {
  filter: drop-shadow(0 0 20px rgba(255,201,74,0.55));
}
.seq-center-card.target-merge .slot-inner {
  animation: seqMergeAbsorb 0.65s 0.38s ease-in-out both;
  filter: drop-shadow(0 0 26px rgba(255,201,74,0.68));
}

/* Played duplicate travels to champion and disappears */
.seq-ap.merge-travel {
  transition: transform 0.52s cubic-bezier(0.4,0,0.2,1), opacity 0.44s ease !important;
  opacity: 0 !important;
}
.seq-ap.right.merge-travel { transform: translateX(calc(var(--card-w) * -0.62)) !important; }
.seq-ap.left.merge-travel  { transform: translateX(calc(var(--card-w) *  0.62)) !important; }
/* non-side-mode (double center cards): ap at +0.55, champion at -0.55 */
.seq-ap.merge-travel:not(.left):not(.right) { transform: translateX(calc(var(--card-w) * -0.55)) !important; }

@keyframes seqMergeAbsorb {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.28); filter: drop-shadow(0 0 30px rgba(255,201,74,0.9)); }
  68%  { transform: scale(0.92); }
  100% { transform: scale(1.12); }
}

@keyframes seqWinPulse {
  0%,100% { box-shadow: 0 0 18px rgba(45,232,139,0.4); transform: scale(1); }
  50%     { box-shadow: 0 0 42px rgba(45,232,139,0.9), 0 0 65px rgba(45,232,139,0.25); transform: scale(1.07); }
}

@keyframes seqShatter {
  0%   { transform: scale(1) rotate(0); opacity: 1; filter: brightness(1); }
  18%  { transform: scale(1.07) rotate(-5deg); filter: brightness(2); }
  40%  { transform: scale(0.76) rotate(8deg) translate(5px,-5px); opacity: 0.7; }
  65%  { transform: scale(0.38) rotate(-12deg) translate(-6px,6px); opacity: 0.3; }
  100% { transform: scale(0.04) rotate(24deg); opacity: 0; }
}

@keyframes seqMerge {
  0% { transform: scale(1); opacity: 1; }
  45% { transform: scale(1.22); opacity: 0.9; }
  100% { transform: scale(0.92); opacity: 0.72; }
}

.seq-ac .b-emoji, .seq-ap .b-emoji { font-size: var(--emoji-size); line-height: 1; }
.seq-ac .b-name,  .seq-ap .b-name  { display: none; }
.seq-ac .slot-q,  .seq-ap .slot-q  { font-size: 30px; color: var(--muted); }

/* Result flavor text */
.seq-result-text {
  grid-area: arena;
  align-self: end;
  z-index: 2;
  pointer-events: none;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0 12px;
}

/* Hand area */
.seq-hand-area {
  grid-area: hand;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 110px;
}
.seq-hand-area .cards-row {
  justify-content: center;
}

.seq-centers {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
}

.seq-center-card {
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 16px;
  touch-action: none;
}

.seq-center-card.selected .slot-inner {
  filter: drop-shadow(0 0 18px rgba(255,201,74,0.75));
}
.seq-wait-msg {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 20px;
}

/* Game over overlay */
.seq-gameover {
  position: absolute;
  inset: 0;
  background: rgba(7,8,15,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 10;
  border-radius: inherit;
}
.seq-go-icon  { font-size: 72px; }
.seq-go-title {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 3px;
  background: linear-gradient(135deg, var(--gold), #ff9a3c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Duel mode */
.duel-hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
}

.duel-player {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  min-width: 0;
}

.duel-player span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 900;
}

.duel-player b {
  color: var(--red);
  letter-spacing: 2px;
}

.duel-opp { text-align: right; }

.duel-board {
  width: min(510px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: stretch;
  justify-content: center;
  flex: 1;
}

.duel-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
}

.duel-slot {
  aspect-ratio: 1 / 1;
  border: 2px solid rgba(255,255,255,0.09);
  border-radius: 0;
  background: rgba(255,255,255,0.035);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  margin-left: -2px;
  margin-top: -2px;
}

.duel-row:first-child .duel-slot { margin-top: 0; }
.duel-slot:first-child { margin-left: 0; }

.duel-slot .slot-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.duel-slot.empty {
  border-style: dashed;
}

.duel-slot.drop-ready {
  border-color: rgba(45,232,139,0.55);
  box-shadow: inset 0 0 22px rgba(45,232,139,0.12);
}

.duel-slot.filled {
  border-color: rgba(255,255,255,0.09);
  background: rgba(255,255,255,0.02);
}

.duel-slot.opp.filled {
  border-color: rgba(255,255,255,0.09);
  background: rgba(255,255,255,0.02);
}

.duel-slot.duel-win {
  border-color: var(--green);
  box-shadow: inset 0 0 28px rgba(45,232,139,0.22), 0 0 24px rgba(45,232,139,0.32);
  animation: duelWinPulse 0.7s ease-in-out both;
}

.duel-slot.duel-lose {
  border-color: var(--red);
  box-shadow: inset 0 0 24px rgba(240,82,106,0.22), 0 0 24px rgba(240,82,106,0.25);
  animation: duelCardVanish 0.75s 0.18s ease-in forwards;
}

.duel-slot.duel-attack {
  border-color: var(--gold);
  box-shadow: inset 0 0 28px rgba(255,201,74,0.22), 0 0 24px rgba(255,201,74,0.32);
  animation: duelStrike 0.62s ease-in-out both;
}

.duel-row-opp .duel-slot.duel-attack {
  animation-name: duelStrikeDown;
}

@keyframes duelWinPulse {
  0%,100% { transform: scale(1); }
  45% { transform: scale(1.05); }
}

@keyframes duelCardVanish {
  0% { transform: scale(1); opacity: 1; filter: brightness(1); }
  30% { transform: scale(1.08) rotate(-4deg); opacity: 0.95; filter: brightness(1.8); }
  100% { transform: scale(0.08) rotate(16deg); opacity: 0; filter: brightness(0.7); }
}

@keyframes duelStrike {
  0%,100% { transform: translateY(0) scale(1); }
  42% { transform: translateY(-12px) scale(1.06); }
  70% { transform: translateY(6px) scale(1.02); }
}

@keyframes duelStrikeDown {
  0%,100% { transform: translateY(0) scale(1); }
  42% { transform: translateY(12px) scale(1.06); }
  70% { transform: translateY(-6px) scale(1.02); }
}

.duel-slot .card-face {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

/* Bossmoji */
.boss-hud {
  width: min(1320px, 100%);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
}

.boss-title {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0;
  color: #ff8e8e;
  white-space: nowrap;
}

.boss-hp {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

.boss-hp span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff5b5b, #ffb84a);
  transition: width 0.35s ease;
}

.boss-hp-text {
  font-size: 13px;
  font-weight: 900;
  color: var(--gold);
}

.boss-board {
  --boss-card-size: min(calc((100vw - 126px) / 3), calc((100vh - 255px) / 2));
  width: min(1320px, 100%);
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
  min-height: 0;
}

.boss-board-2 { --boss-card-size: min(calc((100vw - 106px) / 2), calc((100vh - 255px) / 2)); grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(980px, 100%); }
.boss-board-4 { --boss-card-size: min(calc((100vw - 146px) / 4), calc((100vh - 255px) / 2)); grid-template-columns: repeat(4, minmax(0, 1fr)); }

.boss-lane {
  min-width: 0;
  display: grid;
  grid-template-rows: var(--boss-card-size) var(--boss-card-size) auto;
  justify-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.028);
  border: 1px solid rgba(255,255,255,0.09);
}

.boss-lane.me {
  border-color: rgba(124,92,252,0.45);
  box-shadow: inset 0 0 24px rgba(124,92,252,0.08);
}

.boss-lane.dead {
  opacity: 0.48;
  filter: grayscale(0.75);
}

.boss-player-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  text-align: left;
}

.boss-player-row b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  letter-spacing: 0;
}

.boss-mini-hand {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.boss-mini-hand button {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.055);
  color: var(--text);
  font-size: clamp(54px, 5.6vw, 92px);
  line-height: 1;
  cursor: default;
}

.boss-mini-hand button.pickable {
  cursor: pointer;
  border-color: rgba(255,201,74,0.5);
  background: rgba(255,201,74,0.12);
  box-shadow: 0 0 18px rgba(255,201,74,0.22), inset 0 0 18px rgba(255,201,74,0.08);
}

.boss-mini-hand button:disabled {
  opacity: 0.68;
}

.boss-card-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, var(--boss-card-size));
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
}

.boss-card-slot .card-face {
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.boss-card-slot .b-emoji {
  font-size: clamp(80px, 10vw, 180px);
}

.boss-side {
  border-color: rgba(255,91,91,0.28);
}

.player-side {
  border-color: rgba(124,92,252,0.28);
}

.player-side.picked {
  border-color: rgba(255,201,74,0.45);
}

.boss-card-slot.win {
  border-color: var(--green);
  box-shadow: inset 0 0 24px rgba(45,232,139,0.18), 0 0 22px rgba(45,232,139,0.28);
  animation: duelWinPulse 0.72s ease-in-out both;
}

.boss-card-slot.win .card-face {
  animation: seqWinPulse 0.7s ease-in-out both;
  filter: drop-shadow(0 0 24px rgba(45,232,139,0.6));
}

.boss-card-slot.lose {
  border-color: var(--red);
  box-shadow: inset 0 0 22px rgba(240,82,106,0.16), 0 0 20px rgba(240,82,106,0.2);
  animation: duelCardVanish 0.78s 0.18s ease-in forwards;
}

.boss-card-slot.lose .card-face {
  animation: seqShatter 0.65s 0.25s ease-in forwards;
}

.boss-card-slot.tie {
  border-color: var(--gold);
  box-shadow: inset 0 0 22px rgba(255,201,74,0.14), 0 0 20px rgba(255,201,74,0.22);
  animation: seqMerge 0.72s ease-in-out both;
}

@media (max-width: 780px) {
  :root {
    --card-w: clamp(64px, 20vw, 104px);
    --card-h: var(--card-w);
    --card-radius: 50%;
    --emoji-size: clamp(58px, 17vw, 96px);
  }

  #s-game,
  #s-seq-game,
  #s-duel-game,
  #s-boss-game {
    gap: 6px;
    padding: 6px;
  }

  #s-seq-game {
    --card-w: clamp(86px, 28vw, 132px);
    --card-h: var(--card-w);
    --emoji-size: clamp(74px, 24vw, 116px);
  }

  #s-boss-game {
    justify-content: center;
  }

  .card {
    border-radius: var(--card-radius);
  }

  .battle-slot {
    border-radius: var(--card-radius);
  }

  .c-emoji { font-size: var(--emoji-size); }
  .b-emoji { font-size: var(--emoji-size); }
  .c-name, .b-name { display: none; }
  .hud { padding: 8px 10px; }
  .hud-name { font-size: 12px; }
  .hud-pts { font-size: 22px; }
  .seq-centers {
    gap: 7px;
  }
  .seq-badge {
    gap: 4px;
    padding: 6px 4px;
  }
  .mini-hand {
    min-height: 26px;
  }
  .mini-hand span img,
  .mini-hand i img {
    width: clamp(22px, 6vw, 32px);
    height: clamp(22px, 6vw, 32px);
  }
  #s-seq-game .mini-hand span img,
  #s-seq-game .mini-hand i img {
    width: clamp(28px, 8vw, 44px);
    height: clamp(28px, 8vw, 44px);
  }
  .boss-mini-hand {
    gap: 6px;
  }
  .boss-mini-hand button {
    font-size: clamp(34px, 10vw, 56px);
  }
  .duel-row {
    grid-template-columns: repeat(3, minmax(52px, 1fr));
  }
  .duel-slot {
    border-radius: 12px;
  }
  .duel-slot {
    border-radius: 0;
  }
  .seq-count-row {
    grid-template-columns: 1fr;
  }
  .pool-grid {
    grid-template-columns: 1fr 1fr;
  }
  .library-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .boss-board {
    --boss-card-size: min(calc((100vw - 48px) / 3), calc((100vh - 214px) / 2));
    gap: 6px;
  }
  .boss-board-2 {
    --boss-card-size: min(calc((100vw - 42px) / 2), calc((100vh - 214px) / 2));
  }
  .boss-board-4 {
    --boss-card-size: min(calc((100vw - 60px) / 4), calc((100vh - 214px) / 2));
  }
  .boss-lane {
    padding: 6px;
    gap: 5px;
    grid-template-rows: var(--boss-card-size) var(--boss-card-size) auto;
  }
  .boss-card-slot {
    border-radius: 10px;
  }
  .boss-card-slot .b-emoji {
    font-size: clamp(58px, 18vw, 112px);
  }
  .boss-title {
    font-size: 12px;
  }
  .boss-player-row b {
    font-size: 10px;
  }
}

/* ── MOBILE MENU & SCREENS ───────────────────────────────────────────────── */

/* Allow menu/waiting screens to scroll on very small phones */
@media (max-width: 600px) {
  #s-menu,
  #s-waiting,
  #s-seq-wait,
  #s-setover,
  #s-gameover {
    overflow-y: auto;
    justify-content: flex-start;
    padding-top: max(56px, 20px);
    padding-bottom: 28px;
    gap: 14px;
  }

  /* Logo smaller on small phones */
  .logo-row { font-size: clamp(20px, 6vw, 36px); gap: 10px; }
  .logo-title { font-size: clamp(22px, 7vw, 44px); letter-spacing: 4px; }

  /* Name input full-width on small phones */
  .name-input { width: min(260px, 88vw); font-size: 15px; }

  /* Mode panel single column */
  .mode-panel { grid-template-columns: 1fr; width: min(440px, 96vw); gap: 8px; }
  .mode-card { min-height: 72px; }

  /* Private panel */
  .private-panel { width: min(440px, 96vw); }

  /* Result screens */
  .result-icon { font-size: 56px; }
  .result-heading { font-size: 26px; }
  .result-sets { font-size: 36px; gap: 12px; }

  /* Reduce overall screen gap */
  .screen { gap: 14px; padding: 14px; }
}

/* Very small phones (< 400px) */
@media (max-width: 400px) {
  .logo-row { font-size: 5vw; }
  .logo-title { font-size: 6.5vw; letter-spacing: 2px; }
  .mode-panel { width: 100%; }
  .name-input { width: 90vw; }
  .lang-row { gap: 5px; }
  .lang-btn { width: 36px; height: 36px; }
}

/* Landscape phone — compact all screens */
@media (max-height: 500px) {
  #s-menu,
  #s-waiting,
  #s-seq-wait,
  #s-setover,
  #s-gameover {
    overflow-y: auto;
    justify-content: flex-start;
    padding-top: 12px;
    padding-bottom: 16px;
    gap: 10px;
  }
  .logo { display: none; }
  .screen { gap: 10px; padding: 10px 16px; }
  .mode-panel { gap: 6px; }
  .mode-card { min-height: 60px; padding: 8px 10px; }
  .lang-row { gap: 5px; }
  .lang-btn { width: 34px; height: 34px; }

  /* Game screens landscape */
  #s-game, #s-seq-game, #s-duel-game, #s-boss-game {
    gap: 4px;
    padding: 4px 6px;
  }
  .seq-hud { gap: 4px; }
  .seq-badge { padding: 4px 3px; gap: 2px; }
  .seq-badge-name { font-size: 9px; }
  .mini-hand { min-height: 20px; }
  .mini-hand span img, .mini-hand i img { width: clamp(18px, 5vw, 26px) !important; height: clamp(18px, 5vw, 26px) !important; }
  .normal-pts { font-size: 14px; }
  .normal-sets { font-size: 10px; }
  .seq-hand-area { min-height: 80px; gap: 4px; }
}

/* ── POLISH ──────────────────────────────────────────────────────────────── */

/* Screen fade-in */
.screen.active {
  animation: screenFadeIn 0.18s ease both;
}
@keyframes screenFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Result toast — WIN / LOSE / TIE */
.result-toast {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  width: fit-content;
  margin: 0 auto;
  margin-top: -32px;
  z-index: 8;
  pointer-events: none;
  padding: 10px 28px;
  border-radius: 18px;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 3px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: toastPop 0.36s cubic-bezier(0.34,1.56,0.64,1) both;
}
.result-toast[hidden] { display: none; }
.result-toast.win  {
  color: var(--gold);
  background: rgba(255,201,74,0.14);
  border: 1.5px solid rgba(255,201,74,0.35);
  text-shadow: 0 0 24px rgba(255,201,74,0.7);
  box-shadow: 0 0 32px rgba(255,201,74,0.18);
}
.result-toast.lose {
  color: var(--red);
  background: rgba(240,82,106,0.11);
  border: 1.5px solid rgba(240,82,106,0.28);
  text-shadow: 0 0 20px rgba(240,82,106,0.6);
}
.result-toast.tie {
  color: var(--muted);
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.12);
}
@keyframes toastPop {
  from { opacity: 0; transform: scale(0.35) translateY(12px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* Score change bump */
.score-bump {
  animation: scoreBump 0.42s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes scoreBump {
  from { transform: scale(1.65); }
  to   { transform: scale(1); }
}

/* New card deal-in animation */
.card-deal {
  animation: cardDealIn 0.32s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes cardDealIn {
  from { transform: translateY(-32px) scale(0.72); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* Game toast notification */
.game-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  z-index: 200;
  transform: translateX(-50%);
  padding: 12px 26px;
  background: rgba(16,17,30,0.94);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 14px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-align: center;
  pointer-events: none;
  animation: toastSlideIn 0.28s cubic-bezier(0.34,1.56,0.64,1) both;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  max-width: 90vw;
}
.game-toast.hidden { display: none; }
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(-50%) translateY(18px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Clickable room code */
.code-display.copyable {
  cursor: pointer;
  transition: opacity 0.15s;
}
.code-display.copyable:hover { opacity: 0.75; }

/* Bot button pulse while waiting */
.mode-bot-btn.connecting {
  animation: botPulse 0.9s ease-in-out infinite;
  border-color: rgba(255,201,74,0.6);
  background: rgba(255,201,74,0.16);
}
@keyframes botPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,201,74,0); }
  50%     { box-shadow: 0 0 0 6px rgba(255,201,74,0.22); }
}

/* Sequential HUD hands scale from each badge, not from the viewport. */
#s-seq-game .seq-badge {
  container-type: inline-size;
}

#s-seq-game .seq-badge .mini-hand {
  justify-content: space-between;
  gap: 2px;
  min-height: max(34px, 32cqi);
}

#s-seq-game .seq-badge .mini-hand span,
#s-seq-game .seq-badge .mini-hand i {
  flex: 0 0 calc((100cqi - 4px) / 3);
  width: calc((100cqi - 4px) / 3);
}

#s-seq-game .seq-badge .mini-hand span img,
#s-seq-game .seq-badge .mini-hand i img {
  width: calc((100cqi - 4px) / 3) !important;
  height: calc((100cqi - 4px) / 3) !important;
  max-width: none;
  max-height: none;
  object-fit: contain;
}
