:root {
    /* --- COLOR PALETTE (Midnight Strategy) --- */
    --bg-primary: #0f172a; /* Deep Navy (Main Background) */
    --bg-secondary: #1e293b; /* Lighter Navy (Sidebar/Cards) */
    --accent: #ae8a70; /* Spartan Bronze (Buttons/Links/Active) */
    --accent-hover: #b8925e; /* Slightly darker gold for hover states */
    --text-main: #e2e8f0; /* Mist Grey (Main Text) */
    --text-muted: #94a3b8; /* Muted Blue-Grey (Secondary Text) */
    --greek-piece-dark: #3A2515; /* The deepest brown for dark checkers */
    --greek-accent: #4F4A41; /* The dark grey/olive for borders or outlines */
    --greek-tile-dark: #BA9A74; /* The tan color for "black" tiles */
    --greek-tile-light: #EEE4D5;
}

html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-main);
}

/* Updated Links to Gold */
a, .btn-link {
    color: var(--accent);
}

    a:hover {
        color: var(--accent-hover);
    }

/* Updated Primary Buttons to Spartan Bronze */
.btn-primary {
    color: #0f172a; /* Dark text on gold button reads better */
    font-weight: 600;
    background-color: var(--accent);
    border-color: var(--accent);
}

    .btn-primary:hover {
        background-color: var(--accent-hover);
        border-color: var(--accent-hover);
        color: #0f172a;
    }

/* Focus rings updated to match Gold theme instead of Blue */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem var(--bg-primary), 0 0 0 0.25rem var(--accent);
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--text-muted);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* --- NAVIGATION & SIDEBAR --- */

.nav-container {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.nav-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 120px;
}

.sidebar-shell {
    height: 100vh;
    display: flex;
    flex-direction: column;
    /* Sets the background of the sidebar to Lighter Navy */
    background-color: var(--bg-secondary);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    /* Modern mobile browsers */
    height: 100dvh;
    height: 100svh;
}

.brand-text {
    font-family: 'Georgia', serif;
    font-weight: bold;
    color: var(--accent); /* Updated to Gold */
    font-size: 1rem;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-muted); /* Uses the muted grey variable */
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 4px solid transparent;
    cursor: pointer;
}

    .nav-item:hover {
        background-color: rgba(255,255,255,0.05);
        color: var(--text-main);
    }

    .nav-item.active {
        background-color: rgba(207, 168, 114, 0.15); /* Gold tint matching logo */
        color: var(--accent);
        border-left-color: var(--accent);
    }

.nav-icon {
    font-size: 1.2rem;
    width: 30px;
    text-align: center;
    margin-right: 10px;
}

.border-white-10 {
    border-color: rgba(255,255,255,0.1) !important;
}

.text-gold {
    color: var(--accent);
}

.nav-external {
    border-left: 4px solid transparent;
}

    .nav-external:hover {
        border-left-color: rgba(255, 255, 255, 0.15);
    }

.auth-area {
    position: sticky;
    bottom: 0;
    /* Updated background to match the lighter navy sidebar but with transparency */
    background: rgba(30, 41, 59, 0.85);
    backdrop-filter: blur(6px);
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid rgba(255,255,255,0.05);
}

.game-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    margin: -1.1rem -1.5rem -1.5rem -1.9rem !important;
    width: calc(100% + 3rem) !important;
    min-height: calc(100vh - 3.5rem);
    background-image: linear-gradient(rgba(15, 23, 42, 0.15), rgba(15, 23, 42, 0.15)), url('/images/Greek-Background.webp');
    background-size: cover;
    background-position: center center;
    color: #fff;
}

/* Board Structure */
.board-wrapper {
    display: grid;
    /* 30px for Y-labels, then the board width */
    grid-template-columns: 30px 600px;
    /* The board height, then 30px for X-labels */
    grid-template-rows: 600px 30px;
    margin: 20px auto;
}

.battleground-board {
    display: grid;
    width: 100%;
    height: 100%;
    border: 8px solid var(--greek-accent);
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    background-color: #000;
}
.square {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.04' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.15'/%3E%3C/svg%3E");
    background-blend-mode: multiply;
    box-shadow: inset 0 0 12px rgba(79, 74, 65, 0.15);
    position: relative;
}

    .square.light {
        background-color: var(--greek-tile-light);
    }

    .square.dark {
        background-color: var(--greek-tile-dark);
    }

.unit-token {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-weight: 800;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}
    .unit-token.blessed {
        background-color: #eee;
        color: #111;
        border: 2px solid #fff;
    }

    .unit-token.cursed {
        background-color: #900;
        color: #fff;
        border: 2px solid #500;
    }

/* Right Panel Styles */
.game-info-panel {    
    background-color: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
}

.inspector-area {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: calc(100vh - 100px);
}

.unit-info-container {
    min-height: 420px;
    flex-shrink: 0;
}

.unit-card h2 {
    font-size: 2rem;
    margin-bottom: 2px;
    color: var(--accent); /* Spartan Bronze */
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-left:10px;
}

.unit-type {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 15px;
    font-style: italic;
    padding-left: 10px;
}

.unit-stats {
    background: rgba(0, 0, 0, 0.2); /* Soft dark inset */
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
    box-sizing: border-box;
    width: 100%;
}

.label-x, .label-y {
    font-size: clamp(0.7rem, 1.5vw, 1rem);
    font-weight: bold;
    color: var(--text-muted);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    padding-right: 15px;
    padding-left: 10px;
    border-bottom: none; /* Lines removed */
    font-size: 1.05rem;
    color: var(--text-muted); /* Soften the labels */
}

    .stat-row strong, .stat-row span[title] {
        color: var(--text-main);
    }

.status-flags {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding-left:10px;
}

.event-log {
    display: flex;
    flex-direction: column;
    flex: 1; 
    min-height: 0;
}

@media (max-width: 768px) {
    .unit-info-container {
        min-height: auto;
    }

    .event-log {
        max-height: 300px;
    }
}

.log-scroll-container {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    padding-right: 10px;
}

    .log-scroll-container::-webkit-scrollbar {
        width: 8px;
    }

    .log-scroll-container::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.1);
        border-radius: 4px;
    }

    .log-scroll-container::-webkit-scrollbar-thumb {
        background: #6b7280;
        border-radius: 4px;
    }

        .log-scroll-container::-webkit-scrollbar-thumb:hover {
            background: #4b5563;
        }

.log-attack {
    border-left-color: #ef4444 !important;
    font-weight: 500;
    font-style: italic;
}

.log-move {
    border-left-color: #3b82f6 !important;
}

.log-decline {
    border-left-color: #a855f7 !important;

}

.log-endturn {
    border-left-color: #d2b48c !important;
}

.special-abilities h3, .event-log h3 {
    font-size: 1.1rem;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1); /* Keep one subtle line here for section separation */
    padding-bottom: 6px;
    padding-left:10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.special-abilities p {
    padding-left: 10px;
}

.event-log ul {
    list-style-type: none;
    padding-left: 0;
    margin: 0;
}

.event-log li {
    padding: 8px 12px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid var(--accent); /* Bronze accent line on the left */
    border-radius: 0 4px 4px 0;
    font-size: 0.9rem;
    color: var(--text-main);
}

.badge.badge-red {
    background: rgba(220, 53, 69, 0.15); /* Translucent red */
    color: #ff6b6b;
    border: 1px solid rgba(220, 53, 69, 0.3);
    padding: 4px 12px;
    border-radius: 20px; /* Pill shape */
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.condition-row {
    margin-top: 8px;
}

.action-bar {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 15px;
    flex-shrink: 0;
    z-index: 10;
    margin-top: auto;
}

    .action-bar .btn {
        background: linear-gradient(180deg, #2a3441 0%, #1e2530 100%);
        color: var(--text-main, #e2e8f0);
        border: 1px solid rgba(255, 255, 255, 0.2);
        padding: 12px 30px;
        font-size: 1.1rem;
        font-weight: 700;
        letter-spacing: 1.5px;
        text-transform: uppercase;
        border-radius: 4px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3), inset 0 1px 1px rgba(255,255,255,0.1);
        transition: all 0.2s ease-in-out;
        min-width: 140px; /* Makes them all a uniform size */
    }

        /* 3. Spartan Bronze Hover State */
        .action-bar .btn:not(:disabled):hover {
            background: linear-gradient(180deg, var(--accent) 0%, #8a6a50 100%);
            border-color: var(--accent-hover);
            color: #fff;
            box-shadow: 0 0 15px rgba(174, 138, 112, 0.4), inset 0 1px 1px rgba(255,255,255,0.3);
            transform: translateY(-2px); /* Lifts the button up slightly */
        }

        /* 4. Click/Press State */
        .action-bar .btn:not(:disabled):active {
            transform: translateY(1px);
            box-shadow: 0 2px 3px rgba(0,0,0,0.4);
        }

        /* 5. Clearly faded out Disabled State */
        .action-bar .btn:disabled {
            background: rgba(255, 255, 255, 0.03);
            color: rgba(255, 255, 255, 0.2);
            border-color: rgba(255, 255, 255, 0.05);
            box-shadow: none;
            cursor: not-allowed;
            transform: none;
        }

/* Y-Axis: Numbers 8-1 */
.coords-y {
    display: grid;
    height: 100%;
    align-items: center;
    text-align: right;
    padding-right: 8px;
}

/* X-Axis: Letters a-h */
.coords-x {
    display: grid;
    width: 100%;
    justify-items: center;
    align-items: center;
}

.unit-token.blue {
    background: radial-gradient(circle at 30% 30%, #ffffff 0%, var(--greek-tile-light) 40%, #c4b59d 100%);
    color: var(--greek-piece-dark);
    border: 1px solid #8c7e6a;
    box-shadow: inset 0 4px 4px rgba(255, 255, 255, 0.8), inset 0 -4px 6px rgba(0, 0, 0, 0.2), 0 4px 0 #9e8f79, 0 6px 8px rgba(0, 0, 0, 0.5);
}

.unit-token.red {
    background: radial-gradient(circle at 30% 30%, #6e5544 0%, var(--greek-piece-dark) 50%, #2a1c13 100%);
    color: var(--greek-tile-light);
    border: 1px solid #2a1c13;
    box-shadow: inset 0 4px 4px rgba(255, 255, 255, 0.15), inset 0 -4px 6px rgba(0, 0, 0, 0.6), 0 4px 0 #120b07, 0 6px 8px rgba(0, 0, 0, 0.7);
}

.unit-icon {
    text-shadow: 1px 1px 1px rgba(255, 255, 255, 0.2), -1px -1px 1px rgba(0, 0, 0, 0.5);
    letter-spacing: 1px;
}

.unit-token:hover:not(.exhausted) {
    transform: translateY(-2px);
}

.unit-token.selected {
    transform: translateY(2px);
    border-color: var(--accent);    
    box-shadow: inset 0 4px 4px rgba(255, 255, 255, 0.3), inset 0 -4px 6px rgba(0, 0, 0, 0.4), 0 1px 0 #120b07, 0 0 15px 4px var(--accent) !important;
}

.square.valid-attack,
.square.valid-attack .unit-token {
    cursor: crosshair !important;
}

.square.selected-square {
    box-shadow: inset 0 0 0 3px var(--gold);
    background-color: rgba(197, 155, 109, 0.3); /* Gold tint */
}

.square.valid-move {
    box-shadow: inset 0 0 0 3px #4a90e2;
    background-color: rgba(74, 144, 226, 0.3); /* Blue tint */
    cursor: pointer;
}

    .square.valid-move:hover {
        background-color: rgba(74, 144, 226, 0.5);
    }

.game-board-container {
    background: transparent !important;
    box-shadow: none !important;
    display: flex;
    flex-direction: column;
    /* Lock height to the window height minus top nav */
    height: calc(100vh - 3.5rem);
    overflow: hidden;
    position: relative;
}

.turn-banner {
    width: 100%;
    padding: 1rem 2rem;
    margin-bottom: 1.5rem;
    background: rgba(15, 23, 42, 0.25);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    border: none;
    border-radius: 0;
    transition: all 0.3s ease;
}

    .turn-banner.my-turn {
        border-bottom: 2px solid var(--accent);
        box-shadow: 0 4px 15px rgba(174, 138, 112, 0.15); 
        animation: none;
    }

        .turn-banner.my-turn h2 {
            color: var(--accent);
        }

    .turn-banner.opponent-turn {
        border-bottom: 2px solid #334155;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); 
    }

        .turn-banner.opponent-turn h2 {
            color: #adb5bd;
        }

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 5px rgba(197,155,109,0.1);
    }

    50% {
        box-shadow: 0 0 20px rgba(197,155,109,0.4);
    }

    100% {
        box-shadow: 0 0 5px rgba(197,155,109,0.1);
    }
}

/* --- Toast Notification --- */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    pointer-events: none;
}

.toast-custom {
    background-color: #dc3545; /* Bootstrap danger red */
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    border: 1px solid #ff6b6b;
    font-weight: bold;
    animation: fadein 0.3s, fadeout 0.5s 2.5s forwards;
    pointer-events: auto;
}

@keyframes fadein {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeout {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        visibility: hidden;
    }
}

.square.valid-attack {
    box-shadow: inset 0 0 0 3px #dc3545;
    background-color: rgba(220, 53, 69, 0.3); /* Red tint */
    cursor: crosshair;
}

    .square.valid-attack:hover {
        background-color: rgba(220, 53, 69, 0.5);
    }

.hp-pips-vertical {
    position: absolute;
    right: 4px;
    top: 10%;
    bottom: 10%;
    width: 8px;
    display: flex;
    flex-direction: column-reverse;    
    border: 1px solid #111;
    border-radius: 2px;
    background-color: rgba(20, 20, 20, 0.7);
    overflow: hidden;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.6);
    pointer-events: none;
}

.hp-pip {
    width: 100%;
    flex-grow: 1;
    border-top: 1px solid rgba(0, 0, 0, 0.5);
    transition: background-color 0.3s ease;
}
    .hp-pip:last-child {
        border-top: none;
    }

    .hp-pip.empty {        
        background-color: transparent !important;        
        box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
    }

@keyframes pip-shatter {
    0% {
        background-color: white !important;
        transform: scale(1.5);
        box-shadow: 0 0 8px white;
        border-color: white;
    }

    50% {
        transform: scale(0.8);
    }

    100% {
        background-color: rgba(20, 20, 20, 0.6) !important;
        transform: scale(1);
    }
}

.floating-damage {
    position: absolute;
    top: -15px; 
    color: #ff4444;
    font-size: 1.5rem;
    font-weight: 900;
    pointer-events: none;
    z-index: 100;    
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 0px 4px 4px rgba(0,0,0,0.8);    
    animation: float-up 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes float-up {
    0% {
        opacity: 1;
        transform: translateY(0) scale(0.5);
    }

    20% {
        transform: translateY(-15px) scale(1.2);
    }

    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1);
    }
}

.unit-token.exhausted {
    border: 2px solid #fbbf24 !important; /* Bright Yellow */
    box-shadow: 0 0 8px 2px rgba(251, 191, 36, 0.6), /* Outer yellow glow */
    inset 0 0 10px rgba(251, 191, 36, 0.4) !important; /* Inner yellow tint */
    opacity: 0.85; /* Fades the unit slightly */
    filter: sepia(0.4) hue-rotate(-15deg); /* Gives the whole token a slight golden/warm wash */
}

.unit-token.exhausted.selected {
    border-color: #4ade80 !important; /* Or whatever your selection color is */
    box-shadow: 0 0 10px 3px #4ade80 !important;
    opacity: 1;
    filter: none;
}

.zzz-indicator {
    position: absolute;
    top: -10px;
    right: 5px;
    color: #fbbf24; /* Yellow to match the exhausted border */
    font-weight: 900;
    font-size: 1.1rem;
    letter-spacing: 1px;
    pointer-events: none; /* Prevents it from blocking clicks on the unit */
    z-index: 50;
    /* Thick black outline */
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 0px 2px 4px rgba(0,0,0,0.8);
    /* 2.5 second continuous loop */
    animation: float-sleep 2.5s infinite linear;
}

@keyframes float-sleep {
    0% {
        opacity: 0;
        transform: translate(0, 0) scale(0.6) rotate(-10deg);
    }

    20% {
        opacity: 1;
        transform: translate(4px, -10px) scale(0.9) rotate(5deg);
    }

    80% {
        opacity: 1;
        transform: translate(12px, -25px) scale(1.1) rotate(-5deg);
    }

    100% {
        opacity: 0;
        transform: translate(16px, -35px) scale(1.2) rotate(10deg);
    }
}

.unit-token.power-level-2 {
    box-shadow: 0 0 12px 3px rgba(192, 132, 252, 0.7), inset 0 0 8px rgba(192, 132, 252, 0.5) !important;
    animation: magic-pulse-heavy 2s infinite alternate ease-in-out;
}

.unit-token.power-level-1 {
    box-shadow: 0 0 5px 1px rgba(192, 132, 252, 0.4) !important;
    animation: magic-pulse-flicker 3s infinite alternate;
}

.bonded-aura {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

.power-orb {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #e9d5ff;
    box-shadow: 0 0 8px 3px #c084fc;
}

    .power-orb.orb-0 {
        top: -4px;
        left: -4px;
        animation: float-orb-1 3s infinite alternate ease-in-out;
    }

    .power-orb.orb-1 {
        bottom: -4px;
        right: -4px;
        animation: float-orb-2 3s infinite alternate ease-in-out reverse;
    }

@keyframes magic-pulse-heavy {
    0% {
        filter: brightness(1);
    }

    100% {
        filter: brightness(1.3) drop-shadow(0 0 5px #c084fc);
    }
}

@keyframes magic-pulse-flicker {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }

    80% {
        opacity: 0.9;
    }
}

@keyframes float-orb-1 {
    0% {
        transform: translate(0, 0) scale(0.8);
    }

    100% {
        transform: translate(-3px, -3px) scale(1.2);
    }
}

@keyframes float-orb-2 {
    0% {
        transform: translate(0, 0) scale(0.8);
    }

    100% {
        transform: translate(3px, 3px) scale(1.2);
    }
}

/* Base Tile Styling with Inline SVG Texture */
.chess-board .tile {
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.04' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.15'/%3E%3C/svg%3E");
    background-blend-mode: multiply;
    box-shadow: inset 0 0 12px rgba(79, 74, 65, 0.15);
}

    .chess-board .tile.light {
        background-color: var(--greek-tile-light, #F3EFE8);
    }

    .chess-board .tile.dark {
        background-color: var(--greek-tile-dark, #E5D3B3);
    }

.log-turn {
    color: var(--accent); /* Gold/Bronze */
    font-weight: 700;
}

.log-coord {
    color: #e2e8f0; /* Bright white/grey */
    font-weight: 700;
    background: rgba(255,255,255,0.1);
    padding: 0 4px;
    border-radius: 3px;
}

.log-dmg {
    color: #ef4444; /* Red */
    font-weight: 800;
    font-size: 1.1em;
}

.log-roll {
    color: #fbbf24; /* Yellow/Gold */
    font-weight: 600;
}

.log-destroyed {
    color: #ef4444;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.log-noreaction {
    color: #a855f7; /* Purple */
    font-style: italic;
    opacity: 0.8;
}

.bonded-aura {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 2;
}

.orb-container {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    animation: orbit-spin 8s linear infinite;
}

.power-orb {
    position: absolute;
    top: -5px;
    left: 20px;
    width: 10px;
    height: 10px;
    border-radius: 50%;    
    background: radial-gradient(circle at 30% 30%, #ffffff, #00ffff);
    box-shadow: 0 0 6px #00ffff, 0 0 12px #00ffff;    
    animation: counter-spin 8s linear infinite;
}

@keyframes orbit-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes counter-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(-360deg);
    }
}

/* Container for the physical effect is now centered */
.vfx-physical {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* 1. The Swinging Arm (Spins Forward) */
.swing-arm {
    position: absolute;
    width: 0;
    height: 0;
    /* This invisible arm spins 120 degrees over the target */
    animation: cleave-swing 1.5s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
}

/* 2. The Sword (Spins Backward to stay oriented, but slightly rotated) */
.swinging-sword {
    position: absolute;
    left: 25px; /* Radius of the swing */
    top: -20px; /* Pulls it up to center on the arm */
    /* Draw the physical blade */
    width: 6px;
    height: 45px;
    background: #ffffff;
    /* Curves the top corners to create a sharp blade tip, leaves bottom flat */
    border-radius: 50% 50% 2px 2px;
    /* Adds the glowing red edge */
    box-shadow: 0 0 5px #ffffff, 0 0 10px #ff0000, 0 0 20px #ff0000;
    /* The Ferris wheel counter-spin */
    animation: sword-ferris 1.5s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
}

.simple-sword {
    position: absolute;
    top: -10px;
    width: 6px;
    height: 45px;
    background: #ffffff;
    border-radius: 50% 50% 2px 2px;
    /* Changed from red to a sharp neon blue/cyan */
    box-shadow: 0 0 5px #ffffff, 0 0 10px #00d0ff, 0 0 20px #00d0ff;
    /* Pins the base of the sword so it chops overhead */
    transform-origin: bottom center;
    /* Timed exactly with the 1000ms Task.Delay in C# */
    animation: overhead-chop 1s ease-in-out forwards;
}

@keyframes overhead-chop {
    0% {
        transform: rotate(-50deg);
        opacity: 0;
    }

    15% {
        opacity: 1;
    }

    85% {
        opacity: 1;
    }

    100% {
        transform: rotate(50deg);
        opacity: 0;
    }
}

/* This is the keyframes for the invisible swing-arm */
@keyframes cleave-swing {
    0% {
        transform: rotate(-60deg);
        opacity: 1;
    }
    /* Wide cleave action */
    60% {
        transform: rotate(60deg);
        opacity: 1;
    }
    /* Slower follow-through that fades out */
    100% {
        transform: rotate(70deg);
        opacity: 0;
    }
}

/* Keyframes for the sword itself (The "Ferris Wheel" counter-spin) */
@keyframes sword-ferris {
    /* Notice the values are the opposite of 'cleave-swing', but starting
       at 120deg. This is what gives the sword that specific leading angle! */
    0% {
        transform: rotate(180deg);
    }

    100% {
        transform: rotate(50deg);
    }
}

.attack-vfx {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none; /* Lets clicks pass through the animation */
    z-index: 100; /* Makes sure the effect draws OVER the unit tokens */
    display: flex;
    align-items: center;
    justify-content: center;
}

.vfx-magic {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.9) 0%, rgba(139, 92, 246, 0) 70%);
    box-shadow: inset 0 0 20px #8b5cf6;
    animation: magic-burst 1.5s ease-out forwards;
}

@keyframes magic-burst {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
        filter: hue-rotate(0deg);
    }

    50% {
        transform: scale(1.2) rotate(180deg);
        opacity: 0.8;
    }

    100% {
        transform: scale(1.8) rotate(360deg);
        opacity: 0;
        filter: hue-rotate(90deg);
    }
}

#dice-box {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    pointer-events: none !important; /* Lets you click the board behind the dice! */
    background: transparent !important;
}

    #dice-box canvas {
        pointer-events: none !important;
    }

/* @brief   3d dice roller app stylesheet
   @author  Sarah Rosanna Busch
   @date    10 Aug 2023
   @version 0.1
   */

* {
    box-sizing: border-box; /* padding and border are included in total width/height of all elements */
    margin: 0px;
    font-size: 14pt;
    font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}

body {
    margin: 0;
    overflow-x: hidden;
    background-repeat: no-repeat;
    background-position: right bottom;
    background-size: cover;
    height: 100vh;
    width: 100vw;
}

header {
    text-align: center;
    color: white;
    padding: 5px;
}

#helpBtn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 1.2rem;
    height: 1.2rem;
    border: none;
    border-radius: 0.6rem;
}

/* ******* DICE ROLLER *********** */

#diceRoller {
    position: absolute;
    top: 0;
    height: calc(100% - 4.5rem);
    width: 100%;
    margin-top: 1.5rem;
    z-index: -1;
    overflow: hidden;
}

#canvas {
    width: 100%;
    height: 100%;
}

/* ************* UI ************* */

#diceRollerUI {
    width: 100vw;
    height: 100vh;
    margin: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#diceLimit {
    text-align: center;
    color: red;
    background-color: #050505;
    padding: 0.5rem;
    font-size: 10pt;
    font-weight: bold;
}

.top_field {
    text-align: center;
    width: 100%;
    background-color: rgba(150,150,150,0.1);
}

#textInput {
    text-align: center;
    border: none;
    color: rgba(0, 0, 0, 0.8);
    background-color: rgba(199, 199, 199, 0.7);
    width: 100%;
    text-overflow: ellipsis;
    padding: 0.2em;
    text-decoration: none;
}

    #textInput:focus {
        background-color: rgba(255, 255, 255, 0.7);
        outline: none;
    }

.center_field {
    position: relative;
    flex: 1;
    text-align: center;
    height: 80%;
    width: 100%;
    z-index: 100;
}

    .center_field * {
        position: relative;
        background-color: rgba(255, 255, 255, 0.6);
        padding: 5px 15px;
        user-select: none;
    }

#instructions {
    background: none;
    height: 100%;
    width: 100%;
}

    #instructions p {
        color: rgb(255, 255, 255);
        background: none;
        margin: auto;
        top: 35%;
        padding: 1em;
    }

#numPad { /* container */
    position: absolute;
    width: 200px;
    height: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.numPad { /* table */
    width: 200px;
    margin: auto;
    padding-top: 15px;
    padding-bottom: 15px;
}

    .numPad td {
        cursor: pointer;
    }

#numPad button {
    padding: 0.5em;
    margin-top: 5px;
    width: 97px;
    border: none;
    background-color: rgba(255, 255, 255, 0.8);
    color: black;
}

.bottom_field {
    position: absolute;
    bottom: 0;
    text-align: center;
    min-height: 3rem;
    background: rgba(0, 0, 0, 0.4);
    width: inherit;
    padding: 0px;
}

#result {
    position: relative;
    display: block;
    min-height: 1.5em;
    bottom: 5px;
    word-spacing: 0.5em;
    color: rgba(255,255,255,0.9);
    padding: 0.5em;
    margin-left: 5px;
    margin-right: 5px;
}

.last-move-highlight {
    background-color: rgba(234, 179, 8, 0.4) !important;
    box-shadow: inset 0 0 0 999px rgba(59, 130, 246, 0.3) !important;
}

    .last-move-highlight::after {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        /* A soft, glowing gold radial gradient with low opacity */
        background: radial-gradient(circle, rgba(234, 179, 8, 0.25) 0%, rgba(234, 179, 8, 0.05) 100%);
        /* Makes the edges softer and adds to the ghostly effect */
        box-shadow: 0 0 10px rgba(234, 179, 8, 0.3);
        /* Ensures the text and pieces still render on top */
        z-index: -1;
    }

.unit-icon-img {
    max-width: 105%; 
    max-height: 105%;
    object-fit: contain;
    pointer-events: none;
    display: block;
    margin: auto;
    filter: drop-shadow(0px 0px 2px rgba(0,0,0,1)) drop-shadow(0px 6px 8px rgba(0,0,0,0.6));
}

.unit-token:has(.unit-icon-img) {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

    .unit-token:has(.unit-icon-img) .hp-pips-vertical {
        right: 0px;
        top: 10%;
    }

.inspector-portrait {
    text-align: center;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

    .inspector-portrait img {
        max-width: 140px;
        max-height: 140px;
        object-fit: contain;
        filter: drop-shadow(0px 8px 12px rgba(0,0,0,0.6)); /* Makes the art pop */
    }

.game-board-container {
    height: calc(100vh - 3.5rem) !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

.board-wrapper {
    /* 1. Calculate an unbreakable square using vh (viewport height) */
    width: min(100%, 65vh) !important;
    height: min(100%, 65vh) !important;
    margin: auto !important;
    display: grid !important;
    grid-template-columns: 30px 1fr !important;
    grid-template-rows: 1fr 30px !important;
    /* 2. Fix the CSS Grid bug: Prevent it from auto-expanding */
    min-width: 0 !important;
    min-height: 0 !important;
}

.battleground-board {
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
}

.square {
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
}

.unit-token {
    /* 3. Force perfect circles, scaled down to 75% so they fit inside perfectly */
    width: 75% !important;
    height: auto !important;
    aspect-ratio: 1 / 1 !important;
    margin: auto !important;
    font-size: clamp(0.5rem, 1.5vh, 1.2rem) !important;
}

.action-bar {
    /* 4. Anchor firmly to the bottom */
    margin-top: auto !important;
    flex-shrink: 0 !important;
    position: relative !important;
    z-index: 100 !important;
}