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

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

body {
    background: #1a1a2e;
    color: #eaeaea;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    min-height: 100vh;
    user-select: none;
    touch-action: manipulation;
}

/* === Ekran sistemi === */
.screen {
    display: none;
    width: 100%;
    min-height: 100vh;
    padding: 10px;
}
.screen.active { display: flex; }

#screen-menu.active,
#screen-market.active {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

#screen-game.active {
    justify-content: center;
    align-items: flex-start;
}

/* === Ana menü === */
#screen-menu {
    background: radial-gradient(ellipse at top, #2a2a4e 0%, #1a1a2e 60%);
}
.menu-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 40px 20px;
    width: 100%;
    max-width: 420px;
    margin: auto 0;
}
.menu-title {
    font-size: clamp(56px, 14vw, 96px);
    color: #e94560;
    letter-spacing: 8px;
    text-shadow: 0 4px 24px rgba(233, 69, 96, 0.5);
    margin-bottom: 0;
}
.menu-sub {
    color: #ffd700;
    letter-spacing: 4px;
    font-size: clamp(12px, 3vw, 16px);
    margin-bottom: 32px;
    opacity: 0.9;
}
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}
.menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 18px 24px;
    background: #16213e;
    color: #eaeaea;
    border: 2px solid #0f3460;
    border-radius: 12px;
    font-size: clamp(16px, 4.5vw, 22px);
    font-weight: 700;
    letter-spacing: 4px;
    cursor: pointer;
    transition: transform 0.12s, background 0.2s, border-color 0.2s;
}
.menu-btn:hover {
    transform: translateY(-2px);
    background: #0f3460;
    border-color: #e94560;
}
.menu-btn:active { transform: translateY(0); }
.menu-btn.primary {
    background: linear-gradient(135deg, #e94560, #c1334b);
    border-color: #ffd700;
    color: white;
    box-shadow: 0 4px 20px rgba(233, 69, 96, 0.35);
}
.menu-btn.primary:hover {
    background: linear-gradient(135deg, #ff5876, #d43d57);
}
.menu-btn .icon { font-size: 1.3em; }
.menu-foot {
    margin-top: 40px;
    color: #555;
    font-size: 12px;
    letter-spacing: 2px;
}

/* === Hesap modal === */
.account-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 25, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.account-backdrop.hidden { display: none; }
.account-card {
    position: relative;
    background: linear-gradient(180deg, #1f1f3a 0%, #161628 100%);
    border: 2px solid #0f3460;
    border-radius: 16px;
    padding: 28px 24px 22px;
    width: min(92vw, 380px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.account-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 10px;
}
.account-close:hover { color: #fff; }
.account-title {
    color: #ffd700;
    font-size: 22px;
    letter-spacing: 4px;
    margin-bottom: 18px;
    text-align: center;
}
.account-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    gap: 12px;
}
.account-label {
    color: #9ea0c4;
    font-size: 13px;
    letter-spacing: 1px;
    flex: 0 0 auto;
}
.account-tag {
    color: #e94560;
    font-weight: 700;
    letter-spacing: 2px;
    font-size: 16px;
}
.account-status {
    color: #cfd0e4;
    font-size: 13px;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.account-input {
    background: #0f0f1e;
    border: 1px solid #2a2a4e;
    color: #eaeaea;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    width: 60%;
    text-align: right;
    font-family: inherit;
}
.account-input:focus {
    outline: none;
    border-color: #e94560;
}
.account-action-btn {
    margin-top: 18px;
    width: 100%;
    letter-spacing: 2px;
}
.account-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}
.account-hint {
    margin-top: 14px;
    color: #888aa8;
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
}

/* === Market === */
#screen-market {
    background: #1a1a2e;
}
.screen-header {
    width: 100%;
    max-width: 800px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #16213e;
    border-radius: 8px;
    margin-bottom: 12px;
}
.screen-header h2 {
    color: #ffd700;
    letter-spacing: 4px;
    font-size: clamp(18px, 5vw, 26px);
    flex: 1;
    text-align: center;
}
.header-spacer { width: 80px; }
.back-btn {
    background: none;
    color: #eaeaea;
    border: 1px solid #e94560;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    min-width: 80px;
    transition: background 0.15s;
}
.back-btn:hover { background: rgba(233, 69, 96, 0.2); }

.market-grid {
    width: 100%;
    max-width: 1000px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 10px;
}
@media (max-width: 600px) {
    .market-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
}
.market-quadrant {
    background: #14182a;
    border: 1px solid #0f3460;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 280px;
}
.market-quadrant[data-side="left"] { border-left: 3px solid #ffd700; }
.market-quadrant[data-side="right"] { border-right: 3px solid #e94560; }

.quad-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
}
.quad-tag {
    font-size: 13px;
    color: #ffd700;
    letter-spacing: 1px;
    font-weight: 600;
}
.quad-active {
    font-size: 11px;
    color: #4caf50;
    background: rgba(76, 175, 80, 0.15);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid #4caf50;
}
.quad-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    padding: 10px;
    overflow-y: auto;
    max-height: 400px;
}
.quad-cards.quad-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
}
.empty-msg {
    text-align: center;
    color: #777;
    font-size: 13px;
    line-height: 1.6;
}
.empty-msg small { color: #555; font-size: 11px; }

/* === Tier divider === */
.tier-divider {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px 4px;
    color: #888;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
}
.tier-divider::before,
.tier-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #2a2a4e;
}
.tier-divider.tier-1 { color: #ffd700; }
.tier-divider.tier-2 { color: #777; }

/* === Asset kart === */
.asset-card {
    background: linear-gradient(135deg, #1a2240, #0f1830);
    border: 1px solid #2a2a4e;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.2s, box-shadow 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 130px;
}
.asset-card:hover {
    transform: translateY(-2px);
    border-color: #e94560;
    box-shadow: 0 4px 16px rgba(233, 69, 96, 0.2);
}
.asset-card.active {
    border-color: #4caf50;
    background: linear-gradient(135deg, #1a3a2a, #0f2a1f);
    box-shadow: 0 0 12px rgba(76, 175, 80, 0.3);
}
.asset-card.active::after {
    content: '✓';
    position: absolute;
    top: 6px;
    right: 6px;
    color: #4caf50;
    font-size: 16px;
    font-weight: 900;
}

.card-preview {
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-emoji {
    font-size: 24px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a0f20;
    border-radius: 6px;
    flex-shrink: 0;
}
.card-swatches {
    display: flex;
    gap: 2px;
    flex: 1;
    height: 18px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #2a2a4e;
}
.swatch { flex: 1; }

.card-name {
    color: #eaeaea;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    word-break: break-word;
}
.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 10px;
}
.card-lic {
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    background: #2a2a4e;
    color: #aaa;
}
.card-lic.lic-cc0 { background: #2e7d32; color: #fff; }
.card-lic.lic-cc-by { background: #ef6c00; color: #fff; }
.card-lic.lic-cc-by-sa { background: #5d4037; color: #fff; }
.card-lic.lic-gpl { background: #c62828; color: #fff; }
.card-lic.lic-royalty { background: #1565c0; color: #fff; }
.card-lic.lic-itch { background: #6a4caf; color: #fff; }
.card-badge {
    padding: 2px 6px;
    border-radius: 3px;
    background: #ffd700;
    color: #1a1a2e;
    font-weight: 700;
}
.card-badge.warn { background: #c62828; color: #fff; }
.card-source {
    background: none;
    border: 1px solid #444;
    color: #999;
    font-size: 10px;
    padding: 3px 6px;
    border-radius: 4px;
    text-decoration: none;
    align-self: flex-start;
    margin-top: auto;
}
.card-source:hover {
    border-color: #ffd700;
    color: #ffd700;
}
.market-foot {
    color: #666;
    font-size: 12px;
    text-align: center;
    margin-top: 16px;
    max-width: 800px;
    padding: 0 16px;
}

/* === Oyun ekranındaki geri butonu === */
#hud .back-btn {
    padding: 4px 10px;
    min-width: 0;
    font-size: 18px;
    border-color: #0f3460;
}
#hud .back-btn:hover {
    background: rgba(15, 52, 96, 0.4);
}

/* İç sahne 600×720 sabit (120 pia + 10 + 360 board + 10 + 120 smog).
   Dış genişlik ekrana göre küçülür — mobilde tam otursun, masaüstünde max 600. */
:root {
    --base-width: 600px;
    --base-height: 720px;
}

#app {
    width: 100%;
    max-width: var(--base-width);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: #16213e;
    border-radius: 8px;
    gap: 8px;
    flex-wrap: nowrap;
    min-height: 54px;
}

#hud h1 {
    color: #e94560;
    font-size: clamp(18px, 5vw, 28px);
    letter-spacing: 2px;
}

.hud-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 6px;
    min-width: 46px;
}

.hud-stat .label {
    font-size: 9px;
    color: #888;
    letter-spacing: 1.5px;
}

.hud-stat .value {
    font-size: clamp(14px, 4.5vw, 22px);
    font-weight: 700;
    color: #ffd700;
    font-family: 'Consolas', monospace;
}

#combo-value.active {
    color: #e94560;
    animation: combo-pulse 0.4s;
}

@keyframes combo-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

#mute-btn {
    background: none;
    border: 1px solid #e94560;
    color: #eaeaea;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

#mute-btn:hover {
    background: rgba(233, 69, 96, 0.2);
}

/* Sahne, 600×720 iç oranında, genişliğe göre ölçeklenir */
#game-scaler {
    width: 100%;
    max-width: var(--base-width);
    aspect-ratio: 600 / 720;
    position: relative;
    overflow: hidden;
}

#game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--base-width);
    height: var(--base-height);
    display: flex;
    gap: 10px;
    transform-origin: top left;
    /* JS ile ölçek güncellenir */
}

.character-stage {
    width: 120px;
    height: 720px;
    background: #16213e;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

#board-wrap {
    position: relative;
    width: 360px;
    height: 720px;
    flex-shrink: 0;
}

#board {
    position: absolute;
    inset: 0;
    background: #0f0f1e;
    border: 2px solid #0f3460;
    border-radius: 4px;
    display: block;
    width: 100%;
    height: 100%;
}

#overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    width: 100%;
    height: 100%;
}

#progress-bar {
    height: 26px;
    background: #16213e;
    border-radius: 13px;
    overflow: hidden;
    position: relative;
}

#progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #e94560, #ffd700);
    transition: width 0.4s ease-out;
}

.star-marker {
    position: absolute;
    top: 0;
    width: 22px;
    height: 26px;
    line-height: 26px;
    text-align: center;
    font-size: 13px;
    color: #ffd700;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 2;
    text-shadow: 0 0 4px rgba(0,0,0,0.8);
}

.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    animation: fade-in 0.3s;
    padding: 16px;
}

.modal-content {
    background: linear-gradient(135deg, #16213e, #0f3460);
    border: 2px solid #e94560;
    border-radius: 16px;
    padding: clamp(20px, 5vw, 40px);
    text-align: center;
    min-width: min(320px, 90vw);
    max-width: 90vw;
    box-shadow: 0 0 60px rgba(233, 69, 96, 0.4);
}

.modal-content.level-complete {
    border-color: #ffd700;
    box-shadow: 0 0 60px rgba(255, 215, 0, 0.4);
}

.modal-content h2 {
    color: #ffd700;
    font-size: clamp(22px, 6vw, 32px);
    letter-spacing: 4px;
    margin-bottom: 12px;
}

.modal-content .sub {
    color: #ccc;
    margin-bottom: 20px;
}

.modal-content .stars {
    font-size: clamp(32px, 10vw, 48px);
    margin: 20px 0;
    letter-spacing: 8px;
}

.final-score .label {
    font-size: 11px;
    color: #888;
    letter-spacing: 2px;
}

.final-score .value {
    font-size: clamp(26px, 8vw, 36px);
    color: #ffd700;
    font-weight: 700;
    margin-bottom: 24px;
}

.modal-content button {
    display: block;
    width: 100%;
    padding: 14px;
    margin: 8px 0;
    background: #e94560;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 2px;
    cursor: pointer;
    transition: transform 0.1s;
}

.modal-content button:hover:not(:disabled) {
    transform: scale(1.03);
}

.modal-content button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 480px) {
    body { padding: 6px; }
    #hud { padding: 6px 10px; min-height: 48px; }
    .hud-stat { padding: 0 3px; min-width: 40px; }
}
