@import url('https://fonts.googleapis.com/css2?family=Almendra:ital,wght@0,400;0,700;1,400&family=Cinzel:wght@400..900&family=EB+Garamond:ital,wght@0,400..800;1,400..800&family=Grenze+Gotisch:wght@100..900&family=IM+Fell+English:ital@0;1&display=swap');

:root {
    --bg-color: #0b0705;
    --panel-bg: rgba(22, 13, 8, 0.92);
    --parchment: #f4ebd0;
    --gold: #d4af37;
    --gold-dark: #aa841c;
    --gold-glow: rgba(212, 175, 55, 0.4);
    --text-dark: #201309;
    --text-light: #f5e6d3;
    --text-gray: #a8937e;
    
    --row-diplomacy: #132b21;
    --row-diplomacy-border: #2ecc71;
    --row-military: #361414;
    --row-military-border: #e74c3c;
    --row-economy: #332611;
    --row-economy-border: #f1c40f;
    
    --transition-speed: 0.3s;
    --vh: max(1vh, 7.2px);
    --vw: max(1vw, 12.8px);
    --fs-base: calc(14px + 0.15 * var(--vw) + 0.15 * var(--vh));

    --font-gothic: 'Grenze Gotisch', serif;
    --font-calligraphy: 'Almendra', serif;
    --font-serif: 'EB Garamond', serif;
    --font-antique: 'IM Fell English', serif;
    --font-cinzel: 'Cinzel', serif;
}

* {
    box-sizing: border-box;
    user-select: none;
}

/* Premium Custom Scrollbars for medieval immersion */
#chronicle-log::-webkit-scrollbar,
.tokens-area::-webkit-scrollbar {
    width: 6px;
}
#chronicle-log::-webkit-scrollbar-track,
.tokens-area::-webkit-scrollbar-track {
    background: rgba(18, 10, 6, 0.5);
    border-radius: 3px;
}
#chronicle-log::-webkit-scrollbar-thumb,
.tokens-area::-webkit-scrollbar-thumb {
    background: #5a4119;
    border-radius: 3px;
    border: 1px solid rgba(212, 175, 55, 0.15);
}
#chronicle-log::-webkit-scrollbar-thumb:hover,
.tokens-area::-webkit-scrollbar-thumb:hover {
    background: var(--gold);
}

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(26, 15, 9, 0.45) 0%, rgba(7, 4, 3, 0.88) 100%),
        url("assets/main_bkg.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--text-light);
    font-family: var(--font-serif);
    font-size: var(--fs-base);
    font-weight: 500;
    line-height: 1.5;
    letter-spacing: 0.01em;
    margin: 0;
    padding: 0;
    min-width: 1280px;
    min-height: 720px;
    height: 100vh;
    overflow: auto;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

h1, h2, h3, .medieval-title {
    font-family: var(--font-cinzel);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h3.medieval-title {
    font-size: clamp(0.85rem, 1.6vh, 1.1rem);
}

/* Lobby / Ekran powitalny */
#lobby-screen {
    position: absolute;
    inset: 0;
    min-width: 1280px;
    min-height: 720px;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at center, rgba(26, 15, 9, 0.45) 0%, rgba(7, 4, 3, 0.88) 100%),
        url("assets/main_bkg.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2.5vh 2.5vw;
    text-align: center;
    transition: opacity 0.5s ease;
}

.lobby-content {
    width: 90%;
    max-width: 50vw;
    min-width: 600px;
    background: rgba(18, 10, 6, 0.95);
    border: 0.3vh solid var(--gold);
    border-image: linear-gradient(to bottom, var(--gold), #5a4119) 1;
    padding: 5vh;
    box-shadow: 0 0 4vh rgba(0, 0, 0, 0.8), 0 0 2vh var(--gold-glow);
    position: relative;
}

/* Language Selector */
.lang-selector-container {
    position: absolute;
    top: 2vh;
    right: 2vw;
    display: flex;
    gap: 0.5vw;
    z-index: 105;
}

.lang-btn {
    background: rgba(30, 20, 15, 0.7);
    border: 1px solid var(--gold);
    color: var(--text-gray);
    font-family: var(--font-cinzel);
    font-size: 0.8rem;
    padding: 0.4vh 1vw;
    cursor: pointer;
    transition: all 0.3s ease;
}

.lang-btn:hover {
    color: var(--gold);
    border-color: var(--gold-bright);
    background: rgba(45, 30, 20, 0.9);
}

.lang-btn.active {
    background: var(--gold);
    color: #120a06;
    font-weight: bold;
    box-shadow: 0 0 10px var(--gold-glow);
}

.lobby-logo {
    font-family: var(--font-gothic);
    font-size: clamp(4rem, 10vh, 7rem);
    color: var(--gold);
    margin: 0 0 1vh 0;
    font-weight: 900;
    text-shadow: 0 0 2vh rgba(212, 175, 55, 0.7);
    letter-spacing: 0.3vw;
}

.lobby-subtitle {
    font-family: var(--font-cinzel);
    font-size: clamp(1.1rem, 2.5vh, 1.8rem);
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 0.4em;
    margin-bottom: 4vh;
}

.dynasty-select-title {
    color: var(--text-light);
    font-family: var(--font-cinzel);
    font-size: clamp(1rem, 2vh, 1.3rem);
    margin-bottom: 2vh;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.dynasty-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5vw;
    margin-bottom: 4vh;
}

.dynasty-card {
    background: rgba(255, 255, 255, 0.03);
    border: 0.1vh solid #4a3423;
    padding: 2vh;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-align: left;
    border-radius: 0.4vh;
}

.dynasty-card:hover {
    background: rgba(212, 175, 55, 0.05);
    border-color: var(--gold);
}

.dynasty-card.selected {
    background: rgba(212, 175, 55, 0.12);
    border-color: var(--gold);
    box-shadow: 0 0 1.5vh var(--gold-glow);
}

.dynasty-name {
    font-weight: bold;
    color: var(--gold);
    font-size: clamp(1rem, 1.8vh, 1.2rem);
    margin-bottom: 0.8vh;
    font-family: var(--font-cinzel);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dynasty-desc {
    font-family: var(--font-serif);
    font-size: clamp(0.75rem, 1.4vh, 0.9rem);
    color: #dcd0c0;
    line-height: 1.5;
}

.lobby-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    border: 0.1vh solid #5a4119;
    color: var(--text-light);
    padding: 1.5vh;
    font-size: clamp(1rem, 1.8vh, 1.25rem);
    font-family: var(--font-cinzel);
    margin-bottom: 3vh;
    text-align: center;
    outline: none;
    border-radius: 0.4vh;
    letter-spacing: 0.05em;
}

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

.start-btn {
    background: linear-gradient(to bottom, #d4af37, #aa841c);
    color: #120a06;
    border: none;
    padding: 1.8vh 4vh;
    font-size: clamp(1.1rem, 2vh, 1.5rem);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all var(--transition-speed);
    font-family: var(--font-cinzel);
    box-shadow: 0 0.5vh 1.5vh rgba(0,0,0,0.4);
    border-radius: 0.4vh;
}

.start-btn:hover {
    transform: translateY(-0.2vh);
    box-shadow: 0 0.7vh 2vh var(--gold-glow);
    filter: brightness(1.1);
}

.start-btn:disabled {
    background: linear-gradient(to bottom, #4a3c20, #3a2c10);
    color: #6a5538;
    border: 1px solid #3a2815;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
    filter: saturate(0.5) brightness(0.6);
}

.start-btn:disabled:hover {
    transform: none;
    box-shadow: none;
    filter: saturate(0.5) brightness(0.6);
}

/* Ekran gry */
#game-container {
    display: flex;
    height: 100vh;
    min-height: 720px;
    width: 100vw;
    min-width: 1280px;
    padding: 1vh 1.5vw;
    gap: 1.5vw;
    overflow: hidden;
    box-sizing: border-box;
}

/* Lewa strona - Plansza Bitewna */
#board-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.8vh;
    height: 100%;
}

/* Statystyki Graczy / Header */
.player-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel-bg);
    border: 0.1vh solid #4a3423;
    padding: 0.5vh 1.5vw;
    height: calc(5 * var(--vh));
    min-height: 45px;
    border-radius: 0.6vh;
    box-shadow: 0 0.4vh 1vh rgba(0, 0, 0, 0.4);
    position: relative;
    z-index: 15;
}

#enemy-bar .player-info {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    display: flex;
    align-items: center;
    background: rgba(18, 10, 6, 0.92);
    border: 0.15vh solid var(--gold);
    border-radius: 0.6vh;
    padding: 0.5vh 1.5vw;
    box-shadow: 0 0.4vh 1.2vh rgba(0, 0, 0, 0.75);
    transition: all var(--transition-speed);
}

#enemy-bar .player-info:hover {
    border-color: #fff;
    box-shadow: 0 0.4vh 1.5vh rgba(255, 255, 255, 0.25);
}

.player-info {
    display: none !important;
}

.player-avatar {
    width: 4.2vh;
    height: 4.2vh;
    border-radius: 50%;
    border: 0.25vh solid var(--gold);
    background: #27160e;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-family: var(--font-cinzel);
    color: var(--gold);
    font-size: clamp(0.9rem, 1.6vh, 1.2rem);
}

.player-name-dynasty {
    display: flex;
    flex-direction: column;
}

.p-name {
    display: none;
}

.p-dynasty {
    font-family: var(--font-cinzel);
    font-weight: 700;
    font-size: clamp(0.85rem, 1.6vh, 1.1rem);
    line-height: 1.1;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--gold);
}

.treasury-display {
    display: flex;
    align-items: center;
    gap: 0.5vw;
    background: rgba(0, 0, 0, 0.4);
    padding: 0.5vh 1.2vw;
    border-radius: 2vh;
    border: 0.1vh solid #5a4119;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.treasury-display.shielded {
    border-color: #2ecc71;
    box-shadow: 0 0 1.5vh rgba(46, 204, 113, 0.6), inset 0 0 1vh rgba(46, 204, 113, 0.3);
}

.coin-icon {
    width: 2.2vh;
    height: 2.2vh;
    background: var(--gold);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #000;
    font-family: var(--font-cinzel);
    font-size: clamp(0.75rem, 1.2vh, 0.95rem);
    font-weight: 800;
    box-shadow: 0 0 0.5vh var(--gold-glow);
}

.sclav-amount {
    font-weight: bold;
    color: var(--gold);
    font-family: var(--font-cinzel);
    font-size: clamp(1rem, 1.8vh, 1.25rem);
    letter-spacing: 0.05em;
}

.round-crowns {
    display: flex;
    gap: 0.5vh;
}

.crown-slot {
    font-size: 1.3rem;
    opacity: 0.2;
    transition: opacity 0.3s;
}

.crown-slot.won {
    opacity: 1;
    color: var(--gold);
    text-shadow: 0 0 1vh var(--gold-glow);
}

/* Obszar pola bitwy i stosów kart */
#battlefield-container {
    flex-grow: 1;
    display: flex;
    flex-direction: row;
    width: 100%;
    align-items: stretch;
    justify-content: space-between;
    gap: 1.2vw;
    overflow: visible;
}

#battlefield {
    position: relative;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 3.5vh; /* Przerwa pomiędzy polami gracza a przeciwnika */
    overflow: visible;
}

.battlefield-half {
    flex: 1;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: stretch;
    gap: 1.2vw;
    overflow: visible;
}

/* Kolumny planszy */
.board-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: rgba(18, 10, 6, 0.45);
    border: 0.15vh solid #5a4119;
    border-radius: 0.8vh;
    padding: 0.8vh;
    gap: 0.5vh;
    box-shadow: 0 0.5vh 2vh rgba(0, 0, 0, 0.6);
    position: relative;
    z-index: 1;
    transition: transform var(--transition-speed), border-color 0.3s;
    overflow: visible;
}

/* Rotacja dla kolumn Gracza (standardowy łuk) */
.player-side.board-column.diplomacy-column {
    transform: rotate(-2.2deg);
    border-color: rgba(46, 204, 113, 0.25);
    box-shadow: 0 0.5vh 2.5vh rgba(0, 0, 0, 0.65), inset 0 0 2vh rgba(46, 204, 113, 0.05);
    top: 0px;
}
.player-side.board-column.military-column {
    transform: rotate(0deg);
    border-color: rgba(231, 76, 60, 0.25);
    box-shadow: 0 0.5vh 2.5vh rgba(0, 0, 0, 0.65), inset 0 0 2vh rgba(231, 76, 60, 0.05);
    top: -20px;
}
.player-side.board-column.economy-column {
    transform: rotate(2.2deg);
    border-color: rgba(212, 175, 55, 0.25);
    box-shadow: 0 0.5vh 2.5vh rgba(0, 0, 0, 0.65), inset 0 0 2vh rgba(212, 175, 55, 0.05);
    top: 0px;
}

/* Rotacja dla kolumn Przeciwnika (odwrócony łuk) */
.enemy-side.board-column.diplomacy-column {
    transform: rotate(2.2deg);
    border-color: rgba(46, 204, 113, 0.25);
    box-shadow: 0 0.5vh 2.5vh rgba(0, 0, 0, 0.65), inset 0 0 2vh rgba(46, 204, 113, 0.05);
    top: -80px;
}
.enemy-side.board-column.military-column {
    transform: rotate(0deg);
    border-color: rgba(231, 76, 60, 0.25);
    box-shadow: 0 0.5vh 2.5vh rgba(0, 0, 0, 0.65), inset 0 0 2vh rgba(231, 76, 60, 0.05);
    top: -60px;
}
.enemy-side.board-column.economy-column {
    transform: rotate(-2.2deg);
    border-color: rgba(212, 175, 55, 0.25);
    box-shadow: 0 0.5vh 2.5vh rgba(0, 0, 0, 0.65), inset 0 0 2vh rgba(212, 175, 55, 0.05);
    top: -80px;
}

/* Podświetlenie przy aktywnym przeciąganiu */
.board-column .board-row.active-row-target {
    border-color: var(--gold);
    box-shadow: inset 0 0 2.5vh rgba(212, 175, 55, 0.15);
}

.board-column .board-row.drag-over {
    background: rgba(212, 175, 55, 0.18) !important;
    border-color: #fff !important;
    box-shadow: inset 0 0 3vh rgba(255, 255, 255, 0.3) !important;
}

/* Pojedyncza strefa (rząd) w kolumnie */
.board-column .board-row {
    height: 100%;
    min-height: auto;
    border-radius: 0.5vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5vh;
    transition: all 0.2s ease;
    box-shadow: inset 0 0 1.5vh rgba(0,0,0,0.7);
    border: 0.1vh solid rgba(255, 255, 255, 0.02);
}

.board-column .board-row.diplomacy-row {
    background: linear-gradient(180deg, var(--row-diplomacy) 0%, rgba(19, 43, 33, 0.1) 100%);
}
.board-column .board-row.military-row {
    background: linear-gradient(180deg, var(--row-military) 0%, rgba(54, 20, 20, 0.1) 100%);
}
.board-column .board-row.economy-row {
    background: linear-gradient(180deg, var(--row-economy) 0%, rgba(51, 38, 17, 0.1) 100%);
}

.zone-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(212, 175, 55, 0.3) 50%, transparent 100%);
    margin: 0.2vh 0;
    flex-shrink: 0;
}

/* Etykiety i wyniki wewnątrz kolumn planszy */
.board-column .row-label {
    position: absolute;
    left: 1vh;
    top: 0.8vh;
    font-family: var(--font-cinzel);
    font-weight: 700;
    font-size: clamp(0.65rem, 1.2vh, 0.85rem);
    color: rgba(220, 208, 192, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    pointer-events: none;
    display: flex;
    align-items: flex-start;
    gap: 0.4vw;
    z-index: 10;
}

.row-icon-mini {
    width: 1.8vh;
    height: 1.8vh;
    object-fit: contain;
    opacity: 0.7;
}

.board-column .row-score {
    position: absolute;
    right: 1vh;
    top: 0.8vh;
    transform: none;
    font-family: var(--font-cinzel);
    font-size: clamp(1.2rem, 2.5vh, 1.8rem);
    font-weight: 800;
    opacity: 0.85;
    pointer-events: none;
    z-index: 10;
}

.diplomacy-row .row-score { color: var(--row-diplomacy-border); }
.military-row .row-score { color: var(--row-military-border); }
.economy-row .row-score { color: var(--row-economy-border); }

/* Kontener kart w kolumnie */
.board-column .cards-container {
    display: flex;
    height: 100%;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 3vh 0.5vh 0.5vh 0.5vh;
    overflow: visible;
    box-sizing: border-box;
}

.cards-container::-webkit-scrollbar {
    display: none;
}

/* Przeciwnik (AI) - etykiety i kontenery kart odwrócone na dół */
.enemy-side.board-column .row-label {
    top: auto;
    bottom: 0.8vh;
}
.enemy-side.board-column .row-score {
    top: auto;
    bottom: 0.8vh;
}
.enemy-side.board-column .cards-container {
    padding: 0.5vh 0.5vh 3vh 0.5vh;
}

/* Strefa stosów kart (Talia i Cmentarz) */
.pile-zone {
    width: calc(10.5 * var(--vh));
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 2.2vh 0.2vw;
    background: rgba(18, 10, 6, 0.4);
    border: 0.15vh solid rgba(212, 175, 55, 0.12);
    border-radius: 0.8vh;
    box-shadow: inset 0 0 1.5vh rgba(0,0,0,0.6);
}

.pile-divider {
    height: 1px;
    width: 80%;
    background: rgba(212, 175, 55, 0.15);
    margin: 1.5vh 0;
}

.pile-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.card-pile {
    width: 9vh;
    height: 12vh;
    border: 0.2vh solid #5a4119;
    border-radius: 0.4vh;
    position: relative;
    cursor: default;
    box-shadow: 0 0.4vh 0.8vh rgba(0,0,0,0.6);
    background-size: cover;
    background-position: center;
    background-color: rgba(26, 18, 11, 0.88);
    transition: transform var(--transition-speed), border-color var(--transition-speed);
}
.card-pile:hover {
    transform: translateY(-0.2vh) scale(1.05);
}

.card-pile.enemy-deck,
.card-pile.player-deck {
    background-image: url('assets/card_back.png');
    border-color: var(--gold);
}

.card-pile.empty {
    background-image: none !important;
    border-color: #5a4119 !important;
}

.pile-card-content {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 0.2vh;
}

.empty-pile-icon {
    width: 4vh;
    height: 5vh;
    color: rgba(212, 175, 55, 0.18);
    pointer-events: none;
}

.pile-count {
    position: absolute;
    top: -1.2vh;
    right: -1.2vh;
    background: #1e130c;
    border: 0.18vh solid var(--gold);
    color: #fff;
    border-radius: 50%;
    width: 2.8vh;
    height: 2.8vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-cinzel);
    font-size: 1.4vh;
    font-weight: bold;
    box-shadow: 0 0.3vh 0.6vh rgba(0, 0, 0, 0.7);
    z-index: 10;
}

.pile-label {
    font-family: var(--font-cinzel);
    font-size: clamp(0.55rem, 1vh, 0.72rem);
    text-transform: uppercase;
    color: var(--gold);
    text-shadow: 0 0 0.6vh #000;
    margin-top: 0.8vh;
}

/* Mini Monarch Card (for graveyard top-card display) */
.monarch-card-playable.mini {
    cursor: default;
    border: 0.15vh solid var(--gold);
    border-radius: 0.4vh;
    box-shadow: none;
    transform: none;
}
.monarch-card-playable.mini:hover {
    transform: none;
    box-shadow: none;
}
.monarch-card-playable.mini .card-power-badge.mini {
    font-size: 0.95vh;
    width: 1.8vh;
    height: 1.8vh;
    line-height: 1.8vh;
    border-width: 0.12vh;
    border-radius: 0.3vh;
    top: 0.4vh;
    left: 0.4vh;
}
.monarch-card-playable.mini .card-bottom-overlay.mini {
    padding: 0.3vh;
    background: linear-gradient(to top, rgba(0,0,0,0.95) 75%, rgba(0,0,0,0) 100%);
}
.monarch-card-playable.mini .card-name-overlay.mini {
    font-size: clamp(0.5rem, 0.75vh, 0.65rem);
    margin-bottom: 0.1vh;
    line-height: 1.1;
    max-height: 2.2vh;
}
.monarch-card-playable.mini .card-dynasty-overlay.mini {
    font-size: clamp(0.35rem, 0.5vh, 0.45rem);
    line-height: 1;
}

/* Graveyard card specific filter to feel like a "discarded" history piece */
.graveyard-card {
    filter: grayscale(20%) sepia(0.25) brightness(0.6);
    transition: filter var(--transition-speed);
}
.card-pile:hover .graveyard-card {
    filter: sepia(0.15) brightness(0.75);
}

/* Ręka przeciwnika (rewersy) */
#enemy-hand-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: calc(12 * var(--vh));
    min-height: 90px;
    overflow: visible;
    margin-top: -0.2vh;
    margin-bottom: 0.6vh;
    background: transparent;
    border-radius: 0.6vh;
    border: none;
    width: 100%;
    position: relative;
    top: -30px;
    z-index: 20;
}

#enemy-hand-cards {
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible;
    padding: 0 1vw;
}

.enemy-card-wrapper {
    position: relative;
    width: calc(7.5 * var(--vh));
    height: calc(10.5 * var(--vh));
    flex-shrink: 0;
    overflow: visible;
    
    /* Parametry dla łuku (fan) */
    transform-origin: top center;
    transform: translateX(var(--card-dx, 0)) translateY(var(--card-dy, 0)) rotate(var(--card-rot, 0deg));
    z-index: var(--card-z, 10);
    transition: z-index 0.2s;
}

.enemy-card-wrapper:hover {
    z-index: 50 !important;
}

.enemy-card-wrapper:not(:first-child) {
    margin-left: -2.8vh;
}

.enemy-card-back {
    width: 100%;
    height: 100%;
    background-image: url('assets/card_back.png');
    background-size: cover;
    background-position: center;
    border: 0.18vh solid var(--gold);
    border-radius: 0.4vh;
    box-shadow: 0 0.4vh 0.8vh rgba(0,0,0,0.6);
    transition: transform var(--transition-speed);
    transform-origin: top center;
}

.enemy-card-wrapper:hover .enemy-card-back {
    transform: translateY(1.2vh) scale(1.18);
    box-shadow: 0 0.8vh 1.6vh rgba(0,0,0,0.8), 0 0 1vh var(--gold-glow);
}

/* Ręka gracza na dole */
#player-hand-container {
    background: var(--panel-bg);
    border: 0.1vh solid #4a3423;
    padding: 1.5vh 1.5vw 6.5vh 1.5vw;
    border-radius: 0.6vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    position: relative;
    height: calc(24 * var(--vh));
    min-height: 140px;
    overflow: visible;
    box-shadow: 0 0.4vh 1vh rgba(0, 0, 0, 0.4);
    z-index: 20;
}

#player-hand-container .player-info {
    position: absolute;
    bottom: 0.8vh;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25; /* Powyżej kart na ręku */
    display: flex;
    align-items: center;
    background: rgba(18, 10, 6, 0.92);
    border: 0.15vh solid var(--gold);
    border-radius: 0.6vh;
    padding: 0.5vh 1.5vw;
    box-shadow: 0 0.4vh 1.2vh rgba(0, 0, 0, 0.75);
    transition: all var(--transition-speed);
}

#player-hand-container .player-info:hover {
    border-color: #fff;
    box-shadow: 0 0.4vh 1.5vh rgba(255, 255, 255, 0.25);
}

#player-hand-container > div:last-child {
    position: absolute;
    bottom: 0.8vh;
    right: 1.5vw;
    z-index: 25;
    display: flex;
    align-items: center;
    gap: 1vw;
}

#hand-cards {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    position: relative;
    width: 100%;
    height: 100%;
    overflow: visible;
    margin-bottom: -1vh;
}

/* Wrapper dla karty w ręce w celu uniknięcia drgań (shaking) przy najechaniu myszką */
.card-wrapper {
    position: relative;
    width: calc(14 * var(--vh));
    height: calc(20.5 * var(--vh));
    flex-shrink: 0;
    overflow: visible;
    
    /* Parametry dla łuku (fan) */
    transform-origin: bottom center;
    transform: translateX(var(--card-dx, 0)) translateY(var(--card-dy, 0)) rotate(var(--card-rot, 0deg));
    z-index: var(--card-z, 10);
    transition: z-index 0.2s;
}

.card-wrapper:hover {
    z-index: 50 !important;
}

.card-wrapper.dragging {
    opacity: 0.35;
}

/* Stylizacja Karty */
.monarch-card-playable {
    background: var(--parchment);
    color: var(--text-dark);
    width: 100%;
    height: 100%;
    border: 0.3vh solid var(--gold);
    border-radius: 0.6vh;
    box-shadow: 0 0.5vh 1vh rgba(0, 0, 0, 0.5);
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: grab;
    position: relative;
    overflow: hidden;

    /* Płynne powiększenie wewnątrz stabilnego wrappera */
    transform-origin: bottom center;
    transition: transform 0.22s cubic-bezier(0.18, 0.89, 0.32, 1.28), box-shadow 0.2s, border-color 0.2s;
}

.card-wrapper:hover .monarch-card-playable {
    transform: translateY(-1.5vh) scale(1.25);
    box-shadow: 0 1vh 2.5vh rgba(0, 0, 0, 0.7);
}

.card-wrapper.selected-for-play .monarch-card-playable {
    border-color: #fff;
    box-shadow: 0 0 1.5vh #fff;
    transform: translateY(-2vh) scale(1.1);
}

.card-wrapper.selected-for-play:hover .monarch-card-playable {
    transform: translateY(-2.5vh) scale(1.25);
    box-shadow: 0 1vh 2.5vh rgba(255, 255, 255, 0.4);
}

/* Card portrait background (full-art style) */
.card-portrait-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    z-index: 1;
    pointer-events: none;
}

/* Power Badge */
.card-power-badge {
    position: absolute;
    top: 0.8vh;
    left: 0.8vh;
    font-family: var(--font-cinzel);
    font-weight: bold;
    font-size: clamp(0.95rem, 1.5vh, 1.25rem);
    background: #1b130e;
    color: #fff;
    border: 0.25vh solid var(--gold);
    border-radius: 50%;
    width: 3.2vh;
    height: 3.2vh;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    box-shadow: 0 0.3vh 0.6vh rgba(0, 0, 0, 0.6), inset 0 0 0.5vh rgba(255, 255, 255, 0.1);
}

.card-power-badge.power-boosted {
    color: #2ecc71;
    border-color: #2ecc71;
    text-shadow: 0 0 0.5vh rgba(46, 204, 113, 0.6);
}

.card-power-badge.power-weakened {
    color: #e74c3c;
    border-color: #e74c3c;
    text-shadow: 0 0 0.5vh rgba(231, 76, 60, 0.6);
}

/* Cost Badge (wax seal style) */
.card-cost-badge {
    position: absolute;
    top: 0.8vh;
    right: 0.8vh;
    background: #8a1313;
    color: #fff;
    border: 0.25vh solid var(--gold);
    border-radius: 50%;
    width: 3.2vh;
    height: 3.2vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-cinzel);
    font-weight: bold;
    font-size: clamp(0.95rem, 1.5vh, 1.25rem);
    z-index: 10;
    box-shadow: 0 0.3vh 0.6vh rgba(0, 0, 0, 0.6);
}

/* Bottom banner / text overlay */
.card-bottom-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.7) 60%, rgba(0, 0, 0, 0) 100%);
    padding: 1.5vh 0.8vh 0.8vh 0.8vh;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 0.2vh;
    pointer-events: none;
}

.card-name-overlay {
    font-family: var(--font-cinzel);
    font-weight: 700;
    font-size: clamp(0.7rem, 1.1vh, 0.95rem);
    color: var(--gold);
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.15;
    text-transform: uppercase;
    letter-spacing: 0.01em;
    text-shadow: 0 0.2vh 0.4vh rgba(0,0,0,0.8);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-dynasty-overlay {
    font-family: var(--font-serif);
    font-size: clamp(0.55rem, 0.9vh, 0.75rem);
    color: #dcd0c0;
    opacity: 0.85;
    text-shadow: 0 0.1vh 0.3vh rgba(0,0,0,0.8);
}

.card-traits-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.65);
    border-radius: 0.3vh;
    padding: 0.2vh 0.4vh;
    margin-top: 0.4vh;
    border: 0.1vh solid rgba(212, 175, 55, 0.15);
}

.trait-val {
    font-family: var(--font-cinzel);
    font-size: clamp(0.6rem, 1vh, 0.75rem);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.2vw;
}

.trait-val.diplomacy { color: #52be80; }
.trait-val.military { color: #ec7063; }
.trait-val.economy { color: #f4d03f; }

.card-trait-icon {
    width: 1.3vh;
    height: 1.3vh;
    object-fit: contain;
}

/* Dynasty Borders and Glows */
.monarch-card-playable.dynasty-piastowie {
    border-color: #d4af37; /* Gold */
    box-shadow: 0 0.5vh 1vh rgba(0, 0, 0, 0.5), inset 0 0 1vh rgba(212, 175, 55, 0.2);
}
.monarch-card-playable.dynasty-jagiellonowie {
    border-color: #a11818; /* Polish Crimson */
    box-shadow: 0 0.5vh 1vh rgba(0, 0, 0, 0.5), inset 0 0 1vh rgba(161, 24, 24, 0.2);
}
.monarch-card-playable.dynasty-wazowie {
    border-color: #2e86de; /* Royal Blue */
    box-shadow: 0 0.5vh 1vh rgba(0, 0, 0, 0.5), inset 0 0 1vh rgba(46, 134, 222, 0.2);
}

/* Dynasty Hover Glows */
.monarch-card-playable.dynasty-piastowie:hover {
    box-shadow: 0 1vh 2.5vh rgba(0, 0, 0, 0.6), 0 0 1.5vh rgba(212, 175, 55, 0.7);
}
.monarch-card-playable.dynasty-jagiellonowie:hover {
    box-shadow: 0 1vh 2.5vh rgba(0, 0, 0, 0.6), 0 0 1.5vh rgba(161, 24, 24, 0.7);
}
.monarch-card-playable.dynasty-wazowie:hover {
    box-shadow: 0 1vh 2.5vh rgba(0, 0, 0, 0.6), 0 0 1.5vh rgba(46, 134, 222, 0.7);
}

/* Karty zagrane na planszy - są bardziej kompaktowe, ale wystają poza wiersze */
.board-row {
    overflow: visible !important;
}

.board-row .monarch-card-playable {
    width: calc(9.56 * var(--vh));
    height: calc(14 * var(--vh));
    cursor: default;
    border-width: 0.25vh;
    border-radius: 0.5vh;
    padding: 0;
    transition: transform var(--transition-speed) cubic-bezier(0.18, 0.89, 0.32, 1.28), z-index var(--transition-speed), box-shadow var(--transition-speed);
}

.board-row .monarch-card-playable:not(:first-child) {
    margin-left: -3vh; /* Overlapping card effect */
}

/* Cards inside board rows should be clean and straight (as columns are already rotated) */
.board-row .monarch-card-playable {
    transform: rotate(0deg);
}
.board-row .monarch-card-playable:hover {
    transform: scale(1.35);
    z-index: 100 !important;
    box-shadow: 0 1vh 2.5vh rgba(0,0,0,0.8), 0 0 1vh var(--gold-glow);
}

.board-row .monarch-card-playable .card-cost-badge {
    display: none;
}

.board-row .monarch-card-playable .card-bottom-overlay {
    padding: 1.2vh 0.4vh 0.4vh 0.4vh;
}

.board-row .monarch-card-playable .card-name-overlay {
    font-size: clamp(0.6rem, 0.85vh, 0.75rem);
}

.board-row .monarch-card-playable .card-dynasty-overlay {
    font-size: clamp(0.55rem, 0.8vh, 0.7rem);
}

.board-row .monarch-card-playable .card-power-badge {
    width: 2.6vh;
    height: 2.6vh;
    font-size: clamp(0.8rem, 1.1vh, 0.95rem);
    top: 0.5vh;
    left: 0.5vh;
    border-width: 0.15vh;
}

/* Prawa strona - Panel sterowania i kronika */
#control-sidebar {
    width: 22vw;
    min-width: 320px;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 1vh;
    height: 100%;
}

.sidebar-section {
    background: var(--panel-bg);
    border: 0.1vh solid #4a3423;
    border-radius: 0.6vh;
    padding: 2vh;
    box-shadow: 0 0.4vh 1vh rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
}

.score-board {
    text-align: center;
    padding: 1vh 0;
    border-bottom: 0.2vh double var(--gold);
    margin-bottom: 1vh;
}

.score-board-title {
    font-size: clamp(0.75rem, 1.3vh, 0.9rem);
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: var(--font-cinzel);
}

.score-digits {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5vw;
    margin: 1vh 0;
}

.player-score-large {
    font-family: var(--font-cinzel);
    font-weight: 800;
    font-size: clamp(2.5rem, 5vh, 3.8rem);
    color: #fff;
    text-shadow: 0 0 1.5vh rgba(255,255,255,0.25);
    letter-spacing: 0.05vw;
}

.score-vs {
    font-family: var(--font-cinzel);
    font-size: clamp(1rem, 1.8vh, 1.4rem);
    color: var(--gold);
    letter-spacing: 0.05em;
}

.round-indicator {
    font-family: var(--font-cinzel);
    font-size: clamp(0.95rem, 1.6vh, 1.15rem);
    color: var(--gold);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.1em;
}

/* Tokeny wydarzeń w panelu bocznym */
.tokens-area {
    flex-grow: 1;
    overflow-y: auto;
    margin-top: 1vh;
}

.tokens-list {
    display: flex;
    flex-direction: column;
    gap: 1vh;
    margin-top: 1vh;
}

.token-item {
    background: rgba(0,0,0,0.3);
    border: 0.1vh solid #5a4119;
    border-radius: 0.4vh;
    padding: 1.2vh;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1vw;
    transition: border-color 0.2s;
    flex-shrink: 0;
}

.token-item:hover {
    border-color: var(--gold);
}

.token-info {
    display: flex;
    flex-direction: column;
}

.token-name {
    font-family: var(--font-cinzel);
    font-size: clamp(0.85rem, 1.5vh, 1.05rem);
    font-weight: bold;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.token-desc {
    font-size: clamp(0.7rem, 1.2vh, 0.8rem);
    color: var(--text-light);
    opacity: 0.85;
    line-height: 1.4;
    font-family: var(--font-serif);
}

.token-cost {
    background: #8a1313;
    color: #fff;
    padding: 0.5vh 1vh;
    border-radius: 0.4vh;
    font-size: clamp(0.7rem, 1.2vh, 0.8rem);
    font-weight: bold;
    cursor: pointer;
    border: 0.1vh solid var(--gold);
    text-align: center;
    white-space: nowrap;
    font-family: var(--font-cinzel);
    letter-spacing: 0.05em;
}

.token-cost:hover {
    background: #a11818;
}

/* Przyciski operacyjne */
.btn-panel {
    display: flex;
    gap: 1vw;
}

.game-btn {
    flex-grow: 1;
    background: rgba(0,0,0,0.6);
    border: 0.1vh solid var(--gold);
    color: var(--text-light);
    padding: 1vh;
    font-size: clamp(0.8rem, 1.4vh, 0.95rem);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-cinzel);
    border-radius: 0.4vh;
}

.game-btn:hover {
    background: var(--gold);
    color: #000;
}

.game-btn.pass-btn {
    border-color: #888;
    color: #bbb;
}

.game-btn.pass-btn:hover {
    background: #333;
    color: #fff;
    border-color: #eee;
}

.game-btn.pass-btn.passed {
    background: #222;
    color: #555;
    border-color: #333;
    cursor: not-allowed;
}

/* Kronika wydarzeń - całkiem na lewo, rozciąga się od góry do dołu */
.chronicle-section {
    width: 25vw;
    min-width: 350px;
    max-width: 550px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#chronicle-log {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0.5vh;
    display: flex;
    flex-direction: column;
    gap: 0.6vh;
    font-family: var(--font-serif);
    font-size: clamp(0.9rem, 1.6vh, 1.15rem);
    line-height: 1.55;
    color: #dfcfb2;
    border-top: 0.1vh solid #3a2212;
    margin-top: 1vh;
}

.log-row {
    border-bottom: 0.1vh solid rgba(212,175,55,0.08);
    padding: 0.8vh 0.5vh;
    animation: fadeIn 0.3s ease-out;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 8px;
    font-size: clamp(0.82rem, 1.45vh, 1.02rem);
    flex-shrink: 0;
}

/* Kiedy kolumna z efektami jest pusta, zdarzenie zajmuje pełną szerokość */
.log-row:has(.log-col-effect:empty) {
    grid-template-columns: 1fr;
}

.log-row:has(.log-col-effect:empty) .log-col-effect {
    display: none;
}

.log-col-event {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    word-break: normal;
    overflow-wrap: break-word;
}

.log-col-effect {
    display: flex;
    flex-direction: column;
    gap: 0.4vh;
    border-left: 0.1vh solid rgba(212, 175, 55, 0.15);
    padding-left: 8px;
}

.log-effect-item {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    font-size: clamp(0.78rem, 1.35vh, 0.95rem);
    word-break: normal;
    overflow-wrap: break-word;
}

/* Wpis pomocniczy / sub-effect (np. synergie) */
.log-effect-item.sub-effect {
    padding-left: 4px;
    font-size: clamp(0.78rem, 1.35vh, 0.95rem);
}

/* Pending entry adjustments (sekwencyjne rozwijanie) */
.log-row.pending-entry {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
    border-bottom-color: rgba(212, 175, 55, 0);
    overflow: hidden;
    animation: none;
    transition: max-height 0.4s cubic-bezier(0.25, 1, 0.5, 1), 
                opacity 0.3s ease-out, 
                padding 0.4s cubic-bezier(0.25, 1, 0.5, 1),
                margin 0.4s cubic-bezier(0.25, 1, 0.5, 1),
                border-color 0.4s ease;
}

.log-row.pending-entry.expanded {
    max-height: 500px; /* Rozwiązuje problem ucinania tekstu */
    opacity: 1;
    padding: 0.8vh 0.5vh;
    border-bottom: 0.1vh solid rgba(212, 175, 55, 0.08);
}

/* Separator rundy */
.log-row.round-separator {
    display: block;
    background: linear-gradient(90deg, rgba(212,175,55,0) 0%, rgba(212,175,55,0.08) 50%, rgba(212,175,55,0) 100%);
    border-top: 0.1vh solid rgba(212,175,55,0.15);
    border-bottom: 0.1vh solid rgba(212,175,55,0.15);
    padding: 1vh 0.5vh;
    margin: 1.5vh 0;
    font-family: var(--font-cinzel);
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.separator-inner {
    text-align: center;
    font-size: clamp(0.75rem, 1.4vh, 0.95rem);
    text-shadow: 0 0 1vh rgba(212,175,55,0.2);
}

/* Elementy wpisu */
.log-icon {
    font-size: clamp(0.75rem, 1.4vh, 0.95rem);
    flex-shrink: 0;
    margin-top: 0.1vh;
}

.log-sub-arrow {
    color: var(--text-gray);
    font-size: clamp(0.75rem, 1.4vh, 0.95rem);
    flex-shrink: 0;
    margin-top: -0.1vh;
}

.log-text-content {
    flex-grow: 1;
    word-break: break-word;
}

.log-text-content.italic {
    font-style: italic;
    color: #c4b395;
}

/* Tagi i Kolory */
.log-tag {
    background: rgba(212,175,55,0.12);
    border: 0.1vh solid rgba(212,175,55,0.3);
    border-radius: 0.3vh;
    padding: 0.1vh 0.5vh;
    font-size: 0.85em;
    font-family: var(--font-cinzel);
    font-weight: 700;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 0.3vw;
    display: inline-block;
    vertical-align: middle;
}

.log-positive {
    color: #2ecc71;
    font-weight: 700;
    text-shadow: 0 0 0.8vh rgba(46,204,113,0.25);
}

.log-negative {
    color: #e74c3c;
    font-weight: 700;
    text-shadow: 0 0 0.8vh rgba(231,76,60,0.25);
}

.log-sclav {
    color: var(--gold);
    font-weight: 700;
    text-shadow: 0 0 0.8vh rgba(212,175,55,0.25);
}

.log-row.system { color: var(--gold); font-weight: bold; }
.log-row.player { color: #82e0aa; }
.log-row.enemy { color: #f1948a; }

.log-effect-item.system { color: var(--gold); }
.log-effect-item.player { color: #82e0aa; }
.log-effect-item.enemy { color: #f1948a; }

/* Overlay wygranej / przegranej */
#game-over-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 3100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

#game-over-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.game-over-box {
    background: rgba(18, 10, 6, 0.95);
    border: 0.3vh solid var(--gold);
    border-image: linear-gradient(to bottom, var(--gold), #5a4119) 1;
    padding: 5vh;
    box-shadow: 0 0 5vh rgba(212,175,55,0.2);
    width: 90%;
    max-width: 35vw;
    min-width: 450px;
    text-align: center;
    border-radius: 0.6vh;
}

.game-over-title {
    font-family: var(--font-gothic);
    font-size: clamp(3rem, 7vh, 4.5rem);
    color: var(--gold);
    margin: 0 0 2vh 0;
    text-shadow: 0 0 1.5vh var(--gold-glow);
    letter-spacing: 0.1vw;
}

.game-over-text {
    font-family: var(--font-serif);
    font-size: clamp(1.1rem, 2vh, 1.35rem);
    line-height: 1.6;
    margin-bottom: 4vh;
    color: var(--text-light);
}

/* Animacje */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(0.5vh); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes cardPlay {
    0% { transform: scale(1.5) translateY(5vh); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.animate-play {
    animation: cardPlay 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.pass-status-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #888, #666);
    color: #fff;
    border: 0.15vh solid rgba(255, 255, 255, 0.15);
    font-family: var(--font-cinzel);
    font-size: clamp(0.7rem, 1.2vh, 0.8rem);
    font-weight: bold;
    padding: 0.5vh 1.2vh;
    border-radius: 1.5vh;
    text-transform: uppercase;
    animation: fadeIn 0.3s;
    letter-spacing: 0.05em;
    flex-shrink: 0;
    box-shadow: none;
}

.treasury-shield {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1rem, 1.8vh, 1.35rem);
    margin-right: 0.3vw;
    animation: fadeIn 0.3s;
    filter: drop-shadow(0 0 0.4vh #2ecc71);
}

.loader-shield {
    margin-top: 1vh;
    font-size: clamp(0.85rem, 1.5vh, 1rem);
    color: var(--text-gray);
    font-style: italic;
    font-family: var(--font-serif);
}

/* Widowiskowy Announcer wydarzeń na środku ekranu */
#announcer-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2vh;
    pointer-events: none;
    z-index: 15;
}

.announcement-banner {
    background: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, rgba(20, 15, 10, 0.9) 15%, rgba(20, 15, 10, 0.9) 85%, rgba(0, 0, 0, 0) 100%);
    border-top: 0.15vh solid rgba(212, 175, 55, 0.45);
    border-bottom: 0.15vh solid rgba(212, 175, 55, 0.45);
    padding: 1.2vh 3vh;
    text-align: center;
    min-width: 35vw;
    max-width: 100%;
    box-shadow: 0 1vh 3vh rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(0.4vh);
    
    /* Animacja wpisu */
    animation: announcement-flow 5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.announcement-subtitle {
    font-family: var(--font-cinzel);
    font-size: clamp(0.55rem, 0.9vh, 0.75rem);
    color: var(--gold);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    margin-bottom: 0.3vh;
    opacity: 0.9;
}

.announcement-title {
    font-family: var(--font-cinzel);
    font-weight: 700;
    font-size: clamp(0.9rem, 1.7vh, 1.35rem);
    color: #fff;
    text-shadow: 0 0.2vh 0.4vh rgba(0, 0, 0, 0.95);
    letter-spacing: 0.05em;
}

/* Kolorystyka w zależności od nadawcy */
.announcement-banner.player .announcement-title {
    color: #f1c40f; /* Złoty dla Gracza */
}

.announcement-banner.enemy .announcement-title {
    color: #e74c3c; /* Czerwony dla AI */
}

.announcement-banner.system .announcement-title {
    color: #e5e8e8; /* Srebrno-biały dla systemu */
}

@keyframes announcement-flow {
    0% {
        transform: translateY(2vh) scale(0.95);
        opacity: 0;
    }
    12% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    85% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-1.5vh) scale(0.98);
        opacity: 0;
    }
}

/* Modal Księgi Zasad (Rules Book) */
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.rules-box {
    background: rgba(18, 10, 6, 0.98);
    border: 0.3vh solid var(--gold);
    border-image: linear-gradient(to bottom, var(--gold), #5a4119) 1;
    padding: 3vh 4vh;
    box-shadow: 0 0 6vh rgba(0, 0, 0, 0.95), 0 0 2vh rgba(212, 175, 55, 0.15);
    width: 76vw;
    min-width: 520px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    border-radius: 0.6vh;
    position: relative;
    box-sizing: border-box;
    transform: scale(0.9);
    transition: transform 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.15);
}

.modal-overlay.visible .rules-box {
    transform: scale(1);
}

.modal-title {
    color: var(--gold);
    text-align: center;
    margin: 0 0 2vh 0;
    font-size: clamp(1.2rem, 2.4vh, 1.7rem);
    text-shadow: 0 0 1vh rgba(212,175,55,0.25);
    letter-spacing: 0.05em;
    border-bottom: 0.2vh double #4a3423;
    padding-bottom: 1.5vh;
}

.close-modal-btn {
    position: absolute;
    right: 2.5vh;
    top: 1.8vh;
    font-size: 2.2rem;
    color: var(--text-gray);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
    user-select: none;
}

.close-modal-btn:hover {
    color: var(--gold);
}

.rules-scroll-area {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 1.5vh;
    margin-bottom: 2vh;
    font-family: var(--font-serif);
    font-size: clamp(0.85rem, 1.45vh, 1.05rem);
    line-height: 1.6;
    color: #dfcfb2;
}

/* Custom Scrollbar dla obszaru zasad */
.rules-scroll-area::-webkit-scrollbar {
    width: 0.6vw;
    min-width: 6px;
}
.rules-scroll-area::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0.3vh;
}
.rules-scroll-area::-webkit-scrollbar-thumb {
    background: #4a3423;
    border: 0.1vh solid var(--gold);
    border-radius: 0.3vh;
}
.rules-scroll-area::-webkit-scrollbar-thumb:hover {
    background: #5a4119;
}

.rules-section {
    margin-bottom: 3vh;
    border-bottom: 0.1vh solid rgba(212, 175, 55, 0.08);
    padding-bottom: 2.5vh;
}

.rules-section:last-child {
    border-bottom: none;
    margin-bottom: 1vh;
    padding-bottom: 0;
}

.rules-section-title {
    font-family: var(--font-cinzel);
    color: var(--gold);
    margin: 0 0 1vh 0;
    font-size: clamp(0.95rem, 1.7vh, 1.25rem);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rules-scroll-area p {
    margin: 0 0 1vh 0;
}

.rules-scroll-area ul {
    margin: 0;
    padding-left: 1.5vw;
}

.rules-scroll-area li {
    margin-bottom: 1vh;
}

.modal-close-btn {
    align-self: center;
    width: auto;
    padding: 1.2vh 4vh;
    font-size: clamp(0.85rem, 1.5vh, 1.05rem);
    border-color: var(--gold);
}

/* Podręczne wskazówki rzędów planszy */
.row-effect-hint {
    color: var(--gold);
    font-size: clamp(0.55rem, 0.95vh, 0.75rem);
    font-weight: normal;
    text-transform: none;
    font-style: italic;
    letter-spacing: 0;
    opacity: 0.75;
    pointer-events: none;
    position: absolute;
    z-index: 10;
    line-height: 1.25;
}

/* W pustych rogach dla gracza (na dole po lewej) */
.player-side .row-effect-hint {
    bottom: 0.8vh;
    left: 1vh;
}

/* W pustych rogach dla przeciwnika (na górze po lewej) */
.enemy-side .row-effect-hint {
    top: 0.8vh;
    left: 1vh;
}

/* Przycisk informacyjny na karcie */
.card-info-btn {
    position: absolute;
    top: 0.8vh;
    right: 0.8vh;
    background: #1b130e;
    color: var(--gold);
    border: 0.15vh solid var(--gold);
    border-radius: 50%;
    width: 2.2vh;
    height: 2.2vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1vh;
    font-weight: bold;
    cursor: pointer;
    z-index: 15;
    box-shadow: 0 0.2vh 0.4vh rgba(0,0,0,0.6);
    transition: transform 0.2s, background-color 0.2s, color 0.2s;
    font-family: var(--font-cinzel), serif;
}

.card-info-btn:hover {
    transform: scale(1.2) !important;
    background: var(--gold);
    color: #1b130e;
}

/* Pozycjonowanie przycisku informacyjnego w przypadku obecności badge'u kosztu */
.monarch-card-playable.has-cost .card-info-btn {
    top: 4.8vh;
}

/* Szczegóły modala monarchy */
.details-box {
    background: rgba(18, 10, 6, 0.98);
    border: 0.3vh solid var(--gold);
    border-image: linear-gradient(to bottom, var(--gold), #5a4119) 1;
    padding: 3vh 4vh;
    box-shadow: 0 0 6vh rgba(0, 0, 0, 0.95), 0 0 2vh rgba(212, 175, 55, 0.15);
    width: 78vw;
    min-width: 520px;
    max-width: 1050px;
    height: 82vh;
    display: flex;
    flex-direction: column;
    border-radius: 0.6vh;
    position: relative;
    box-sizing: border-box;
    transform: scale(0.9);
    transition: transform 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.15);
}

.modal-overlay.visible .details-box {
    transform: scale(1);
}

.details-content-area {
    flex-grow: 1;
    overflow: hidden;
    margin-bottom: 2vh;
}

.details-grid {
    display: flex;
    flex-direction: row;
    gap: 3vh;
    height: 100%;
    overflow: hidden;
}

.details-left {
    flex: 0 0 40%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 1.5vh;
    padding-top: 1vh;
}

.details-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 1.5vh;
    padding-bottom: 2vh;
}

/* Custom Scrollbar for details modal right side */
.details-right::-webkit-scrollbar {
    width: 6px;
}
.details-right::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0.3vh;
}
.details-right::-webkit-scrollbar-thumb {
    background: #4a3423;
    border: 0.1vh solid var(--gold);
    border-radius: 0.3vh;
}
.details-right::-webkit-scrollbar-thumb:hover {
    background: #5a4119;
}

.monarch-card-playable.detail-view {
    width: calc(18 * var(--vh));
    height: calc(26.25 * var(--vh));
    cursor: default;
    box-shadow: 0 1vh 3vh rgba(0,0,0,0.8);
    transform: none !important;
}

.monarch-card-playable.detail-view .card-cost-badge {
    display: none;
}

.card-power-badge.detail-view {
    width: 4vh;
    height: 4vh;
    font-size: 1.5rem;
    top: 1vh;
    left: 1vh;
}

.card-bottom-overlay.detail-view {
    padding: 2vh 1vh 1vh 1vh;
}

.card-name-overlay.detail-view {
    font-size: clamp(0.9rem, 1.4vh, 1.25rem);
}

.card-dynasty-overlay.detail-view {
    font-size: clamp(0.7rem, 1vh, 0.9rem);
}

.card-reign-overlay.detail-view {
    font-family: var(--font-serif);
    font-size: clamp(0.7rem, 1vh, 0.9rem);
    color: #dfcfb2;
    opacity: 0.95;
    margin-top: 0.2vh;
}

.details-facts-list {
    margin: 0;
    padding-left: 2vh;
    color: #dfcfb2;
    font-family: var(--font-serif);
    font-size: clamp(0.85rem, 1.35vh, 1.05rem);
    line-height: 1.5;
}

.details-facts-list li {
    margin-bottom: 1vh;
}

.details-stats-row {
    display: flex;
    justify-content: space-between;
    gap: 1vh;
    flex-wrap: wrap;
    background: rgba(0,0,0,0.4);
    border: 0.1vh solid #5a4119;
    border-radius: 0.4vh;
    padding: 1.2vh;
    margin-bottom: 2vh;
    width: calc(18 * var(--vh));
    box-sizing: border-box;
}

.details-section-title {
    font-family: var(--font-cinzel);
    color: var(--gold);
    font-size: clamp(0.85rem, 1.45vh, 1.15rem);
    text-shadow: 0 0.1vh 0.2vh rgba(0, 0, 0, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0;
    text-align: center;
}

.detail-stat {
    display: flex;
    align-items: center;
    gap: 0.5vh;
    font-family: var(--font-cinzel);
    font-size: clamp(0.75rem, 1.2vh, 0.9rem);
}

.detail-stat.diplomacy { color: #52be80; }
.detail-stat.military { color: #ec7063; }
.detail-stat.economy { color: #f4d03f; }

.details-parents-row {
    display: flex;
    flex-direction: column;
    gap: 0.8vh;
    background: rgba(0,0,0,0.25);
    border-radius: 0.4vh;
    padding: 1.2vh;
    margin-top: auto;
    border: 0.1vh solid rgba(212,175,55,0.08);
}

.parent-item {
    font-family: var(--font-serif);
    font-size: clamp(0.8rem, 1.3vh, 0.95rem);
    color: #dfcfb2;
}

.parent-item strong {
    color: var(--gold);
    font-family: var(--font-cinzel);
    font-size: 0.85rem;
    margin-right: 0.5vw;
}

/* Stylizacja popovera kroniki wojennej */
.chronicle-popover-box {
    background: rgba(18, 10, 6, 0.99);
    border: 0.3vh solid var(--gold);
    border-image: linear-gradient(to bottom, var(--gold), #5a4119) 1;
    padding: 3vh 4vh;
    box-shadow: 0 0 6vh rgba(0, 0, 0, 0.95), 0 0 2vh rgba(212, 175, 55, 0.15);
    width: 50vw;
    min-width: 480px;
    max-width: 800px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    border-radius: 0.6vh;
    position: relative;
    box-sizing: border-box;
    transform: scale(0.9);
    transition: transform 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.15);
}

.modal-overlay.visible .chronicle-popover-box {
    transform: scale(1);
}

.chronicle-popover-content {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 1.5vh;
    margin-bottom: 2vh;
    font-family: var(--font-serif);
    font-size: clamp(1.15rem, 1.8vh, 1.45rem);
    line-height: 1.6;
    color: #dfcfb2;
}

/* Scrollbar styling for chronicle popover content */
.chronicle-popover-content::-webkit-scrollbar {
    width: 6px;
}
.chronicle-popover-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0.3vh;
}
.chronicle-popover-content::-webkit-scrollbar-thumb {
    background: #4a3423;
    border: 0.1vh solid var(--gold);
    border-radius: 0.3vh;
}
.chronicle-popover-content::-webkit-scrollbar-thumb:hover {
    background: #5a4119;
}

/* Zwiększone wiersze logu dla czytelności */
.chronicle-popover-content .log-row {
    margin-bottom: 1.8vh;
    padding-bottom: 1.5vh;
    border-bottom: 1px solid rgba(90, 65, 25, 0.2);
    font-size: clamp(1.15rem, 1.8vh, 1.45rem) !important;
}

.chronicle-popover-content .log-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.chronicle-popover-content .log-tag {
    font-size: 1.1em;
}

.chronicle-popover-content .log-icon {
    font-size: 1.3em;
}

/* Stylizacja kontrolek odtwarzacza muzyki w tle */
.lobby-music-control {
    margin-top: 3vh;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    background: rgba(30, 20, 15, 0.75);
    border: 1.5px solid var(--gold);
    padding: 1.2vh 2.5vw;
    border-radius: 30px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), 0 0 10px rgba(212, 175, 55, 0.1);
}
.lobby-music-control .music-toggle-btn {
    background: none;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    color: var(--gold);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}
.lobby-music-control .music-toggle-btn:hover {
    transform: scale(1.15);
}
.lobby-music-control .music-volume-slider {
    width: 120px;
    accent-color: var(--gold);
    cursor: pointer;
}

.game-music-control {
    margin-top: 1.5vh;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 1vh 1.5vh;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 0.5vh;
}
.game-music-control .music-toggle-btn {
    background: none;
    border: 1px solid var(--gold);
    color: var(--gold);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 0.3vh;
    min-width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, transform 0.1s ease;
}
.game-music-control .music-toggle-btn:hover {
    background: rgba(212, 175, 55, 0.12);
}
.game-music-control .music-toggle-btn:active {
    transform: scale(0.95);
}
.game-music-control .music-volume-slider {
    flex-grow: 1;
    accent-color: var(--gold);
    cursor: pointer;
    height: 5px;
}

/* =====================================================================
   ZAKŁADKI W MODALU SZCZEGÓŁÓW
   ===================================================================== */
.details-tabs-header {
    display: flex;
    justify-content: center;
    gap: 1vw;
    margin-bottom: 2vh;
    border-bottom: 0.15vh double #4a3423;
    padding-bottom: 1vh;
}

.details-tab-btn {
    background: rgba(30, 20, 15, 0.6);
    border: 0.15vh solid rgba(212, 175, 55, 0.3);
    color: #dfcfb2;
    padding: 0.8vh 2.2vh;
    font-family: var(--font-cinzel), serif;
    font-size: clamp(0.75rem, 1.3vh, 0.95rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    border-radius: 0.3vh;
    transition: all 0.2s ease;
}

.details-tab-btn:hover {
    background: rgba(212, 175, 55, 0.12);
    border-color: var(--gold);
    color: #fff;
    box-shadow: 0 0 1vh rgba(212, 175, 55, 0.15);
}

.details-tab-btn.active {
    background: var(--gold);
    border-color: var(--gold);
    color: #1b130e;
    box-shadow: 0 0 1.5vh rgba(212, 175, 55, 0.35);
}

.details-tab-panes {
    flex-grow: 1;
    overflow: hidden;
    height: calc(100% - 6vh);
}

.details-tab-pane {
    display: none;
    height: 100%;
}

.details-tab-pane.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

/* =====================================================================
   DRZEWO GENEALOGICZNE
   ===================================================================== */
.tree-container {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5vh 1vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3.5vh;
}

/* Custom Scrollbar */
.tree-container::-webkit-scrollbar {
    width: 6px;
}
.tree-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}
.tree-container::-webkit-scrollbar-thumb {
    background: #4a3423;
    border: 0.1vh solid var(--gold);
    border-radius: 0.3vh;
}

.tree-row {
    display: flex;
    justify-content: center;
    gap: 3vw;
    width: 100%;
    position: relative;
}

.grandparents-group {
    display: flex;
    gap: 1.5vw;
}

.tree-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 13.5vw;
    min-width: 160px;
    transition: transform 0.2s ease;
}

.tree-node.clickable-node {
    cursor: pointer;
}

.tree-node.clickable-node:hover {
    transform: scale(1.05);
}

.node-label {
    font-family: var(--font-cinzel), serif;
    font-size: clamp(0.55rem, 0.95vh, 0.75rem);
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5vh;
    opacity: 0.9;
    text-shadow: 0 0.1vh 0.2vh rgba(0,0,0,0.8);
}

.node-card {
    display: flex;
    align-items: center;
    gap: 1vh;
    width: 100%;
    padding: 0.8vh 1.2vh;
    background: rgba(30, 20, 15, 0.85);
    border: 0.15vh solid #5a4119;
    border-radius: 0.5vh;
    box-shadow: 0 0.4vh 1vh rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

/* Wyróżnienie aktywnego monarchy */
.tree-node.current-monarch-node .node-card {
    border-color: var(--gold);
    box-shadow: 0 0 1.5vh rgba(212, 175, 55, 0.45);
    background: rgba(45, 30, 15, 0.95);
}

.tree-node.current-monarch-node .node-label {
    font-weight: bold;
    text-shadow: 0 0 0.8vh rgba(212, 175, 55, 0.4);
}

.node-portrait {
    width: 4vh;
    height: 4vh;
    object-fit: cover;
    border-radius: 50%;
    border: 0.15vh solid var(--gold);
    background-color: #120a06;
}

.node-portrait-placeholder {
    width: 4vh;
    height: 4vh;
    border-radius: 50%;
    border: 0.15vh solid #8a735b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8vh;
    color: #8a735b;
    background: rgba(0,0,0,0.4);
    flex-shrink: 0;
}

.node-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    flex-grow: 1;
}

.node-name {
    font-family: var(--font-cinzel), serif;
    font-size: clamp(0.7rem, 1.25vh, 0.9rem);
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-node.clickable-node:hover .node-name {
    color: var(--gold);
}

.node-reign {
    font-family: var(--font-serif);
    font-size: clamp(0.55rem, 0.9vh, 0.75rem);
    color: var(--text-gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-arrow {
    font-size: clamp(1.2rem, 2vh, 1.6rem);
    color: rgba(212, 175, 55, 0.45);
    margin: -1vh 0;
    pointer-events: none;
    text-shadow: 0 0.1vh 0.2vh rgba(0,0,0,0.8);
    user-select: none;
}

