/* ============================================
   MegaTown – Board CSS (Mobile-First)
   ============================================ */

/* ---- Tahta Grid ---- */
#board {
    display: grid;
    grid-template-columns: 1.65fr repeat(9, 1fr) 1.65fr;
    grid-template-rows:    1.65fr repeat(9, 1fr) 1.65fr;

    /* Desktop: sidebar (300px) + 2×0.75rem padding */
    width:  min(calc(100dvh - 1.5rem), calc(100vw - 320px));
    height: min(calc(100dvh - 1.5rem), calc(100vw - 320px));

    background: var(--bg-surface);
    border: 1.5px solid rgba(255,255,255,0.10);
    border-radius: var(--r);
    box-shadow:
        var(--shadow-glow),
        0 8px 40px rgba(0,0,0,0.6),
        0 0 0 1px rgba(255,255,255,0.03) inset;
    position: relative;
    flex-shrink: 0;
}

/* ---- Kare Genel ---- */
.square {
    border: 1px solid rgba(255,255,255,0.07);
    position: relative;
    overflow: visible;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: background 0.2s;
    background: rgba(8, 12, 31, 0.55);
}
.square:hover { background: rgba(255,255,255,0.04); z-index: 2; }

.square.highlighted {
    box-shadow: inset 0 0 14px rgba(0, 229, 255, 0.45);
    z-index: 3;
}

.square.owned {
    box-shadow: inset 0 0 0 2px var(--owner-color, transparent);
}

/* ---- Köşe Kareler ---- */
.square.corner {
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
.square.corner .sq-content {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    height: 100%;
}
.square.corner .sq-icon { font-size: clamp(1rem, 2.5vmin, 2rem); }
.square.corner .sq-name {
    font-size: clamp(0.38rem, 1vmin, 0.65rem);
    font-weight: 700; text-align: center;
}

/* ---- Renk Barı ---- */
.sq-color-bar { flex-shrink: 0; }
.side-bottom .sq-color-bar { height: 7px; width: 100%; }
.side-top    .sq-color-bar { height: 7px; width: 100%; order: 1; }
.side-left   .sq-color-bar { width: 7px; height: 100%; position: absolute; right: 0; top: 0; }
.side-right  .sq-color-bar { width: 7px; height: 100%; position: absolute; left: 0; top: 0; }

/* ---- Kare İçerik ---- */
.sq-content {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 2px; text-align: center;
    min-height: 0; min-width: 0;
}
.sq-name {
    font-size: clamp(0.3rem, 1vmin, 0.52rem);
    font-weight: 600; line-height: 1.2;
    color: var(--text-1);
    word-break: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}
.sq-price {
    font-size: clamp(0.3rem, 0.9vmin, 0.48rem);
    color: var(--gold); font-weight: 700;
    margin-top: 1px;
}
.sq-icon {
    font-size: clamp(0.6rem, 1.8vmin, 1.1rem);
    line-height: 1;
}

/* Yan kareler: metin dikey */
.side-left .sq-content {
    writing-mode: vertical-lr;
    transform: rotate(180deg);
}
.side-right .sq-content {
    writing-mode: vertical-lr;
}
.side-left.corner .sq-content,
.side-right.corner .sq-content {
    writing-mode: horizontal-tb;
    transform: none;
}

/* ---- Ev / Otel ---- */
.sq-houses {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    display: flex; gap: 1px;
    z-index: 3;
    pointer-events: none;
    flex-wrap: wrap; /* Taşmayı önlemek için eklendi */
    justify-content: center;
    width: 100%;
    padding: 0 2px;
    box-sizing: border-box;
}

.house-icon {
    font-size: clamp(0.55rem, 1.3vmin, 0.9rem);
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.9));
    line-height: 1;
}
.hotel-icon {
    font-size: clamp(0.7rem, 1.8vmin, 1.2rem);
}

.side-left .sq-houses, .side-right .sq-houses {
    flex-direction: column;
    width: auto; height: 100%;
    max-height: 100%; align-content: center;
    padding: 2px 0;
}
.side-left .sq-houses {
    bottom: auto; left: auto;
    right: 5px; top: 50%;
    transform: translateY(-50%);
}
.side-right .sq-houses {
    bottom: auto; right: auto;
    left: 5px; top: 50%;
    transform: translateY(-50%);
}
.side-top .sq-houses {
    bottom: auto; top: 2px;
}

/* ---- İpotek ---- */
.square.mortgaged {
    background: repeating-linear-gradient(
        45deg,
        rgba(0,0,0,0.25),
        rgba(0,0,0,0.25) 8px,
        rgba(255,0,0,0.08) 8px,
        rgba(255,0,0,0.08) 16px
    ) !important;
}
.square.mortgaged .sq-content { opacity: 0.35; }
.square.mortgaged::after {
    content: "İPOT";
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    color: var(--red);
    font-weight: 900;
    font-size: clamp(0.38rem, 1vmin, 0.6rem);
    letter-spacing: 0.5px;
    border: 1.5px solid var(--red);
    padding: 1px 3px;
    background: rgba(0,0,0,0.8);
    z-index: 5;
    pointer-events: none;
    border-radius: 2px;
    white-space: nowrap;
}

/* ---- Token'lar ---- */
.sq-tokens {
    position: absolute;
    bottom: 2px; right: 2px;
    display: flex; flex-wrap: wrap; gap: 2px;
    z-index: 4; pointer-events: none;
}
.side-top .sq-tokens { bottom: auto; top: 2px; }

.player-token {
    width: clamp(16px, 2.8vmin, 26px);
    height: clamp(16px, 2.8vmin, 26px);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: clamp(0.45rem, 1.3vmin, 0.75rem);
    border: 1px solid rgba(255,255,255,0.85);
    background-image: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.7) 0%, rgba(255,255,255,0) 40%);
    box-shadow: 
        inset -3px -3px 8px rgba(0,0,0,0.5),
        inset 0 0 4px rgba(255,255,255,0.5),
        2px 5px 10px rgba(0,0,0,0.8);
    position: relative;
    animation: tokenPop 0.3s var(--spring) both;
}
/* Ekstra 3D derinlik için alt taban efekti */
.player-token::after {
    content: '';
    position: absolute;
    left: 10%; right: 10%; bottom: -15%;
    height: 30%;
    background: rgba(0,0,0,0.6);
    border-radius: 50%;
    filter: blur(2px);
    z-index: -1;
}
@keyframes tokenPop {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* ---- Merkez Alan ---- */
#board-center {
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg,
        rgba(0, 229, 255, 0.025) 0%,
        rgba(179, 136, 255, 0.025) 100%);
    z-index: 1;
    overflow: hidden;
}

.center-content {
    text-align: center;
    padding: clamp(0.3rem, 1.5vmin, 1rem);
    width: 100%;
    display: flex; flex-direction: column;
    align-items: center; gap: 0.25rem;
}

.game-title {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(1rem, 3vmin, 2.5rem);
    font-weight: 900;
    color: var(--text-1);
    letter-spacing: clamp(1px, 0.3vmin, 3px);
    line-height: 1;
}
.game-title span {
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.game-subtitle {
    font-size: clamp(0.4rem, 1.2vmin, 0.8rem);
    color: var(--text-3);
}

/* Aksiyon alanı */
#action-area {
    display: flex; flex-direction: column;
    gap: clamp(0.2rem, 0.8vmin, 0.5rem);
    align-items: center;
    width: 100%;
}

#action-area .btn {
    min-width: clamp(90px, 18vmin, 180px);
    font-size: clamp(0.65rem, 1.5vmin, 0.95rem);
    padding: clamp(0.35rem, 1vmin, 0.8rem) clamp(0.5rem, 2vmin, 1.5rem);
    min-height: clamp(30px, 5vmin, 48px);
}

.action-msg {
    font-size: clamp(0.6rem, 1.3vmin, 0.85rem);
    color: var(--gold); font-weight: 600; line-height: 1.3;
    max-width: 90%; text-align: center;
}
.waiting-msg {
    font-size: clamp(0.55rem, 1.2vmin, 0.82rem);
    color: var(--text-3); font-style: italic;
}

.btn-roll-dice {
    animation: rollPulse 2s ease-in-out infinite;
    font-size: clamp(0.8rem, 2vmin, 1.1rem) !important;
}
@keyframes rollPulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(0,229,255,0.3); }
    50%       { box-shadow: 0 4px 30px rgba(0,229,255,0.7); }
}

.winner-banner {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(0.9rem, 2.5vmin, 1.5rem);
    color: var(--gold); font-weight: 800;
    animation: winPulse 1s ease-in-out infinite alternate;
}
@keyframes winPulse {
    from { transform: scale(1); }
    to   { transform: scale(1.08); }
}

#turn-info { margin-top: clamp(0.1rem, 0.5vmin, 0.5rem); }
.last-dice {
    font-size: clamp(0.5rem, 1.1vmin, 0.8rem);
    color: var(--text-2);
}

/* Build section */
.build-section {
    background: rgba(0,0,0,0.25);
    border-radius: var(--r-xs);
    padding: clamp(0.25rem, 0.8vmin, 0.5rem);
    text-align: left;
    width: 100%;
    max-width: clamp(180px, 30vmin, 280px);
}
.build-section strong {
    font-size: clamp(0.55rem, 1.1vmin, 0.8rem);
    color: var(--green); display: block; margin-bottom: 0.25rem;
}
.build-btns {
    display: flex; flex-direction: column;
    gap: clamp(0.15rem, 0.4vmin, 0.3rem);
}
.btn-build {
    background: rgba(0, 230, 118, 0.12);
    border: 1px solid rgba(0, 230, 118, 0.3);
    color: var(--green); text-align: left;
    font-size: clamp(0.5rem, 1vmin, 0.78rem);
}
.btn-build:hover { background: rgba(0, 230, 118, 0.22); }

/* ---- Özel Kareler ---- */
.sq-go       .sq-content { background: rgba(0, 230, 118, 0.08); }
.sq-jail     .sq-content { background: rgba(255, 82, 82, 0.08); }
.sq-go_to_jail .sq-content { background: rgba(255, 82, 82, 0.12); }
.sq-free_parking .sq-content { background: rgba(255,215,64, 0.08); }
.sq-chance   .sq-content { background: rgba(0, 229, 255, 0.06); }
.sq-community .sq-content { background: rgba(179, 136, 255, 0.06); }
.sq-tax      .sq-content { background: rgba(255, 152, 0, 0.08); }

/* ============================================
   MOBİL: Tahta boyutu
   ============================================ */
@media (max-width: 900px) {
    #board {
        /* Alt çekmece (220px) + üst padding */
        width:  min(calc(100vw - 1rem), calc(100dvh - 240px));
        height: min(calc(100vw - 1rem), calc(100dvh - 240px));
    }
}

@media (max-width: 480px) {
    #board {
        width:  min(calc(100vw - 0.5rem), calc(100dvh - 215px));
        height: min(calc(100vw - 0.5rem), calc(100dvh - 215px));
    }
    .sq-color-bar {
        height: 5px !important;
        width:  5px !important;
    }
}

/* Landscape küçük ekran */
@media (max-height: 500px) and (max-width: 900px) {
    #board {
        width:  calc(100dvh - 1rem);
        height: calc(100dvh - 1rem);
    }
}
