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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
}

.main-nav {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.nav-btn.active {
    background: white;
    color: #667eea;
    font-weight: bold;
}

/* Views */
.view {
    display: none;
    padding: 40px;
    min-height: 600px;
}

.view.active {
    display: block;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

.btn-danger {
    background: #f56565;
    color: white;
}

.btn-danger:hover {
    background: #e53e3e;
}

/* Home View */
.welcome-card {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.welcome-card h2 {
    font-size: 2.5em;
    color: #2d3748;
    margin-bottom: 20px;
}

.welcome-card > p {
    font-size: 1.2em;
    color: #718096;
    margin-bottom: 40px;
}

.action-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

.action-card {
    background: #f7fafc;
    padding: 30px;
    border-radius: 15px;
    border: 2px solid #e2e8f0;
    transition: all 0.3s;
}

.action-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border-color: #667eea;
}

.action-card h3 {
    font-size: 1.5em;
    color: #2d3748;
    margin-bottom: 15px;
}

.action-card p {
    color: #718096;
    margin-bottom: 20px;
}

/* Form Groups */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 8px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

/* Board Creator */
.creator-container {
    max-width: 1200px;
    margin: 0 auto;
}

.creator-section {
    background: #f7fafc;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
}

.creator-section h3 {
    color: #2d3748;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.hint {
    color: #718096;
    font-style: italic;
    margin-bottom: 20px;
}

.board-preview {
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    grid-template-rows: repeat(11, 1fr);
    gap: 5px;
    background: #2d3748;
    padding: 20px;
    border-radius: 10px;
    aspect-ratio: 1;
    max-width: 800px;
    margin: 0 auto;
}

.board-space {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 5px;
    padding: 8px;
    font-size: 0.7em;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
    aspect-ratio: 1;
    min-height: 0;
}

.board-space:hover {
    background: #edf2f7;
    transform: scale(1.05);
}

.property-color-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
}

.space-name {
    margin-top: 10px;
    font-size: 0.85em;
    font-weight: 600;
    text-shadow: 0 0 3px white, 0 0 5px white;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 2px 4px;
    border-radius: 3px;
}

.space-price {
    margin-top: 2px;
    font-size: 0.75em;
    color: #4a5568;
    font-weight: 500;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 1px 3px;
    border-radius: 2px;
}

.space-info {
    margin-top: 2px;
    font-size: 0.65em;
    color: #718096;
    line-height: 1.2;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 2px 4px;
    border-radius: 2px;
}

.board-space.corner {
    grid-column: span 1;
    grid-row: span 1;
}

.board-space.property { background: #90EE90; }
.board-space.railroad { background: #FFD700; }
.board-space.utility { background: #87CEEB; }
.board-space.chance { background: #FFA07A; }
.board-space.chest { background: #DDA0DD; }
.board-space.tax { background: #FF6B6B; }
.board-space.go { background: #4CAF50; color: white; font-weight: bold; }
.board-space.jail { background: #FF9800; color: white; }
.board-space.free { background: #2196F3; color: white; }
.board-space.gotojail { background: #F44336; color: white; font-weight: bold; }

.creator-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* Game Lobby */
.lobby-container {
    max-width: 1000px;
    margin: 0 auto;
}

.lobby-section {
    background: #f7fafc;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
}

.lobby-section h3 {
    color: #2d3748;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.games-list {
    display: grid;
    gap: 15px;
}

.game-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
}

.game-card:hover {
    border-color: #667eea;
    transform: translateX(5px);
}

.game-card-info h4 {
    color: #2d3748;
    margin-bottom: 5px;
}

.game-card-info p {
    color: #718096;
    font-size: 0.9em;
}

/* Game Board */
.game-container {
    max-width: 1400px;
    margin: 0 auto;
}

.game-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    border-radius: 10px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-info {
    display: flex;
    gap: 20px;
    font-size: 0.9em;
}

.game-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 30px;
    margin-bottom: 30px;
}

.game-board-container {
    background: #2d3748;
    padding: 20px;
    border-radius: 15px;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    grid-template-rows: repeat(11, 1fr);
    gap: 3px;
    background: #1a202c;
    padding: 15px;
    aspect-ratio: 1;
    max-width: 800px;
    margin: 0 auto;
    border-radius: 10px;
}

.board-center {
    /* Grid position set dynamically via JavaScript based on board size */
    /* grid-column and grid-row are set to 2 / gridSize in JS */
    background: #1e293b;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
}

.game-space {
    background: white;
    border-radius: 5px;
    padding: 10px;
    font-size: 0.75em;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    text-align: center;
    overflow: hidden;
    aspect-ratio: 1;
    min-height: 0;
}

.game-space .property-color-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
}

.game-space .space-name {
    margin-top: 10px;
    font-size: 0.85em;
    font-weight: 600;
    text-shadow: 0 0 3px white, 0 0 5px white;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 2px 4px;
    border-radius: 3px;
}

.game-space .space-info {
    margin-top: 2px;
    font-size: 0.65em;
    color: #718096;
    line-height: 1.2;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 2px 4px;
    border-radius: 2px;
}

.player-token {
    width: 55%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 3px solid white;
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    z-index: 10;
    font-size: 2em;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Game Controls */
.game-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.turn-controls {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    order: -1; /* Ensure it appears first */
    margin-bottom: 10px;
}

.turn-controls h3 {
    color: white;
    margin-bottom: 15px;
    font-size: 1.3em;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.turn-controls #turn-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.turn-controls #turn-panel button {
    font-size: 1.1em;
    padding: 15px 25px;
}

.players-panel,
.game-log {
    background: #f7fafc;
    padding: 20px;
    border-radius: 10px;
}

.players-panel h3,
.game-log h3 {
    color: #2d3748;
    margin-bottom: 15px;
}

.player-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 4px solid #667eea;
}

.player-item.active {
    border-left-color: #48bb78;
    background: #f0fff4;
}

.player-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.player-name {
    font-weight: 600;
    color: #2d3748;
}

.player-position,
.player-properties {
    font-size: 0.9em;
    color: #718096;
}

.dice-result {
    background: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    margin: 15px 0;
    font-size: 2em;
    font-weight: bold;
    color: #667eea;
}

.turn-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.game-log {
    max-height: 300px;
    overflow-y: auto;
}

.log-message {
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border-radius: 5px;
    font-size: 0.9em;
    color: #4a5568;
}

.log-message.important {
    background: #fef5e7;
    border-left: 3px solid #f39c12;
}

.game-footer {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
}

.modal-content h3 {
    color: #2d3748;
    margin-bottom: 25px;
    font-size: 1.8em;
}

.modal-actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    justify-content: flex-end;
}

/* Token Selection */
.token-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 10px;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    background: #f8fafc;
    border-radius: 8px;
}

.token-option {
    position: relative;
    cursor: pointer;
    border: 3px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s;
    aspect-ratio: 1;
}

.token-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.token-option:hover {
    transform: scale(1.05);
    border-color: #667eea;
}

.token-option.selected {
    border-color: #4caf50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.3);
}

.token-option.taken {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(100%);
}

.token-option.taken::after {
    content: '✓ Taken';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
}

.token-name {
    text-align: center;
    font-size: 10px;
    margin-top: 4px;
    color: #64748b;
}

/* Responsive */
@media (max-width: 1024px) {
    .game-layout {
        grid-template-columns: 1fr;
    }

    .board-preview,
    .game-board {
        grid-template-columns: repeat(11, 1fr);
        font-size: 0.8em;
    }
}

@media (max-width: 768px) {
    .action-cards {
        grid-template-columns: 1fr;
    }

    .board-preview,
    .game-board {
        font-size: 0.6em;
    }

    .game-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
}

/* Turn Banner */
.turn-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 30px;
    text-align: center;
    font-size: 1.2em;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideDown 0.3s ease-out;
}

.turn-banner.your-turn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    animation: pulse 2s ease-in-out infinite;
}

.turn-banner.waiting {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    50% {
        box-shadow: 0 4px 20px rgba(16, 185, 129, 0.5), 0 0 30px rgba(16, 185, 129, 0.3);
    }
}

/* Enhanced player highlighting */
.player-item.active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-left: 5px solid #047857;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    transform: scale(1.02);
}

.player-item.active .player-name {
    color: white !important;
    font-weight: bold;
    font-size: 1.1em;
}

/* Game state update notification */
.game-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    animation: slideInRight 0.3s ease-out;
    max-width: 300px;
}

.game-notification.success {
    border-left: 5px solid #10b981;
}

.game-notification.info {
    border-left: 5px solid #3b82f6;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}
