/* ========== Machi Koro Game Styles ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #1a1a2e;
    --bg-card: #16213e;
    --bg-modal: #0f3460;
    --fg: #e8e8e8;
    --fg2: #a0a0b0;
    --accent: #e94560;
    --accent2: #0f3460;
    --blue: #4a9eff;
    --green: #4caf50;
    --red: #f44336;
    --purple: #9c27b0;
    --gold: #ffc107;
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'Segoe UI', 'Noto Sans SC', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--fg);
    min-height: 100vh;
    overflow-x: hidden;
}

#app {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* ========== Setup Screen ========== */
.setup-screen {
    text-align: center;
    padding: 60px 20px;
}

.setup-screen h1 {
    font-size: 2.5em;
    background: linear-gradient(135deg, var(--blue), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.setup-screen .subtitle {
    color: var(--fg2);
    margin-bottom: 40px;
    font-size: 1.1em;
}

.setup-form {
    max-width: 400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.setup-field {
    text-align: left;
}

.setup-field label {
    display: block;
    font-size: 0.9em;
    color: var(--fg2);
    margin-bottom: 6px;
}

.setup-field input[type="text"],
.setup-field select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--fg);
    font-size: 1em;
    transition: border-color 0.3s;
}

.setup-field input:focus,
.setup-field select:focus {
    outline: none;
    border-color: var(--blue);
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

/* ========== Buttons ========== */
.btn-primary {
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    border: none;
    border-radius: 980px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(233,69,96,0.3);
}

.btn-secondary {
    padding: 12px 24px;
    background: transparent;
    color: var(--fg);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 980px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.btn-secondary:hover {
    border-color: var(--fg);
}

.btn-small {
    padding: 8px 16px;
    background: rgba(255,255,255,0.1);
    color: var(--fg);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 980px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}

.btn-small:hover {
    background: rgba(255,255,255,0.15);
}

.btn-dice {
    padding: 16px 32px;
    background: var(--bg-card);
    color: var(--fg);
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: var(--radius);
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    min-width: 120px;
}

.btn-dice:hover:not(:disabled) {
    border-color: var(--blue);
    background: rgba(74,158,255,0.1);
}

.btn-dice.active {
    border-color: var(--accent);
    background: rgba(233,69,96,0.15);
}

.btn-dice:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ========== Game Screen ========== */
.game-screen {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.game-title-bar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.game-title-bar h1 {
    font-size: 1.4em;
}

.turn-indicator {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 12px;
}

.turn-indicator.player-turn {
    background: rgba(74,158,255,0.15);
    border: 1px solid rgba(74,158,255,0.3);
}

.turn-indicator.ai-turn {
    background: rgba(233,69,96,0.15);
    border: 1px solid rgba(233,69,96,0.3);
}

.turn-label {
    font-weight: 600;
    font-size: 0.95em;
}

.turn-num {
    font-weight: 700;
    color: var(--gold);
}

/* ========== Dice Area ========== */
.dice-area {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
}

.dice-choice p {
    margin-bottom: 16px;
    color: var(--fg2);
}

.dice-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.dice-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.dice-display {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.die {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #fff, #e0e0e0);
    color: #1a1a2e;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 800;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.dice-total {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--gold);
}

.doubles-bonus {
    color: var(--green);
    font-weight: 600;
    animation: pulse 0.5s ease-in-out;
}

.buy-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

/* ========== Players Area ========== */
.players-area {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.player-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.player-card.active {
    border-color: var(--accent);
    background: rgba(233,69,96,0.05);
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.player-name {
    font-weight: 600;
    font-size: 0.95em;
}

.player-coins {
    font-weight: 700;
    color: var(--gold);
    font-size: 1.1em;
}

.player-stats {
    font-size: 0.85em;
    color: var(--fg2);
    margin-bottom: 10px;
}

.player-buildings {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.building-tag {
    font-size: 0.75em;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.building-tag.blue { background: rgba(74,158,255,0.2); color: var(--blue); }
.building-tag.green { background: rgba(76,175,80,0.2); color: var(--green); }
.building-tag.red { background: rgba(244,67,54,0.2); color: var(--red); }
.building-tag.purple { background: rgba(156,39,176,0.2); color: var(--purple); }
.building-tag.landmark { background: rgba(255,193,7,0.2); color: var(--gold); }

/* ========== Game Log ========== */
.game-log {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    max-height: 200px;
    overflow-y: auto;
}

.game-log h3 {
    font-size: 0.9em;
    color: var(--fg2);
    margin-bottom: 8px;
}

.log-entries {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.log-entry {
    font-size: 0.85em;
    color: var(--fg2);
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* ========== Modal ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-modal);
    border-radius: var(--radius);
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,0.4);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.modal-header h2 {
    font-size: 1.2em;
}

.btn-close {
    background: none;
    border: none;
    color: var(--fg2);
    font-size: 1.5em;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-close:hover {
    background: rgba(255,255,255,0.1);
    color: var(--fg);
}

.modal-body {
    padding: 16px 24px;
}

.modal-body h3 {
    font-size: 0.9em;
    color: var(--fg2);
    margin: 12px 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.buy-item {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
}

.buy-item:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.15);
}

.buy-item-name {
    font-weight: 600;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.color-dot.blue { background: var(--blue); }
.color-dot.green { background: var(--green); }
.color-dot.red { background: var(--red); }
.color-dot.purple { background: var(--purple); }
.color-dot.landmark-color { background: var(--gold); }

.buy-item-desc {
    grid-column: 1 / -1;
    font-size: 0.8em;
    color: var(--fg2);
}

.buy-item-cost {
    font-weight: 700;
    color: var(--gold);
    font-size: 1em;
}

.buy-item.landmark {
    border-color: rgba(255,193,7,0.2);
}

.modal-footer {
    padding: 12px 24px;
    border-top: 1px solid rgba(255,255,255,0.1);
    text-align: right;
}

/* ========== Game Over ========== */
.game-over-msg {
    text-align: center;
    padding: 12px 24px;
}

.game-over-msg h2 {
    font-size: 1.5em;
    color: var(--gold);
    margin-bottom: 12px;
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ========== Animations ========== */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ========== Responsive ========== */
@media(max-width: 600px) {
    #app { padding: 12px; }
    .setup-screen { padding: 40px 16px; }
    .setup-screen h1 { font-size: 1.8em; }
    .players-area { grid-template-columns: 1fr; }
    .dice-buttons { flex-direction: column; align-items: center; }
    .btn-dice { width: 100%; min-width: auto; }
    .buy-actions { flex-direction: column; }
    .dice-display { gap: 10px; }
    .die { width: 48px; height: 48px; font-size: 22px; }
}