/* ─── Lokalne Czcionki ────────────────────────────────────────────── */
@font-face {
  font-family: 'Cinzel Decorative';
  src: url('fonts/CinzelDecorative-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Cinzel Decorative';
  src: url('fonts/CinzelDecorative-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('fonts/Inter-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('fonts/Inter-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('fonts/Inter-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('fonts/Inter-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ─── Tokens & Reset ─────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

.lock-scroll {
  overflow: hidden !important;
}

:root {
  --clr-bg: #0b0b1a;
  --clr-surface: #12122a;
  --clr-surface2: #1a1a38;
  --clr-border: rgba(140, 100, 255, 0.25);
  --clr-purple: #8b5cf6;
  --clr-purple-lt: #a78bfa;
  --clr-blue: #3b82f6;
  --clr-cyan: #06b6d4;
  --clr-gold: #f59e0b;
  --clr-green: #10b981;
  --clr-red: #ef4444;
  --clr-text: #e2e8f0;
  --clr-text-dim: #94a3b8;

  /* Ustalanie Od Ogółu: Główna szerokość gry */
  /* Główna szerokość gry: Na telefonach (mała wysokość/szerokość) zajmujemy 100vw.
     Na komputerach/wysokich ekranach ograniczamy szerokość, by wszystko zmieściło się w pionie. */
  --game-width: min(480px, 100vw);
  
  /* Specjalne ograniczenie dla Areny, gdy ekran jest zbyt niski w stosunku do szerokości */
  @media (min-height: 500px) {
    :root {
      --safe-v: calc((100dvh - 360px) * 0.92);
      --game-width: min(480px, 100vw, var(--safe-v));
    }
  }
  --board-padding: 12px;
  --tile-gap: 6px;

  /* Szczegół (kafelek) wyliczany z ogółu (szerokości gry) */
  --tile-size: calc((var(--game-width) - (2 * var(--board-padding)) - (4 * var(--tile-gap))) / 5);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --font-title: 'Cinzel Decorative', serif;
  --font-tile: 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;

  --glow-purple: 0 0 16px rgba(139, 92, 246, 0.55);
  --glow-gold: 0 0 16px rgba(245, 158, 11, 0.6);
  --glow-cyan: 0 0 16px rgba(6, 182, 212, 0.55);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  background: var(--clr-bg);
  color: var(--clr-text);
  font-family: var(--font-body);
}

/* Ukrycie scrollbara dla wszystkich przeglądarek */
* {
  scrollbar-width: none !important;
  /* Firefox */
  -ms-overflow-style: none !important;
  /* IE/Edge */
}

*::-webkit-scrollbar {
  display: none !important;
  /* Chrome/Safari */
}

html,
body {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none !important;
}

/* ─── Particles ──────────────────────────────────────────────────── */
.particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  border-radius: 50%;
  animation: float linear infinite;
  opacity: 0;
}

@keyframes float {
  0% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }

  10% {
    opacity: .6;
  }

  90% {
    opacity: .4;
  }

  100% {
    transform: translateY(-10vh) scale(1.2);
    opacity: 0;
  }
}

/* ─── Screens ────────────────────────────────────────────────────── */
.screen {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: var(--game-width);
  min-height: 100dvh;
  display: none;
  z-index: 10;
  background: var(--clr-bg);
  box-shadow: 0 0 100px rgba(0, 0, 0, 0.5);
}

.screen.active {
  display: flex;
  flex-direction: column;
  overflow-y: visible;
  padding-bottom: 60px;
}

/* Lobby nadal centrujemy, bo tam jest tylko jedna karta */
#screen-lobby.active {
  align-items: center;
  padding: 40px 0;
}

@media (max-width: 1023px) {
  #screen-lobby.active {
    padding-top: 50px !important;
  }
}




/* ─── Lobby ──────────────────────────────────────────────────────── */
.lobby-card {
  position: relative;
  background: linear-gradient(135deg, var(--clr-surface) 0%, #1d0f3a 100%);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: min(480px, 92vw);
  box-shadow: 0 0 80px rgba(139, 92, 246, 0.2), inset 0 1px 0 rgba(255, 255, 255, .08);
  text-align: center;
  margin: auto 0;
  /* Automatyczne centrowanie w pionie, gdy jest miejsce */
}

.lang-selector {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 1000;
}

.custom-dropdown {
  position: relative;
  min-width: 80px;
}

.dropdown-trigger {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 0.8rem;
  padding: 6px 12px;

  /* --- Discord Player Card (Compact Version) --- */
  .discord-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 12px;
    /* Takie samo jak w inputach */
    margin-bottom: 20px;
    height: 52px;
    /* Dopasowanie do wysokości inputa + paddingu */
    box-sizing: border-box;
    animation: slideInUp 0.5s ease-out;
  }

  .discord-profile.hidden {
    display: none;
  }

  .discord-avatar-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--clr-gold);
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
  }

  #discord-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .discord-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    overflow: hidden;
  }

  .discord-label {
    font-size: 0.65rem;
    color: var(--clr-gold);
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
    white-space: nowrap;
  }

  .discord-name {
    font-family: var(--font-title);
    font-size: 1.1rem;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
}

.dropdown-trigger:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--clr-purple-lt);
  box-shadow: 0 0 15px rgba(167, 139, 250, 0.2);
}

.dropdown-arrow {
  font-size: 0.6rem;
  opacity: 0.5;
  margin-left: auto;
}

.current-flag,
.flag-icon {
  width: 18px;
  height: 12px;
  display: flex;
  align-items: center;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.current-flag svg,
.flag-icon svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: rgba(20, 15, 35, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 5px;
  min-width: 130px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.custom-dropdown.active .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.85rem;
  transition: all 0.15s;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.dropdown-item.active {
  background: rgba(167, 139, 250, 0.2);
  color: var(--clr-purple-lt);
}


.logo {
  font-family: var(--font-title);
  font-size: clamp(1.6rem, 8vw, 2.5rem);
  background: linear-gradient(135deg, #a78bfa, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: .04em;
  margin-bottom: 6px;
}

.tagline {
  color: var(--clr-text-dim);
  font-size: .9rem;
  margin-bottom: 24px;
}

.form-group {
  text-align: left;
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--clr-purple-lt);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--clr-border);
  background: rgba(255, 255, 255, .05);
  color: var(--clr-text);
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.form-group input:focus {
  border-color: var(--clr-purple);
  box-shadow: var(--glow-purple);
}

.input-with-button {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-with-button input {
  padding-right: 55px !important;
}

.btn-input-action {
  position: absolute;
  right: 0;
  height: 100%;
  padding: 0 16px;
  background: transparent;
  border: none;
  border-left: 1px solid var(--clr-border);
  color: var(--clr-purple-lt);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
}

.input-with-button:focus-within .btn-input-action {
  border-left-color: var(--clr-purple);
  opacity: 1;
}

.btn-input-action:hover {
  color: #fff;
  opacity: 1;
}

.btn-input-action.hidden {
  display: none;
}

.player-count-lobby {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--clr-text-dim);
  margin-bottom: 32px;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 16px;
  border-radius: 20px;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.online-dot {
  width: 8px;
  height: 8px;
  background: var(--clr-green);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--clr-green);
  animation: dot-pulse 2s infinite;
}

@keyframes dot-pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.4);
    opacity: 0.5;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.lobby-status {
  margin-top: 16px;
  color: var(--clr-cyan);
  font-size: .9rem;
  min-height: 1.4em;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: .5
  }
}

.rules {
  margin-top: 28px;
  text-align: left;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.rules h3 {
  font-size: .85rem;
  font-weight: 600;
  color: var(--clr-gold);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.rules ul {
  list-style: none;
}

.rules li {
  font-size: .82rem;
  color: var(--clr-text-dim);
  padding: 4px 0;
  line-height: 1.5;
  display: flex;
  align-items: center;
}

.rule-badge {
  display: inline-block;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 900;
  margin-right: 10px;
  min-width: 32px;
  text-align: center;
}

.rb-dl {
  background: rgba(59, 130, 246, .3);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, .55);
  text-shadow: 0 0 6px #3b82f6;
}

.rb-tl {
  background: rgba(168, 85, 247, .3);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, .65);
  text-shadow: 0 0 6px #a855f7;
}

.rb-dw {
  background: rgba(245, 158, 11, .3);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, .65);
  text-shadow: 0 0 6px #f59e0b;
}

/* ─── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s ease;
  user-select: none;
}

.btn:active {
  transform: scale(.96);
}

.btn:disabled,
.btn.disabled {
  opacity: .4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  box-shadow: var(--glow-purple);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #8b5cf6, #3b82f6);
  box-shadow: 0 0 28px rgba(139, 92, 246, .7);
}

/* Player Count Buttons */
.player-count-buttons {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-bottom: 12px;
}

.btn-player-count {
  flex: 1;
  padding: 12px 0;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: var(--clr-surface2);
  color: var(--clr-text-dim);
  font-family: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s ease;
  user-select: none;
}

.btn-player-count:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--clr-text);
}

.btn-player-count.active {
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--glow-purple);
}

.btn-submit {
  width: 100%;
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  box-shadow: 0 0 12px rgba(16, 185, 129, .4);
}

.btn-submit:hover:not(:disabled) {
  box-shadow: 0 0 24px rgba(16, 185, 129, .6);
}

.btn-clear {
  width: 100%;
  background: rgba(239, 68, 68, .15);
  border: 1px solid rgba(239, 68, 68, .35);
  color: #fca5a5;
}

.btn-clear:hover:not(:disabled) {
  background: rgba(239, 68, 68, .25);
}

.btn-spell {
  width: 100%;
  background: linear-gradient(135deg, #7c3aed55, #06b6d455);
  border: 1px solid rgba(139, 92, 246, .4);
  color: var(--clr-purple-lt);
}

.btn-spell:hover:not(:disabled) {
  background: linear-gradient(135deg, #7c3aed88, #06b6d488);
  box-shadow: var(--glow-cyan);
}

.gem-cost {
  font-size: .75rem;
  opacity: .7;
}

/* ─── Game Screen Layout ─────────────────────────────────────────── */
#screen-game {
  background: transparent;
  min-height: 100vh;
}

.game-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 11, 26, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding-top: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--clr-border);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  justify-items: stretch;
  flex-shrink: 0;
  box-sizing: border-box;
}

@media (max-width: 1023px) {
  .game-header {
    padding-top: 35px !important;
  }
}








.solo-leave-card {
  display: flex;
  justify-content: center;
  align-items: stretch;
  height: 100%;
  width: 100%;
}

.btn-leave-solo-arena {
  background: rgba(139, 92, 246, 0.1);
  border: 1px dashed rgba(139, 92, 246, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--clr-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

.btn-leave-solo-arena:hover {
  background: rgba(139, 92, 246, 0.2);
  border-style: solid;
  border-color: var(--clr-purple);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
}

.btn-leave-solo-arena .icon {
  font-size: 1.1rem;
}

.btn-leave-solo-arena .text {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--clr-text-dim);
}

.player-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: calc(var(--game-width) * 0.22);
  position: relative;
  transition: all 0.3s ease;
}

.player-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
}

@media (max-width: 1023px) {
  .game-header {
    padding: 2px 8px;
    min-height: auto;
  }

  .player-card {
    min-width: auto;
    padding: 2px;
    gap: calc(var(--game-width) * 0.01);
  }

    max-width: calc(var(--game-width) * 0.2);


  .player-avatar,
  .player-avatar img,
  .player-avatar .avatar-img {
    width: calc(var(--game-width) * 0.1) !important;
    height: calc(var(--game-width) * 0.1) !important;
  }

  .player-avatar {
    font-size: 2.1rem !important;
  }
}

.player-avatar {
  font-size: calc(var(--game-width) * 0.08) !important;
  width: calc(var(--game-width) * 0.08) !important;
  height: calc(var(--game-width) * 0.08) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  overflow: hidden !important;
  border-radius: 50% !important;
}

.p0-glow {
  filter: drop-shadow(0 0 6px rgba(139, 92, 246, 0.6));
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.p1-glow {
  filter: drop-shadow(0 0 6px rgba(6, 182, 212, 0.6));
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.p2-glow {
  filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.6));
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.p3-glow {
  filter: drop-shadow(0 0 6px rgba(16, 185, 129, 0.6));
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.player-avatar img,
.player-avatar .avatar-img {
  width: 34px !important;
  height: 34px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  display: block !important;
}

.player-name {
  display: block;
  font-weight: 700;
  font-size: calc(var(--game-width) * 0.035);
  color: #f8fafc;
  max-width: calc(var(--game-width) * 0.25);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  -webkit-text-size-adjust: none;
}

/* Zmniejszenie kafelk??w gdy s?? dwa w kolumnie */
.header-side-col .player-card:nth-child(2),
.header-side-col .player-card:first-child:not(:only-child) {
  padding: 0px 4px;
  gap: 0;
}

.header-side-col .player-card:nth-child(2) .player-name,
.header-side-col .player-card:first-child:not(:only-child) .player-name {
  font-size: calc(var(--game-width) * 0.03);
}

.header-side-col .player-card:nth-child(2) .player-score,
.header-side-col .player-card:first-child:not(:only-child) .player-score {
  font-size: calc(var(--game-width) * 0.045);
}

.header-side-col .player-card:nth-child(2) .player-avatar,
.header-side-col .player-card:first-child:not(:only-child) .player-avatar {
  width: calc(var(--game-width) * 0.065) !important;
  height: calc(var(--game-width) * 0.065) !important;
  font-size: calc(var(--game-width) * 0.05) !important;
}

.header-side-col .player-card:nth-child(2) .avatar-img,
.header-side-col .player-card:first-child:not(:only-child) .avatar-img {
  width: calc(var(--game-width) * 0.065) !important;
  height: calc(var(--game-width) * 0.065) !important;
}

.player-score {
  display: block;
  font-size: calc(var(--game-width) * 0.05);
  color: var(--clr-gold);
  font-weight: 800;
  font-family: var(--font-timer);
  transition: all 0.3s ease;
}

.player-score.shiny {
  color: #fff !important;
  text-shadow: none !important;
  background: linear-gradient(135deg, #f59e0b, #fbbf24) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  -webkit-text-fill-color: transparent !important;

  animation: none !important;
}

.player-score.plain {
  color: #fbbf24 !important;
  text-shadow: none !important;
  background: none !important;
  -webkit-text-fill-color: initial !important;
  opacity: 1 !important;
}

.pts-label {
  font-size: 0.5em;
  font-weight: 400;
  color: var(--clr-text-dim);
  margin-left: 2px;
  vertical-align: middle;
  -webkit-text-fill-color: var(--clr-text-dim);
  /* Reset fill for gradient text */
}

.num-shiny {
  color: #fff !important;
  font-weight: 800;
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.8) !important;
  background: linear-gradient(135deg, #f59e0b, #fbbf24) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  -webkit-text-fill-color: transparent !important;

  animation: score-glow 2s ease-in-out infinite alternate !important;
}

.num-plain-gold {
  color: #fbbf24 !important;
  font-weight: 800;
  text-shadow: none !important;
}

@keyframes score-glow {
  from {
    filter: drop-shadow(0 0 2px rgba(245, 158, 11, 0.5));
  }

  to {
    filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.9));
  }
}

/* Player card positioning - now dynamic via Grid Auto Flow */
.player-card {
  align-items: center;
  justify-self: center;
}

#player-card-0 .player-meta {
  justify-content: center;
  width: 100%;
}

#player-card-1 .player-meta {
  justify-content: center;
  width: 100%;
}

.game-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  gap: 2px;
  padding: 0 8px;
  min-width: 0;
}

@media (max-width: 1023px) {
    padding: calc(var(--game-width) * 0.01) calc(var(--game-width) * 0.04);

  .timer-display {
    /* Jeszcze węższy start (28px) i ciaśniejszy tekst */
    font-size: clamp(15px, calc(var(--game-width) * 0.12 - 29.6px), 28px) !important;
    letter-spacing: -0.02em;
    margin: 0;
  }

  .btn-timer {
    /* Mniejszy start (15px) i połowa poziomego paddingu */
    font-size: clamp(10px, calc(var(--game-width) * 0.07 - 18.6px), 15px) !important;
    padding: calc(var(--game-width) * 0.01) calc(var(--game-width) * 0.02);
  }




    margin-bottom: 4px;
}

.game-center {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
  padding-top: 4px;
  width: 100%;
  justify-self: center;
}

.turn-status {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-height: auto;
  margin-bottom: 4px;
}

.turn-status-text {
  font-size: calc(var(--game-width) * 0.033);
  margin: 0;
  white-space: nowrap;
  color: #f8fafc !important;
  padding: calc(var(--game-width) * 0.005) calc(var(--game-width) * 0.03);
  border-radius: 25px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: inline-block;
  transition: all 0.3s ease;
}

.turn-status-text.your-turn {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.5);
}

.turn-status-text.opponent-turn {
  background: linear-gradient(135deg, #475569, #1e293b);
  border: 1px solid rgba(255, 215, 0, 0.3);
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.6);
  color: #f8fafc !important;
}

.turn-meta {
  font-size: calc(var(--game-width) * 0.025);
  color: #f8fafc;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.timer-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 32px;
  /* Blokuje wysokość, aby nagłówek nie "skakał" */
  margin-top: 4px;
}

.timer-display {
  font-family: var(--font-title);
  font-size: calc(var(--game-width) * 0.07);
  color: var(--clr-gold);
  text-shadow: var(--glow-gold);
  min-width: 0;
  /* Stała szerokość dla czasu */
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.announcement {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(15, 23, 42, 0.98);
  border: 2px solid var(--clr-purple);
  padding: calc(var(--game-width) * 0.06) calc(var(--game-width) * 0.08);
  border-radius: var(--radius-lg);
  color: #fff;
  font-family: var(--font-title);
  font-size: calc(var(--game-width) * 0.055);
  z-index: 2000;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), var(--glow-purple);
  pointer-events: auto;
  width: min(var(--game-width) * 0.9, 94vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--game-width) * 0.03);
  animation: announcement-pop .4s cubic-bezier(.34, 1.56, .64, 1);
}

.announcement.non-blocking {
  pointer-events: none !important;
}

@media (max-width: 480px) {
  .announcement {
    width: 94vw;
    padding: 20px 15px;
  }
}

/* Stan PAUZY */
.game-paused header,
.game-paused main {
  filter: grayscale(0.7) blur(4px);
  transition: filter 0.5s ease;
}

/* Fizyczna blokada kliknięć nad CAŁĄ grą */
.game-paused::after,
.game-waiting::after,
.game-disconnected::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.01);
  /* Prawie niewidoczna, ale blokuje */
  z-index: 1999;
  cursor: not-allowed;
  pointer-events: auto;
}

.game-disconnected::after {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 3999; /* Tuż pod disconnect-overlay (4000) */
}

.game-disconnected header,
.game-disconnected main {
  filter: grayscale(0.8) blur(6px);
  transition: filter 0.4s ease;
}


/* Ogłoszenie musi być NAD blokadą */
.announcement {
  z-index: 2005 !important;
  pointer-events: auto !important;
}

.announcement.hidden {
  display: none !important;
}

.disconnect-notice {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  margin-top: 10px;
}

.disconnect-notice strong {
  color: var(--clr-gold);
}

.disconnect-notice p {
  margin: 5px 0;
}

.btn-timer {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--clr-gold);
  padding: calc(var(--game-width) * 0.01) calc(var(--game-width) * 0.03);
  border-radius: 20px;
  font-size: calc(var(--game-width) * 0.03);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-timer:hover:not(:disabled) {
  filter: brightness(1.3);
  transform: translateY(-1px);
}

.btn-timer:active:not(:disabled) {
  transform: translateY(0);
}

.btn-timer:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Announcement Variants */
.announcement.success {
  color: var(--clr-purple-lt);
  border-color: var(--clr-purple);
}

.announcement.info {
  color: var(--clr-cyan);
  border-color: var(--clr-cyan);
}

.announcement.hidden {
  display: none !important;
}

.announcement.error {
  color: #ef4444;
  border-color: #ef4444;
}

@keyframes announcement-pop {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
  }

  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-12px);
  }
}

@keyframes history-item-appear {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Game Main ──────────────────────────────────────────────────── */
.game-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: calc(var(--game-width) * 0.02);
  padding: calc(var(--game-width) * 0.02) 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  width: 100%;
}

/* ─── Board ──────────────────────────────────────────────────────── */
.board-container {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: var(--game-width);
  margin: 0 auto;
  padding-top: 5px;
  justify-content: flex-start;
}

.board-container>* {
  margin: 0 !important;
}

/* Usuwamy wszelkie marginesy dzieci */

.board-relative {
  position: relative;
  margin: 0 auto;
}

.board-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Responsive Overrides for Top-Down scaling */
@media (max-width: 1023px) {
  :root {
    /* Usunięto nadpisanie --game-width, aby działało skalowanie vh/dvh */
  }

  #screen-game {
    overflow-x: hidden;
  }

  .game-main {
    padding: 12px 0;
    gap: 14px;
  }

  .board-container {
    padding-top: 2px;
    gap: 2px;
  }

  .word-display {
    font-size: 1.2rem;
    padding: 2px 12px;
    min-width: auto;
  }

  .board-header {
    min-height: auto;
    margin: 0;
  }

  .panel-section {
    padding: 6px 10px;
    flex: 1;
    min-width: 140px;
  }
}

.word-display {
  font-family: var(--font-body);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--clr-purple-lt);
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px 20px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
  width: 100%;
  max-width: 460px;
  /* Szerokość planszy */
  height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  box-sizing: border-box;
  transition: font-size 0.15s ease;
  /* Płynne skalowanie */
}

.score-preview {
  font-size: .95rem;
  color: var(--clr-gold);
  font-weight: 600;
  min-height: 0;
  margin: 0;
}

.board.selecting-target {
  cursor: default;
}

.board.swap-active .tile {
  animation: tile-pulse 1.5s infinite ease-in-out;
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.3);
}

@keyframes tile-pulse {
  0% {
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
    filter: brightness(1);
  }

  50% {
    box-shadow: 0 0 25px rgba(192, 132, 252, 0.7);
    filter: brightness(1.2);
  }

  100% {
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
    filter: brightness(1);
  }
}

#path-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 60;
  /* NAD kafelkami (z-index: 5) dla czystych krawędzi */
  border-radius: var(--radius-lg);
}

.board {
  display: grid;
  grid-template-columns: repeat(5, var(--tile-size));
  grid-template-rows: repeat(5, var(--tile-size));
  gap: var(--tile-gap);
  padding: var(--board-padding);
  background: rgba(17, 17, 40, .7);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 60px rgba(139, 92, 246, .15), inset 0 1px 0 rgba(255, 255, 255, .06);
  user-select: none;
  touch-action: none;
  cursor: default;
  position: relative;
  /* Kluczowe dla pozycjonowania płótna wewnątrz */
}

/* ─── Tile ───────────────────────────────────────────────────────── */
.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, #1e1b4b, #1a1a38);
  border: 1px solid rgba(139, 92, 246, .25);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Idealne środkowanie litery */
  position: relative;
  /* Kluczowe dla z-index */
  z-index: 5;
  /* Wyżej niż linia połączenia (z-index: 2) */
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  overflow: hidden;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, .06) 0%, transparent 60%);
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
}

.tile::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: auto;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
}

/* Wizualna reakcja CAŁEGO kafelka na hover i zaznaczenie */
.tile:has(::after:hover),
.tile.selected {
  border-color: rgba(167, 139, 250, .6);
}

.tile.selected {
  background: linear-gradient(145deg, #4c1d95, #1e1b4b) !important;
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.5), inset 0 0 10px rgba(167, 139, 250, 0.3);
  pointer-events: none;
  z-index: 6;
  /* Na samym wierzchu podczas wyboru */
}

.tile.opponent-selected {
  border-color: var(--clr-cyan) !important;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.4);
}

.tile:has(::after:hover) .tile-letter {
  color: #fff;
  text-shadow: 0 0 12px rgba(167, 139, 250, 0.6);
}

.tile-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
}

.board.shuffling .tile-inner {
  opacity: 0 !important;
  transition: none !important;
}

.tile-letter {
  font-family: var(--font-tile);
  font-size: calc(var(--tile-size) * 0.55);
  /* Powiększenie litery do 55% kafelka */
  font-weight: 800;
  color: var(--clr-text);
  pointer-events: none;
  z-index: 2;
  transition: color .2s ease;
}

.tile-value {
  position: absolute;
  bottom: calc(var(--tile-size) * 0.08);
  right: calc(var(--tile-size) * 0.1);
  font-size: calc(var(--tile-size) * 0.18);
  font-weight: 700;
  color: var(--clr-text-dim);
  pointer-events: none;
  line-height: 1;
}

.tile-multiplier {
  position: absolute;
  top: 0;
  left: 0;
  font-size: calc(var(--tile-size) * 0.16);
  font-weight: 900;
  padding: 1px 4px;
  border-radius: 0 0 6px 0;
  pointer-events: none;
  z-index: 2;
}

.tile-gem {
  position: absolute;
  bottom: calc(var(--tile-size) * 0.08);
  left: calc(var(--tile-size) * 0.08);
  font-size: calc(var(--tile-size) * 0.25);
  pointer-events: none;
  z-index: 3;
  animation: gem-float 2s ease-in-out infinite;
}

@keyframes gem-float {

  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  50% {
    transform: translateY(-3px) rotate(10deg);
  }
}

/* Multiplier colours */
.tile.mult-DL {
  border-color: rgba(59, 130, 246, .55);
}

.tile.mult-DL .tile-multiplier {
  background: rgba(59, 130, 246, .3);
  color: #93c5fd;
  text-shadow: 0 0 6px #3b82f6;
}

.tile.mult-TL {
  border-color: rgba(168, 85, 247, .65);
}

.tile.mult-TL .tile-multiplier {
  background: rgba(168, 85, 247, .3);
  color: #d8b4fe;
  text-shadow: 0 0 6px #a855f7;
}

.tile.mult-DW {
  border-color: rgba(245, 158, 11, .65);
}

.tile.mult-DW .tile-multiplier {
  background: rgba(245, 158, 11, .3);
  color: #fcd34d;
  text-shadow: 0 0 6px #f59e0b;
}

/* Selection order badge */
.sel-badge {
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: .6rem;
  font-weight: 800;
  color: #c4b5fd;
  background: rgba(124, 58, 237, .6);
  border-radius: 4px;
  padding: 0 3px;
  line-height: 1.4;
  pointer-events: none;
}

/* Selected tile */
.tile.p0-selected {
  background: linear-gradient(145deg, #4c1d95, #1e1b4b) !important;
  border-color: #a78bfa;
  box-shadow: 0 0 25px rgba(139, 92, 246, 0.6);
  z-index: 50;
}

.tile.p1-selected {
  background: linear-gradient(145deg, #083344, #082f49) !important;
  border-color: #22d3ee;
  box-shadow: 0 0 25px rgba(6, 182, 212, 0.6);
  z-index: 50;
}

.tile.p2-selected {
  background: linear-gradient(145deg, #451a03, #422006) !important;
  border-color: #fbbf24;
  box-shadow: 0 0 25px rgba(245, 158, 11, 0.6);
  z-index: 50;
}

.tile.p3-selected {
  background: linear-gradient(145deg, #064e3b, #022c22) !important;
  border-color: #34d399;
  box-shadow: 0 0 25px rgba(16, 185, 129, 0.6);
  z-index: 50;
}

@keyframes selection-glow {

  0%,
  100% {
    opacity: 0.7;
    transform: translate(-50%, -50%) scale(1);
  }

  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
}

.tile.p0-selected .tile-letter {
  color: #fff;
  text-shadow: 0 0 10px rgba(167, 139, 250, 0.8);
  z-index: 5;
}

.tile.p1-selected .tile-letter {
  color: #fff;
  text-shadow: 0 0 10px rgba(34, 211, 238, 0.8);
  z-index: 5;
}

.tile.p2-selected .tile-letter {
  color: #fff;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.8);
  z-index: 5;
}

.tile.p3-selected .tile-letter {
  color: #fff;
  text-shadow: 0 0 10px rgba(52, 211, 153, 0.8);
  z-index: 5;
}

.tile-gem {
  position: absolute;
  bottom: 4px;
  left: 5px;
  font-size: .85rem;
  filter: drop-shadow(0 0 5px rgba(6, 182, 212, 0.6));
  pointer-events: none;
  animation: gem-float 2s ease-in-out infinite;
}

@keyframes gem-float {

  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-2px) scale(1.1);
  }
}

/* Animations */
@keyframes tile-spawn {
  from {
    transform: translateY(-20px) scale(.8);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.tile.spawning {
  animation: tile-spawn .35s cubic-bezier(.34, 1.56, .64, 1) forwards;
}

@keyframes shuffle-pop {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }

  50% {
    transform: scale(0.95) rotate(2deg);
    filter: brightness(1.5);
  }

  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

.shuffle-anim .tile:nth-child(4n) {
  --tx: -150px;
  --ty: -150px;
  --tr: -20deg;
}

.shuffle-anim .tile:nth-child(4n+1) {
  --tx: 150px;
  --ty: 150px;
  --tr: 20deg;
}

.shuffle-anim .tile:nth-child(4n+2) {
  --tx: -150px;
  --ty: 150px;
  --tr: 15deg;
}

.shuffle-anim .tile:nth-child(4n+3) {
  --tx: 150px;
  --ty: -150px;
  --tr: -15deg;
}

.shuffle-anim .tile {
  animation: tile-shuffle-fly 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes tile-shuffle-fly {
  0% {
    transform: translate(var(--tx), var(--ty)) rotate(var(--tr)) scale(0.5);
    opacity: 0;
  }

  100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }
}

@keyframes magic-flash {
  0% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
    transform: scale(1);
  }

  50% {
    box-shadow: 0 0 30px 10px rgba(139, 92, 246, 0.8);
    transform: scale(1.1);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
    transform: scale(1);
  }
}

.tile.swap-anim {
  animation: magic-flash .6s ease-out;
  z-index: 50;
}

@keyframes board-refresh {
  0% {
    opacity: 0;
    transform: translateY(30px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Game Over Suspense ────────────────────────────────────────── */
.calculating-anim {
  display: inline-block;
  animation: pulse-dots 1.5s infinite;
}

@keyframes pulse-dots {

  0%,
  100% {
    opacity: 0.6;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

.overlay-reveal-zone {
  position: relative;
  padding: 10px;
  width: 100%;
  z-index: 10;
}

.fanfare-particle {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  font-size: 1.8rem;
  z-index: 10001;
  will-change: transform, opacity;
}

.gameover-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-top: 10px;
}

#btn-rematch.ready {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.4);
  transform: scale(1.02);
}

#btn-rematch.ready::after {
  content: ' ✓';
}

#btn-rematch.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(1);
}

@keyframes magic-flash-anim {
  0% {
    transform: scale(1);
  }

  15% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

.flying-gem {
  position: fixed;
  width: 24px;
  height: 24px;
  background: var(--clr-cyan);
  clip-path: polygon(50% 0%, 100% 35%, 80% 100%, 20% 100%, 0% 35%);
  box-shadow: 0 0 15px var(--clr-cyan);
  z-index: 9999;
  pointer-events: none;
  transition: all 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes gem-pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.4);
    filter: brightness(1.5);
  }

  100% {
    transform: scale(1);
  }
}

.gem-slot.pulse {
  animation: gem-pulse 0.4s ease-out;
}

.flying-tile-inner {
  position: fixed;
  pointer-events: none;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* --- Discord Player Card (Compact Version) --- */
.discord-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 16px;
  border-radius: 12px;
  margin-bottom: 20px;
  height: 52px;
  box-sizing: border-box;
  animation: slideInUp 0.5s ease-out;
  width: 100%;
}

.discord-profile.hidden {
  display: none;
}

.discord-avatar-wrapper {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--clr-purple-lt);
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(167, 139, 250, 0.4);
}

.discord-avatar-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.discord-info {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.discord-label {
  font-size: 0.65rem;
  color: var(--clr-gold);
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.7;
  white-space: nowrap;
}

.discord-name {
  font-family: var(--font-title);
  font-size: 1.1rem;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Support Section ────────────────────────────────────────────── */
.support-container {
  margin-top: 20px;
}

.btn-kofi {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 94, 91, 0.1);
  border: 1px solid rgba(255, 94, 91, 0.3);
  padding: 14px 20px;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all 0.2s ease;
  margin-top: 10px;
}

.btn-kofi:hover {
  background: rgba(255, 94, 91, 0.2);
  border-color: rgba(255, 94, 91, 0.6);
  box-shadow: 0 0 20px rgba(255, 94, 91, 0.3);
  transform: translateY(-2px);
}

.kofi-icon {
  font-size: 1.5rem;
  animation: heart-beat 1.5s infinite;
}

.kofi-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.kofi-title {
  color: #ff5e5b;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
}

.kofi-desc {
  color: var(--clr-text-dim);
  font-size: 0.75rem;
}

@keyframes heart-beat {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.2);
  }
}

/* ─── Waiting Overlay (Floating) ─────────────────────────────────── */
.waiting-overlay {
  border: 2px solid var(--clr-cyan) !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(6, 182, 212, 0.3) !important;
  z-index: 3000 !important;
  background: rgba(15, 23, 42, 0.98) !important;
  padding: 30px 40px !important;
}

.waiting-title {
  font-family: var(--font-title) !important;
  font-size: clamp(1.3rem, 5vw, 1.8rem) !important;
  color: var(--clr-cyan) !important;
  text-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
  margin-bottom: 20px !important;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-leave-arena {
  background: #fff !important;
  color: #111 !important;
  border-radius: 50px !important;
  padding: 8px 24px !important;
  font-size: 0.9rem !important;
  font-weight: 700 !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
  border: none !important;
  width: auto !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease !important;
}

.btn-leave-arena:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5) !important;
  background: #f0f0f0 !important;
}

.waiting-actions {
  display: flex;
  justify-content: center;
  width: 100%;
}

/* Magiczny przycisk wyjścia z Areny Solo */
.btn-leave-solo-arena {
  background: rgba(139, 92, 246, 0.1);
  border: 1px dashed rgba(139, 92, 246, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--clr-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px;
  border-radius: var(--radius-md);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
  height: 100%;
  cursor: pointer;
  box-sizing: border-box;
}

.btn-leave-solo-arena:hover {
  background: rgba(139, 92, 246, 0.2);
  border-style: solid;
  border-color: var(--clr-purple);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
  transform: translateY(-2px) scale(1.02);
}

.btn-leave-solo-arena .icon {
  font-size: 1.4rem;
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.2));
  transition: transform 0.3s ease;
}

.btn-leave-solo-arena:hover .icon {
  transform: scale(1.1) translateY(-2px);
}

.btn-leave-solo-arena .text {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--clr-text-dim);
  transition: color 0.3s ease;
}

.btn-leave-solo-arena:hover .text {
  color: #fff;
}

/* ─── Disconnect Overlay ────────────────────────────────────────── */
.disconnect-overlay {
  border: 2px solid var(--clr-red) !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(239, 68, 68, 0.3) !important;
  z-index: 4000 !important;
  background: rgba(15, 23, 42, 0.98) !important;
  padding: 30px 40px !important;
}

.disconnect-title {
  font-family: var(--font-title) !important;
  font-size: clamp(1.3rem, 5vw, 1.8rem) !important;
  color: var(--clr-red) !important;
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
  margin-bottom: 15px !important;
  text-transform: uppercase;
}

.disconnect-msg {
  color: #fff !important;
  font-size: 1rem !important;
  margin-bottom: 25px !important;
  line-height: 1.5;
}

.disconnect-msg strong {
  color: var(--clr-gold);
}

.new-board-anim .tile {
  animation: board-refresh .5s cubic-bezier(.34, 1.56, .64, 1) both;
}

.new-board-anim .tile:nth-child(5n+1) {
  animation-delay: 0.05s;
}

.new-board-anim .tile:nth-child(5n+2) {
  animation-delay: 0.1s;
}

.new-board-anim .tile:nth-child(5n+3) {
  animation-delay: 0.15s;
}

.new-board-anim .tile:nth-child(5n+4) {
  animation-delay: 0.2s;
}

.new-board-anim .tile:nth-child(5n+5) {
  animation-delay: 0.25s;
}

/* ─── Panels ─────────────────────────────────────────────────────── */
.panel-section {
  background: rgba(17, 17, 40, .75);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-label {
  font-size: calc(var(--game-width) * 0.025);
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--clr-text-dim);
}

.score-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  font-size: .9rem;
  color: var(--clr-gold);
  font-weight: 600;
  margin-top: 4px;
}

.actions {
  gap: 8px;
}

.gems-display {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--clr-cyan);
  text-shadow: var(--glow-cyan);
}

.word-feedback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  font-size: .82rem;
  font-weight: 600;
  margin-top: 2px !important;
  width: 100%;
  max-width: 460px;
  white-space: nowrap;
  overflow: hidden;
}

.word-feedback.success {
  color: var(--clr-green);
}

.word-feedback.error {
  color: var(--clr-red);
}

.history-section {
  max-height: 240px;
  overflow-y: auto;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: calc(var(--game-width) * 0.03);
  padding: calc(var(--game-width) * 0.012) calc(var(--game-width) * 0.02);
  border-radius: var(--radius-sm);
  background: rgba(139, 92, 246, .1);
  animation: history-item-appear .3s ease-out forwards;
  border-left: 3px solid transparent;
}

.p0-color {
  background: rgba(139, 92, 246, 0.15);
  border-left-color: #8b5cf6;
}

.p1-color {
  background: rgba(6, 182, 212, 0.15);
  border-left-color: #06b6d4;
}

.p2-color {
  background: rgba(245, 158, 11, 0.15);
  border-left-color: #f59e0b;
}

.p3-color {
  background: rgba(16, 185, 129, 0.15);
  border-left-color: #10b981;
}

.p0-color .history-player {
  color: #a78bfa;
}

.p1-color .history-player {
  color: #22d3ee;
}

.p2-color .history-player {
  color: #fbbf24;
}

.p3-color .history-player {
  color: #34d399;
}

.p0-text {
  color: #a78bfa !important;
}

.p1-text {
  color: #22d3ee !important;
}

.p2-text {
  color: #fbbf24 !important;
}

.p3-text {
  color: #34d399 !important;
}

.history-num {
  font-weight: 800;
  font-size: calc(var(--game-width) * 0.022);
  color: var(--clr-gold);
  opacity: 0.7;
  margin-right: calc(var(--game-width) * 0.015);
}

.history-main {
  flex: 1;
}

.history-word {
  font-weight: 700;
  color: #fff;
  font-size: calc(var(--game-width) * 0.035);
  line-height: 1.1;
}

.history-pts {
  color: var(--clr-gold);
  font-weight: 600;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.history-spells {
  display: flex;
  gap: 4px;
}

.history-spell-tag {
  font-size: 1.1rem;
  line-height: 1;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.2));
  cursor: help;
  transition: transform 0.2s ease;
}

.history-spell-tag:hover {
  transform: scale(1.3) rotate(15deg);
}

.history-word.is-thinking {
  color: var(--clr-text-dim);
  font-style: italic;
  animation: thinking-pulse 1.5s infinite ease-in-out;
}

@keyframes thinking-pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.98); }
  50% { opacity: 1; transform: scale(1); }
}

.history-player {
  font-size: calc(var(--game-width) * 0.022);
  opacity: 0.5;
  display: block;
  text-transform: uppercase;
}

/* Game Center & Timer */
.game-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.turn-indicator {
  text-align: center;
  margin-bottom: 5px;
}

.turn-meta {
  font-size: calc(var(--game-width) * 0.025);
  color: #f8fafc;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.turn-status {
  font-size: calc(var(--game-width) * 0.033);
  font-weight: 800;
  color: #f8fafc;
  padding: 2px 10px;
  border-radius: 4px;
}

.turn-status.my-turn {
  color: #fff;
  background: rgba(139, 92, 246, 0.3);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 5px rgba(139, 92, 246, 0.4);
  }

  50% {
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.6);
  }

  100% {
    box-shadow: 0 0 5px rgba(139, 92, 246, 0.4);
  }
}

.timer-display {
  font-family: var(--font-title);
  font-size: calc(var(--game-width) * 0.07);
  color: #fff;
  text-shadow: 0 0 15px rgba(255, 255, 255, .3);
  line-height: 1;
}

.timer-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 5px;
}

.btn-timer {
  display: block;
  margin: 0;
  font-size: calc(var(--game-width) * 0.03);
  font-weight: 700;
  padding: calc(var(--game-width) * 0.01) calc(var(--game-width) * 0.03);
  background: var(--clr-gold);
  color: #000;
  border: none;
  border-radius: 6px;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
  transition: all 0.2s ease;
  cursor: pointer;
}

.btn-timer:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.6);
}

.btn-timer:active:not(:disabled) {
  transform: translateY(0);
}

.btn-timer:disabled {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.3);
  box-shadow: none;
  cursor: not-allowed;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Opponent Selection */
.tile.opponent-selected {
  box-shadow: inset 0 0 0 2px rgba(147, 197, 253, 0.5), 0 0 15px rgba(147, 197, 253, 0.3);
  opacity: 1;
}

/* Board disabled during opponent turn */
.board.disabled {
  pointer-events: none;
  filter: grayscale(0.5) contrast(0.8);
  cursor: not-allowed;
}

.player-card.is-offline {
  filter: grayscale(1) opacity(0.5);
  transition: filter 0.3s ease, opacity 0.3s ease;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 5000;
  display: none;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: linear-gradient(145deg, #1e1b4b, #0f172a);
  padding: 30px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--clr-purple);
  box-shadow: 0 0 50px rgba(139, 92, 246, 0.3);
  text-align: center;
  max-width: 400px;
  width: 90%;
  margin-top: env(safe-area-inset-top, 0px);
  margin-bottom: env(safe-area-inset-bottom, 0px);
}

.letter-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 20px 0;
}

.letter-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 1.4rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  aspect-ratio: 1;
}

.letter-btn-char {
  pointer-events: none;
}

.letter-btn-val {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-size: 0.65rem;
  opacity: 0.6;
  font-weight: normal;
  pointer-events: none;
}

.letter-btn:hover {
  background: var(--clr-primary);
  border-color: var(--clr-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

/* ─── Overlay (Game Over) ────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(7, 7, 20, .85);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  background: linear-gradient(135deg, var(--clr-surface) 0%, #1d0f3a 100%);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: calc(var(--game-width) * 0.07) calc(var(--game-width) * 0.05);
  padding-bottom: calc(var(--game-width) * 0.08 + env(safe-area-inset-bottom, 0px));
  width: min(var(--game-width), 94vw);
  text-align: center;
  box-shadow: 0 0 100px rgba(139, 92, 246, .3);
  animation: slide-in .4s ease;
}

.overlay-icon {
  font-size: calc(var(--game-width) * 0.12);
  margin-bottom: calc(var(--game-width) * 0.03);
}

.overlay-card h2 {
  font-family: var(--font-title);
  font-size: calc(var(--game-width) * 0.065);
  background: linear-gradient(135deg, #a78bfa, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: calc(var(--game-width) * 0.02);
}

.overlay-card p {
  color: var(--clr-text-dim);
  margin-bottom: 24px;
}

.final-scores {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  margin: 0 auto 28px auto;
  max-width: 360px;
  /* Ograniczamy szerokość, aby wymusić układ 2x2 */
}

.final-score-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--game-width) * 0.005);
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 12px 10px;
  flex: 0 0 160px;
  min-width: 140px;
  max-width: 200px;
  text-align: center;
}

.final-score-block.p0 {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.5);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.25);
}
.final-score-block.p1 {
  background: rgba(6, 182, 212, 0.12);
  border-color: rgba(6, 182, 212, 0.5);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.25);
}
.final-score-block.p2 {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.5);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.25);
}
.final-score-block.p3 {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.25);
}

.final-score-block.p0 strong { color: #a78bfa; text-shadow: 0 0 10px rgba(167, 139, 250, 0.5); }
.final-score-block.p1 strong { color: #22d3ee; text-shadow: 0 0 10px rgba(34, 211, 238, 0.5); }
.final-score-block.p2 strong { color: #fbbf24; text-shadow: 0 0 10px rgba(251, 191, 36, 0.5); }
.final-score-block.p3 strong { color: #34d399; text-shadow: 0 0 10px rgba(52, 211, 153, 0.5); }


.score-content {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 2.5rem;
}

.score-wrapper {
  position: relative;
  display: inline-flex;
  align-items: baseline;
}


.final-score-block span {
  font-size: .85rem;
  color: #ffffff;
}

.final-score-block strong, .base-val {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--clr-gold);
}

/* Historia ruchów na ekranie końcowym */
#go-history-section {
  width: 100%;
  margin-top: 12px;
}

.go-history-toggle {
  width: 100%;
  padding: 10px 16px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  letter-spacing: 0.03em;
}

.go-history-toggle:hover {
  background: rgba(255,255,255,0.14);
}

.go-history-list {
  list-style: none;
  padding: 8px 0 0;
  margin: 0;
  max-height: 260px;
  overflow-y: auto;
}

.go-history-list.hidden {
  display: none;
}

.go-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  font-size: 0.8rem;
}

.go-history-num {
  color: rgba(255,255,255,0.4);
  font-size: 0.72rem;
  min-width: 24px;
}

.go-history-player {
  color: rgba(255,255,255,0.6);
  font-size: 0.75rem;
  min-width: 50px;
}

.go-history-word {
  font-weight: 700;
  color: #fff;
  flex: 1;
  letter-spacing: 0.05em;
}

.go-history-spells {
  display: flex;
  gap: 2px;
}

.go-history-pts {
  color: #f59e0b;
  font-weight: 700;
  min-width: 32px;
  text-align: right;
}

.gem-on-tile {
  position: absolute;
  top: calc(var(--tile-size) * 0.1);
  right: calc(var(--tile-size) * 0.1);
  width: calc(var(--tile-size) * 0.25);
  height: calc(var(--tile-size) * 0.25);
  background: radial-gradient(circle at 30% 30%, #06b6d4, #0891b2);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.6);
  z-index: 3;
  animation: gem-float 2s ease-in-out infinite;
}

@keyframes gem-float {

  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  50% {
    transform: translateY(-3px) rotate(10deg);
  }
}

/* Gems & Spells */
.gems-container {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  /* 10 równych kolumn */
  gap: calc(var(--game-width) * 0.015);
  margin-bottom: 8px;
  width: 100%;
}

.gem-slot {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  clip-path: polygon(50% 0%, 100% 35%, 80% 100%, 20% 100%, 0% 35%);
  transition: all 0.3s ease;
}

.gem-slot.filled {
  background: var(--clr-cyan);
  box-shadow: 0 0 10px var(--clr-cyan);
  border-color: #fff;
}

.spells-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-spell {
  width: 100%;
  justify-content: space-between;
  text-align: left;
  padding: calc(var(--game-width) * 0.015) calc(var(--game-width) * 0.03);
  font-size: calc(var(--game-width) * 0.032);
}

.gem-cost {
  opacity: 0.7;
  font-size: 0.75rem;
}

.spell-tip {
  font-size: 0.75rem;
  color: var(--clr-gold);
  text-align: center;
  margin-top: 5px;
  font-style: italic;
  animation: pulse-glow 2s infinite;
}

/* Responsive */

/* Animacje podsumowania końcowego */
.base-val {
  font-weight: 800;
  font-size: calc(var(--game-width) * 0.055) !important;
  transition: all 0.3s ease;
  line-height: 1;
  display: block;
  width: 100%;
}

.base-val.shiny {
  color: #fbbf24 !important;
  background: linear-gradient(135deg, #f59e0b, #fcd34d) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
  text-shadow: 0 0 20px rgba(245, 158, 11, 0.8) !important;
  animation: score-glow 2s ease-in-out infinite alternate !important;
}

.base-val.plain-gold {
  color: #fbbf24;
  background: none;
  -webkit-text-fill-color: initial;
  text-shadow: none !important;
}

.score-unit {
  font-size: 0.55em;
  opacity: 0.7;
  color: #fff;
  font-weight: 400;
  margin-left: 2px;
}

.bonus-val {
  color: var(--clr-cyan);
  font-size: 0.85rem;
  font-weight: 800;
  transition: all 0.6s ease;
  white-space: pre !important; /* Wymusza brak zawijania */
  pointer-events: none;
  position: absolute;
  left: 100%;
  margin-left: 8px;
  top: 50%;
  transform: translateY(-30%);
  text-align: left;
}

.final-pop {
  animation: score-pop 0.4s ease-out;
  text-shadow: 0 0 15px var(--clr-gold) !important;
}

@keyframes score-pop {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}