:root {
    --bg: #0c1813;
    --panel: rgba(16, 26, 22, 0.92);
    --border: rgba(255, 255, 255, 0.14);
    --tile-bg: #e4f1e6;
    --tile-text: #111f17;
}

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

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: radial-gradient(circle at top, #173528 0%, #0b1611 65%, #060b09 100%);
    color: #f3f7f4;
    height: 100vh;
    overflow: hidden;
}

.app { display: flex; flex-direction: column; height: 100vh; }

.hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 18px;
    background: rgba(0, 0, 0, 0.45);
    border-bottom: 1px solid var(--border);
}

.hud-left, .hud-right { display: flex; align-items: center; gap: 10px; }

.brand {
    font-weight: 900;
    letter-spacing: 1.5px;
    padding: 4px 12px;
    border-radius: 8px;
    background: #c81d1a;
    color: #fff;
    border: 2px solid #fff;
}

.turn-pill {
    padding: 5px 14px;
    border-radius: 999px;
    background: var(--panel);
    border: 1px solid var(--border);
    font-size: 0.88rem;
    font-weight: 700;
}

.hud-btn {
    text-decoration: none;
    background: var(--panel);
    color: #f3f7f4;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
}

.hud-btn:hover { background: rgba(255, 255, 255, 0.14); }

.layout {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 16px;
    padding: 10px 16px;
    min-height: 0;
}

.board-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.board {
    position: relative;
    width: min(89vh, 100%);
    aspect-ratio: 1 / 1;
    display: grid;
    grid-template-columns: 1.4fr repeat(9, 1fr) 1.4fr;
    grid-template-rows: 1.4fr repeat(9, 1fr) 1.4fr;
    background: #1a2d23;
    border: 5px solid #0e1d15;
    border-radius: 10px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7), inset 0 0 0 2px rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

/* Authentic Directional Tiles */
.tile {
    position: relative;
    background: var(--tile-bg);
    color: var(--tile-text);
    border: 1px solid #243b2f;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    text-align: center;
    font-size: clamp(0.44rem, 0.68vw, 0.64rem);
    overflow: hidden;
}

.tile.side-bottom { flex-direction: column; }
.tile.side-top { flex-direction: column-reverse; }
.tile.side-left { flex-direction: row-reverse; }
.tile.side-right { flex-direction: row; }

.tile.corner {
    background: #d5e9d9;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    font-weight: 900;
    font-size: clamp(0.54rem, 0.8vw, 0.74rem);
}

.tile.mortgaged { opacity: 0.55; background: #cbd2ce; }

.tile-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    font-size: 0.52rem;
}

.tile.side-bottom .tile-bar,
.tile.side-top .tile-bar {
    width: 100%;
    height: 24%;
    min-height: 11px;
    border-bottom: 1px solid #243b2f;
}

.tile.side-top .tile-bar { border-bottom: none; border-top: 1px solid #243b2f; }

.tile.side-left .tile-bar,
.tile.side-right .tile-bar {
    height: 100%;
    width: 24%;
    min-width: 11px;
    flex-direction: column;
    border-left: 1px solid #243b2f;
}

.tile.side-right .tile-bar { border-left: none; border-right: 1px solid #243b2f; }

.tile-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 2px;
    min-width: 0;
}

.tile-icon { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
.tile-icon svg { width: 100%; height: 100%; display: block; }
.tile.clickable-tile { cursor: pointer; }
.tile.clickable-tile:hover { filter: brightness(0.94); }
.prop-left.clickable-prop { cursor: pointer; }
.prop-left.clickable-prop:hover { text-decoration: underline; }
.auction-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile-name { font-weight: 800; line-height: 1.05; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tile-price { font-weight: 800; font-size: 0.84em; color: #1f3b2c; }

.owner-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1.5px solid #fff;
    z-index: 3;
}

.tokens-layer {
    position: absolute;
    inset: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1px;
    pointer-events: none;
    z-index: 5;
}

.token {
    position: relative;
    font-size: clamp(0.85rem, 1.3vw, 1.25rem);
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.7));
    transition: transform 0.14s ease;
}

.token.token-self::before {
    content: '▼';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    color: #ef4444;
    font-size: 0.72rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
    animation: arrowBounce 0.75s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes arrowBounce {
    from { transform: translate(-50%, 0); }
    to { transform: translate(-50%, -5px); }
}

.token.hopping {
    animation: tokenHop 0.16s ease-out;
}

@keyframes tokenHop {
    0% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-9px) scale(1.18); }
    100% { transform: translateY(0) scale(1); }
}

.debt-badge {
    display: inline-block;
    margin-left: 5px;
    padding: 1px 6px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
}

/* Board Center */
.board-center {
    position: relative;
    grid-column: 2 / 11;
    grid-row: 2 / 11;
    background: radial-gradient(circle at center, #d7ecdc 0%, #bad7c1 100%);
    color: #102419;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 18px;
    text-align: center;
    box-shadow: inset 0 0 28px rgba(16, 36, 25, 0.14);
}

.deck-slot {
    position: absolute;
    width: 92px;
    height: 58px;
    border-radius: 7px;
    border: 2px dashed rgba(16, 36, 25, 0.35);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.58rem;
    letter-spacing: 0.6px;
    pointer-events: none;
    box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.12);
}

.deck-slot span { font-size: 1.1rem; }
.deck-community {
    top: 22px;
    left: 22px;
    transform: rotate(-32deg);
    background: linear-gradient(135deg, #60a5fa, #2563eb);
    color: #fff;
    border-color: #fff;
}

.deck-chance {
    bottom: 22px;
    right: 22px;
    transform: rotate(-32deg);
    background: linear-gradient(135deg, #fb923c, #ea580c);
    color: #fff;
    border-color: #fff;
}

.center-logo {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 900;
    letter-spacing: 3px;
    color: #fff;
    background: linear-gradient(135deg, #dc2626, #991b1b);
    padding: 6px 24px;
    border-radius: 10px;
    border: 3px solid #fff;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
    transform: rotate(-6deg);
}

.jackpot-box {
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(16, 36, 25, 0.22);
    padding: 5px 16px;
    border-radius: 10px;
    font-size: 0.78rem;
}

.jackpot-box strong { font-size: 1.15rem; color: #b45309; }

.dice-area { display: flex; gap: 14px; font-size: 3rem; line-height: 1; }

.die {
    width: 56px;
    height: 56px;
    background: #fff;
    color: #111;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    border: 2px solid #d1d5db;
}

.die.rolling { animation: diceRoll 0.35s ease; }
@keyframes diceRoll {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.15); }
    100% { transform: rotate(360deg) scale(1); }
}

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

.cta-btn {
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    background: linear-gradient(135deg, #218c54, #14633a);
    color: #fff;
    font-weight: 800;
    font-size: 0.92rem;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(20, 99, 58, 0.35);
}

.cta-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-secondary { background: #334155; }
.btn-warning { background: #d97706; }
.btn-gold { background: linear-gradient(135deg, #d97706, #b45309); }

.center-log {
    font-size: 0.85rem;
    font-weight: 700;
    background: rgba(16, 36, 25, 0.12);
    padding: 6px 14px;
    border-radius: 999px;
    max-width: 88%;
}

/* Sidebar */
.sidebar { display: flex; flex-direction: column; gap: 10px; min-height: 0; }

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 11px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.panel h3 { font-size: 0.84rem; color: #9eb3a8; text-transform: uppercase; letter-spacing: 0.5px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.wallet-total { color: #ffd700; font-size: 0.95rem; }

/* Authentic Monopoly Banknotes */
.bill-tray {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.banknote {
    position: relative;
    border-radius: 5px;
    padding: 6px 4px;
    text-align: center;
    font-weight: 900;
    font-size: 0.78rem;
    color: #1a1a1a;
    border: 1.5px solid rgba(0, 0, 0, 0.35);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45), 0 3px 6px rgba(0, 0, 0, 0.35);
}

.banknote .bill-count {
    display: block;
    font-size: 0.65rem;
    font-weight: 800;
    opacity: 0.82;
}

.bill-500 { background: linear-gradient(135deg, #fdba74, #f97316); }
.bill-100 { background: linear-gradient(135deg, #fde68a, #d6b26e); }
.bill-50  { background: linear-gradient(135deg, #93c5fd, #60a5fa); }
.bill-20  { background: linear-gradient(135deg, #86efac, #4ade80); }
.bill-10  { background: linear-gradient(135deg, #fef08a, #facc15); }
.bill-5   { background: linear-gradient(135deg, #fbcfe8, #f472b6); }
.bill-1   { background: linear-gradient(135deg, #f8fafc, #e2e8f0); }

.mini-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 4px 9px;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
}

.players-list { display: flex; flex-direction: column; gap: 5px; }

.player-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: 9px;
    background: rgba(0, 0, 0, 0.28);
    border: 2px solid transparent;
    font-size: 0.84rem;
}

.player-row.active { border-color: #ffd700; background: rgba(255, 215, 0, 0.12); }
.player-row.bankrupt { opacity: 0.4; text-decoration: line-through; }

.prop-list { display: flex; flex-direction: column; gap: 5px; max-height: 150px; overflow-y: auto; }

.prop-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.28);
    font-size: 0.78rem;
}

.prop-left { display: flex; align-items: center; gap: 6px; }
.prop-swatch { width: 10px; height: 20px; border-radius: 3px; flex-shrink: 0; }
.prop-actions { display: flex; gap: 4px; }

.prop-btn {
    border: none;
    border-radius: 5px;
    padding: 3px 6px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    background: #238654;
    color: #fff;
}

.prop-btn.mort { background: #64748b; }
.muted { color: #7f968a; font-size: 0.8rem; }

.log-panel { flex: 1; min-height: 0; }
.event-log {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.78rem;
    color: #cfe0d6;
}

/* Modals & Authentic Title Deed Card */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(4, 10, 8, 0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.hidden { display: none !important; }

.modal-card {
    width: 100%;
    max-width: 420px;
    background: linear-gradient(160deg, #16241e 0%, #0d1612 100%);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.deed-card {
    background: #f8faf8;
    color: #142019;
    border: 3px solid #142019;
    padding: 18px;
}

.deed-header {
    border-radius: 10px;
    padding: 12px;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    border: 2px solid #142019;
    margin-bottom: 14px;
}

.deed-header small { display: block; font-size: 0.7rem; letter-spacing: 1px; opacity: 0.9; }
.deed-body { font-size: 0.88rem; margin-bottom: 16px; text-align: left; }
.deed-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed rgba(20, 32, 25, 0.2); }
.deed-price-tag { text-align: center; font-size: 1.1rem; font-weight: 900; margin-top: 10px; color: #14633a; }

.modal-badge { font-size: 1.5rem; font-weight: 900; margin-bottom: 8px; color: #ffd700; }
.modal-desc { color: #a7bdb1; font-size: 0.9rem; line-height: 1.45; margin: 10px 0 18px; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; }

.start-options { text-align: left; margin-bottom: 18px; }
.start-options label { display: block; font-size: 0.82rem; color: #9eb3a8; margin-bottom: 6px; font-weight: 700; }

.segmented {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 6px;
    background: rgba(0, 0, 0, 0.35);
    padding: 4px;
    border-radius: 10px;
}

.segmented button {
    border: none;
    background: transparent;
    color: #9eb3a8;
    padding: 8px;
    border-radius: 7px;
    font-weight: 700;
    cursor: pointer;
}

.segmented button.active { background: #218c54; color: #fff; }
.card-popup-text { font-size: 1.05rem; font-weight: 700; margin: 12px 0 20px; line-height: 1.45; }

/* Authentic Pop-up Chance / Community Card */
.monopoly-event-card {
    padding: 12px;
    border-radius: 16px;
    animation: cardPop 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cardPop {
    from { transform: scale(0.65) rotate(-8deg); opacity: 0; }
    to { transform: scale(1) rotate(0deg); opacity: 1; }
}

.monopoly-event-card.card-chance {
    background: linear-gradient(135deg, #fb923c, #ea580c);
    color: #fff;
    border: 4px solid #fff;
}

.monopoly-event-card.card-community {
    background: linear-gradient(135deg, #60a5fa, #2563eb);
    color: #fff;
    border: 4px solid #fff;
}

.event-card-inner {
    border: 2px dashed rgba(255, 255, 255, 0.75);
    border-radius: 10px;
    padding: 20px 18px;
}

.event-card-icon { font-size: 2.6rem; margin-bottom: 4px; }
.event-card-title { font-weight: 900; letter-spacing: 2px; font-size: 0.9rem; opacity: 0.92; }

/* Interactive Banknote Payment Modal */
.pay-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    background: rgba(0, 0, 0, 0.35);
    padding: 10px;
    border-radius: 12px;
    margin-bottom: 14px;
}

.pay-summary small { display: block; font-size: 0.72rem; color: #9eb3a8; }
.pay-summary strong { font-size: 1.05rem; color: #ffd700; }

.pay-bills-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.pay-bill-btn {
    cursor: pointer;
    transition: transform 0.12s ease, filter 0.12s ease;
}

.pay-bill-btn:hover:not(:disabled) { transform: translateY(-3px) scale(1.04); filter: brightness(1.08); }
.pay-bill-btn:disabled { opacity: 0.32; cursor: not-allowed; }

.pay-footer-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1.4fr;
    gap: 8px;
}

.trade-form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; text-align: left; }
.trade-form select, .trade-form input {
    width: 100%;
    padding: 9px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #0c1411;
    color: #fff;
    font-size: 0.9rem;
}

@media (max-width: 960px) {
    body { overflow: auto; height: auto; }
    .layout { grid-template-columns: 1fr; }
    .board { width: 96vw; }
    .deck-slot { display: none; }
}
