/* BANG! The Dice Game - Client Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Georgia', serif;
    /* Western-y backdrop (no external assets) */
    color: #f4e4c1;
    background-image: url("/assets/image.png");
    background-repeat: no-repeat;
    background-size: cover;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.token {
    width: 18px;
    height: 18px;
    display: inline-block;
    vertical-align: -3px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.55));
}

.token-bullets {
    background-image: url("/assets/tokens/bullets.png"), url("/assets/tokens/bullets.svg");
}

.token-arrow {
    background-image: url("/assets/tokens/arrow.png"), url("/assets/tokens/arrow.svg");
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* ===== LOBBY SCREEN ===== */

.lobby-container {
    background: rgba(20, 10, 5, 0.9);
    border: 3px solid #8b6f47;
    border-radius: 15px;
    padding: 40px;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.lobby-container h1 {
    text-align: center;
    font-size: 2.5em;
    margin-bottom: 30px;
    color: #d4a574;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
}

.lobby-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.lobby-form input {
    padding: 12px;
    font-size: 1.1em;
    border: 2px solid #8b6f47;
    border-radius: 5px;
    background: #2c1810;
    color: #f4e4c1;
}

.lobby-form input::placeholder {
    color: #8b6f47;
}

.button-group {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 12px 24px;
    font-size: 1.1em;
    font-weight: bold;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    flex: 1;
}

.btn-primary {
    background: #d4a574;
    color: #2c1810;
}

.btn-primary:hover {
    background: #e6b885;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(212, 165, 116, 0.4);
}

.btn-secondary {
    background: #8b6f47;
    color: #f4e4c1;
}

.btn-secondary:hover {
    background: #a0855b;
    transform: translateY(-2px);
}

.btn-success {
    background: #5a8b47;
    color: #f4e4c1;
}

.btn-success:hover {
    background: #6aa055;
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.hidden {
    display: none !important;
}

.info-box {
    margin-top: 20px;
    padding: 15px;
    background: rgba(90, 58, 42, 0.5);
    border: 1px solid #8b6f47;
    border-radius: 5px;
}

.info-box p {
    margin: 5px 0;
}

.room-id-hint {
    font-size: 0.9em;
    color: #8b6f47;
    font-style: italic;
}

#player-list {
    margin: 10px 0;
}

.lobby-player {
    padding: 8px;
    margin: 5px 0;
    background: rgba(20, 10, 5, 0.5);
    border: 1px solid #8b6f47;
    border-radius: 3px;
}

.error-box {
    margin-top: 15px;
    padding: 12px;
    background: rgba(139, 47, 47, 0.3);
    border: 1px solid #8b2f2f;
    border-radius: 5px;
    color: #ff6b6b;
}

/* ===== GAME SCREEN ===== */

.game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    /* Subtle vignette + cloth feel */
    background:
        radial-gradient(900px 600px at 50% 35%, rgba(0,0,0,0.35), transparent 70%),
        radial-gradient(1000px 800px at 50% 120%, rgba(0,0,0,0.55), transparent 60%),
        linear-gradient(180deg, rgba(64, 36, 22, 0.85), rgba(30, 16, 10, 0.92));
}

/* Game Info Bar */
.game-info-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(20, 10, 5, 0.9);
    border-bottom: 2px solid #8b6f47;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
}

.info-section {
    font-size: 1.1em;
}

.info-label {
    color: #8b6f47;
    margin-right: 8px;
}

#arrow-pool {
    position: relative;
    padding-left: 22px;
}

#arrow-pool::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    background-image: url("/assets/tokens/arrow.png"), url("/assets/tokens/arrow.svg");
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.55));
}

/* Player Table (fixed seats around a "poker table") */
.player-table {
    position: absolute;
    top: 80px;
    left: 0;
    right: 0;
    bottom: 240px; /* keep clear of dice area */
    padding: 14px 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-content: flex-start;
    align-items: flex-start;
    overflow: auto;
    pointer-events: auto;
}

.player-card {
    width: 320px;
    height: 160px;
    padding: 12px 12px 10px;
    background:
        linear-gradient(180deg, rgba(244, 232, 204, 0.78), rgba(206, 160, 104, 0.90) 30%, rgba(150, 94, 46, 0.92)),
        radial-gradient(520px 260px at 50% 10%, rgba(255,255,255,0.14), transparent 60%);
    border: 2px solid rgba(110, 72, 34, 0.85);
    border-radius: 14px;
    text-align: left;
    transition: transform 0.18s ease-out, box-shadow 0.18s ease-out, border-color 0.18s ease-out;
    box-shadow: 0 10px 22px rgba(0,0,0,0.28);
    overflow: hidden;
    pointer-events: auto;
    position: relative;
    color: #2c1810;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.player-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(255, 255, 255, 0.14) 0px,
            rgba(255, 255, 255, 0.14) 2px,
            rgba(0, 0, 0, 0) 6px,
            rgba(0, 0, 0, 0) 10px
        );
    opacity: 0.35;
    pointer-events: none;
    mix-blend-mode: soft-light;
}

.player-card.current-turn {
    border-color: #ffd700;
    box-shadow:
        0 0 0 2px rgba(255, 215, 0, 0.95),
        0 0 25px rgba(255, 215, 0, 0.65);
    animation: pulse-glow 2s ease-in-out infinite;
    background:
        linear-gradient(180deg, rgba(255, 215, 0, 0.18), rgba(0,0,0,0) 45%),
        linear-gradient(180deg, rgba(244, 232, 204, 0.78), rgba(206, 160, 104, 0.90) 30%, rgba(150, 94, 46, 0.92));
    z-index: 10;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
    }
    50% {
        box-shadow: 0 0 30px rgba(255, 215, 0, 1);
    }
}

.player-card.eliminated {
    opacity: 0.5;
    border-color: #5a3a2a;
}

.player-card.self:not(.current-turn) {
    border-color: #5a8b47;
}

.player-card.self.current-turn {
    border-color: #ffd700;
}

.player-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.player-name {
    font-size: 1.2em;
    font-weight: bold;
    margin: 0;
    color: #3b1f10;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-role {
    font-size: 0.95em;
    color: rgba(44, 24, 16, 0.75);
    margin: 0;
    white-space: nowrap;
}

.player-character {
    font-size: 1em;
    margin: 0;
    color: #2c1810;
    opacity: 0.9;
}

.player-ability {
    font-size: 0.95em;
    font-style: italic;
    color: rgba(44, 24, 16, 0.82);
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(82, 46, 20, 0.18);
    background: rgba(250, 238, 214, 0.22);
    line-height: 1.25;
    text-align: left;
    flex: 1;
    min-height: 0;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
}

.player-stats {
    display: flex;
    justify-content: flex-start;
    gap: 18px;
    padding: 0;
    margin-top: auto;
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.25em;
}

.stat-icon {
    font-size: 1.2em;
}

.player-stats .token {
    width: 22px;
    height: 22px;
}

/* Dice Area */
.dice-area {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 700px;
    padding: 20px;
    background:
        radial-gradient(700px 240px at 50% 0%, rgba(212,165,116,0.10), transparent 65%),
        linear-gradient(135deg, rgba(20, 10, 5, 0.92), rgba(35, 18, 10, 0.92));
    border: 3px solid #8b6f47;
    border-radius: 15px;
}

.dice-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    min-height: 80px;
}

.die {
    width: 70px;
    height: 70px;
    background: #f4e4c1;
    border: 2px solid #8b6f47;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2em;
    cursor: pointer;
    transition: all 0.3s;
    user-select: none;
    position: relative;
}

.die::after { content: none; }

.die-face {
    width: 46px;
    height: 46px;
    display: block;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.25));
}

.die:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.die.locked {
    background: #d4a574;
    border-color: #5a8b47;
    box-shadow: 0 0 0 3px rgba(90, 139, 71, 0.35), 0 8px 18px rgba(0,0,0,0.35);
}

.die.locked::after {
    content: '';
    position: absolute;
    top: -7px;
    right: -7px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #5a8b47;
    border: 2px solid rgba(20, 10, 5, 0.9);
    box-shadow: 0 6px 12px rgba(0,0,0,0.35);
}

.die.locked::before {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border: 2px solid #f4e4c1;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    transform: translate(-4px, 2px);
    opacity: 0.95;
}

.die.dynamite {
    background: #ff6b6b;
    border-color: #8b2f2f;
    cursor: not-allowed;
}

.die:not(.locked) {
    box-shadow: 0 2px 0 rgba(0,0,0,0.22);
}

/* Dice faces (SVG, no external assets) */
.die-arrow .die-face {  rotate: 45deg; background-image: url("/assets/dice/arrow.png"), url("/assets/dice/arrow.svg"); }
.die-dynamite .die-face { background-image: url("/assets/dice/dynamite.png"), url("/assets/dice/dynamite.svg"); }
.die-bullseye1 .die-face { background-image: url("/assets/dice/bullseye1.png"), url("/assets/dice/bullseye1.svg"); }
.die-bullseye2 .die-face { background-image: url("/assets/dice/bullseye2.png"), url("/assets/dice/bullseye2.svg"); }
.die-beer .die-face { background-image: url("/assets/dice/beer.png"), url("/assets/dice/beer.svg"); }
.die-gatling .die-face { background-image: url("/assets/dice/gatling.png"), url("/assets/dice/gatling.svg"); }

.die-roll {
    animation: die-roll 220ms ease-out;
}

@keyframes die-roll {
    0% { transform: translateY(0) rotate(0deg); }
    35% { transform: translateY(-3px) rotate(-6deg); }
    70% { transform: translateY(1px) rotate(4deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
    .die-roll { animation: none; }
}

.dice-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
}

.dice-hint {
    font-size: 0.9em;
    color: #8b6f47;
    font-style: italic;
}

/* Target Selection Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: rgba(20, 10, 5, 0.95);
    border: 3px solid #8b6f47;
    border-radius: 15px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #d4a574;
    text-align: center;
}

#target-selection {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.target-option {
    padding: 12px;
    background: rgba(90, 58, 42, 0.5);
    border: 2px solid #8b6f47;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.target-option:hover {
    background: rgba(90, 58, 42, 0.8);
    border-color: #d4a574;
}

.target-option.selected {
    background: rgba(90, 139, 71, 0.5);
    border-color: #5a8b47;
}

/* Player positioning no longer needed - using flexbox */

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    padding: 15px 20px;
    background: rgba(139, 69, 19, 0.95);
    border: 2px solid #d4a574;
    border-radius: 8px;
    color: #f4e4c1;
    font-family: 'Courier New', monospace;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease-out;
    min-width: 250px;
}

.toast.error {
    background: rgba(139, 0, 0, 0.95);
    border-color: #ff6b6b;
}

.toast.success {
    background: rgba(0, 100, 0, 0.95);
    border-color: #90ee90;
}

.toast.info {
    background: rgba(30, 60, 114, 0.95);
    border-color: #6fa8dc;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast.removing {
    animation: slideOut 0.3s ease-in forwards;
}
