:root {
    --md-sys-color-primary: #006A6A;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-surface: #FBFDFD;
    --md-sys-color-on-surface: #191C1C;
    --md-sys-color-surface-container: #ECEEED;
    --md-sys-elevation-2: 0px 4px 8px rgba(0,0,0,0.1);
    
    --prop-brown: #8B4513;
    --prop-lightblue: #87CEEB;
    --prop-pink: #FF69B4;
    --prop-orange: #FFA500;
    --prop-red: #FF0000;
    --prop-yellow: #FFFF00;
    --prop-green: #008000;
    --prop-darkblue: #00008B;
    --prop-station: #333333;
    --prop-utility: #666666;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Roboto', sans-serif;
    background-color: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface);
    height: 100vh;
    overflow: hidden;
}

#login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.login-card {
    background: var(--md-sys-color-surface);
    padding: 3rem;
    border-radius: 24px;
    box-shadow: var(--md-sys-elevation-2);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 350px;
}

.login-card input {
    padding: 12px 16px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 16px;
}

.btn-primary { 
    background: var(--md-sys-color-primary); 
    color: white; 
    border: none; 
    padding: 12px 24px; 
    border-radius: 12px; 
    cursor: pointer; 
    font-size: 16px;
    font-weight: 500;
    transition: background-color 0.2s;
}
.btn-primary:hover { background: #005555; }
.btn-danger { 
    background: #d32f2f; 
    color: white; 
    border: none; 
    padding: 12px 24px; 
    border-radius: 12px; 
    cursor: pointer; 
    font-size: 16px; 
}

#game-container {
    display: flex;
    width: 100vw;
    height: 100vh;
}

.sidebar {
    width: 300px;
    background: var(--md-sys-color-surface);
    box-shadow: var(--md-sys-elevation-2);
    display: flex;
    flex-direction: column;
    padding: 20px;
    z-index: 10;
}

.main-board {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    background: #e6f2eb;
}

/* Board sizing */
.board {
    width: min(calc(100vh - 40px), calc(100vw - 640px));
    height: min(calc(100vh - 40px), calc(100vw - 640px));
    min-width: 600px;
    min-height: 600px;
    background: #cbf0db;
    border: 2px solid #333;
    display: grid;
    grid-template-columns: 2fr repeat(9, 1fr) 2fr;
    grid-template-rows: 2fr repeat(9, 1fr) 2fr;
    position: relative;
}

.center-area {
    grid-column: 2 / 11;
    grid-row: 2 / 11;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(255,255,255,0.7);
    border: 2px solid #333;
}

.space {
    border: 1px solid rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 11px;
    background: #fff;
    position: relative;
    padding: 2px;
}

/* Specific rotation based on side (to mimic board edge viewing) */
.space.bottom .prop-color { height: 25%; width: 100%; position: absolute; top: 0; border-bottom: 1px solid #333;}
.space.bottom { justify-content: flex-end; padding-bottom: 5px; }

.space.left .prop-color { width: 25%; height: 100%; position: absolute; right: 0; border-left: 1px solid #333;}
.space.left { flex-direction: row; justify-content: flex-start; padding-left: 5px; }
.space.left .content { display: flex; flex-direction: column; align-items: center;}

.space.top .prop-color { height: 25%; width: 100%; position: absolute; bottom: 0; border-top: 1px solid #333;}
.space.top { justify-content: flex-start; padding-top: 5px; }
.space.top .content { display: flex; flex-direction: column; align-items: center;}

.space.right .prop-color { width: 25%; height: 100%; position: absolute; left: 0; border-right: 1px solid #333;}
.space.right { flex-direction: row; justify-content: flex-end; padding-right: 5px; }
.space.right .content { display: flex; flex-direction: column; align-items: center;}

.space .name { font-weight: bold; margin-bottom: 2px; line-height: 1.1; }
.space .price { font-size: 10px; }

.bg-brown { background: var(--prop-brown); }
.bg-lightblue { background: var(--prop-lightblue); }
.bg-pink { background: var(--prop-pink); }
.bg-orange { background: var(--prop-orange); }
.bg-red { background: var(--prop-red); }
.bg-yellow { background: var(--prop-yellow); }
.bg-green { background: var(--prop-green); }
.bg-darkblue { background: var(--prop-darkblue); }
.bg-station { background: var(--prop-station); }
.bg-utility { background: var(--prop-utility); }

.logs-container, .chat-container {
    flex-grow: 1;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    overflow-y: auto;
    margin-bottom: 10px;
    background: #fafafa;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.chat-input-area {
    display: flex;
    gap: 10px;
}
.chat-input-area input {
    flex-grow: 1;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 8px;
}

.player-card {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    margin-bottom: 10px;
    background: white;
}
.player-card.active {
    border: 2px solid var(--md-sys-color-primary);
    box-shadow: var(--md-sys-elevation-2);
}

.player-piece {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    position: absolute;
    z-index: 50;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    pointer-events: none;
    opacity: 0.85;
    mix-blend-mode: multiply;
}

.jumping {
    animation: jump 0.3s ease-in-out;
}
@keyframes jump {
    0% { transform: scale(1) translateY(0); }
    50% { transform: scale(1.2) translateY(-15px); }
    100% { transform: scale(1) translateY(0); }
}

.modal {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: white; padding: 20px; border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5); z-index: 9999;
    display: none; flex-direction: column; gap: 10px; width: 300px;
    text-align: center;
}
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 9998; display: none;
}

.error { color: #d32f2f; font-size: 14px; }

/* Admin Reset Button on Login Page */
.btn-admin-reset {
    background: transparent;
    color: #888;
    border: 1px dashed #ccc;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}
.btn-admin-reset:hover {
    color: #d32f2f;
    border-color: #d32f2f;
    background: rgba(211,47,47,0.05);
}

/* Event Popup System */
#event-popup-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 60px;
    gap: 12px;
}

.event-popup {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: 20px 28px;
    min-width: 320px;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 16px;
    animation: eventPopupIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.event-popup:hover {
    transform: scale(1.02);
    box-shadow: 0 10px 40px rgba(0,0,0,0.2), 0 3px 10px rgba(0,0,0,0.12);
}
.event-popup.dismissing {
    animation: eventPopupOut 0.35s ease-in forwards;
}

.event-popup-icon {
    font-size: 36px;
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: rgba(0,106,106,0.1);
}
.event-popup-icon.rent-pay { background: rgba(211,47,47,0.1); }
.event-popup-icon.rent-receive { background: rgba(46,204,113,0.1); }
.event-popup-icon.jail { background: rgba(211,47,47,0.1); }
.event-popup-icon.tax { background: rgba(255,165,0,0.1); }
.event-popup-icon.go { background: rgba(46,204,113,0.1); }
.event-popup-icon.chance { background: rgba(155,89,182,0.1); }
.event-popup-icon.chest { background: rgba(52,152,219,0.1); }
.event-popup-icon.buy { background: rgba(0,106,106,0.1); }
.event-popup-icon.build { background: rgba(241,196,15,0.1); }
.event-popup-icon.mortgage { background: rgba(149,165,166,0.1); }
.event-popup-icon.reset { background: rgba(211,47,47,0.1); }

.event-popup-body {
    flex: 1;
    min-width: 0;
}
.event-popup-title {
    font-weight: 700;
    font-size: 15px;
    color: #191C1C;
    margin-bottom: 3px;
}
.event-popup-detail {
    font-size: 13px;
    color: #555;
    line-height: 1.4;
}
.event-popup-timer {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--md-sys-color-primary);
    border-radius: 0 0 20px 20px;
    animation: popupTimer linear forwards;
}

@keyframes eventPopupIn {
    0% { opacity: 0; transform: translateY(-30px) scale(0.9); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes eventPopupOut {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-20px) scale(0.9); }
}
@keyframes popupTimer {
    0% { width: 100%; }
    100% { width: 0%; }
}

/* ========== Large Centered Game Event Modal ========== */
.game-modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.45);
    z-index: 11000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    animation: gameModalOverlayIn 0.3s ease forwards;
}
.game-modal-overlay.game-modal-dismissing {
    animation: gameModalOverlayOut 0.4s ease forwards;
}

.game-modal {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 28px;
    padding: 36px 48px;
    min-width: 360px;
    max-width: 480px;
    text-align: center;
    box-shadow: 0 16px 64px rgba(0,0,0,0.25), 0 4px 16px rgba(0,0,0,0.1);
    animation: gameModalCardIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.5);
}
.game-modal-dismissing .game-modal {
    animation: gameModalCardOut 0.35s ease-in forwards;
}

.game-modal-icon {
    font-size: 64px;
    margin-bottom: 12px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
    animation: gameModalBounce 0.6s ease 0.2s;
}
.game-modal-title {
    font-size: 24px;
    font-weight: 800;
    color: #191C1C;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}
.game-modal-detail {
    font-size: 16px;
    color: #555;
    line-height: 1.5;
    margin-bottom: 8px;
}
.game-modal-timer {
    position: absolute;
    bottom: 0; left: 0;
    height: 4px;
    border-radius: 0 0 28px 28px;
    background: var(--md-sys-color-primary);
    animation: popupTimer linear forwards;
}

/* Type-specific accent colors */
.game-modal-rent { border-top: 5px solid #e74c3c; }
.game-modal-rent .game-modal-title { color: #c0392b; }
.game-modal-rent .game-modal-timer { background: #e74c3c; }

.game-modal-tax { border-top: 5px solid #e67e22; }
.game-modal-tax .game-modal-title { color: #d35400; }
.game-modal-tax .game-modal-timer { background: #e67e22; }

.game-modal-jail { border-top: 5px solid #e74c3c; }
.game-modal-jail .game-modal-title { color: #c0392b; }
.game-modal-jail .game-modal-timer { background: #e74c3c; }

.game-modal-jail-free { border-top: 5px solid #2ecc71; }
.game-modal-jail-free .game-modal-title { color: #27ae60; }
.game-modal-jail-free .game-modal-timer { background: #2ecc71; }

.game-modal-chance { border-top: 5px solid #9b59b6; }
.game-modal-chance .game-modal-title { color: #8e44ad; }
.game-modal-chance .game-modal-timer { background: #9b59b6; }

.game-modal-chest { border-top: 5px solid #3498db; }
.game-modal-chest .game-modal-title { color: #2980b9; }
.game-modal-chest .game-modal-timer { background: #3498db; }

@keyframes gameModalOverlayIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}
@keyframes gameModalOverlayOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}
@keyframes gameModalCardIn {
    0% { opacity: 0; transform: scale(0.7) translateY(30px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes gameModalCardOut {
    0% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.85) translateY(20px); }
}
@keyframes gameModalBounce {
    0%, 100% { transform: scale(1); }
    40% { transform: scale(1.3); }
    60% { transform: scale(0.9); }
    80% { transform: scale(1.1); }
}

/* ========== Bankrupt Player ========== */
.player-card.bankrupt {
    opacity: 0.5;
    background: rgba(231, 76, 60, 0.08);
    border: 1px solid rgba(231, 76, 60, 0.3);
    text-decoration: line-through;
    text-decoration-color: rgba(231, 76, 60, 0.5);
}

.game-modal-bankrupt { border-top: 5px solid #e74c3c; }
.game-modal-bankrupt .game-modal-title { color: #c0392b; }
.game-modal-bankrupt .game-modal-timer { background: #e74c3c; }

.game-modal-debt { border-top: 5px solid #e67e22; }
.game-modal-debt .game-modal-title { color: #d35400; }
.game-modal-debt .game-modal-timer { background: #e67e22; }

.game-modal-win { border-top: 5px solid #f1c40f; }
.game-modal-win .game-modal-title { color: #d4ac0d; }
.game-modal-win .game-modal-timer { background: #f1c40f; }
