/* ==========================================================================
   kingdom.css — 3D Sihirli Krallık arayüzü (HUD, D-Pad, gardırop, inşa)
   ========================================================================== */

.kingdom-screen {
    background: #80D8FF;
    overflow: hidden;
}

/* 3D WebGL katmanı */
#canvas-3d-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    z-index: 1;
}

#canvas-3d-container canvas { display: block; }

/* ---------------------------------------------------------------- ÜST HUD */
.kingdom-top-hud {
    position: absolute;
    top: max(14px, env(safe-area-inset-top));
    left: max(16px, env(safe-area-inset-left));
    right: max(16px, env(safe-area-inset-right));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    pointer-events: none;
    z-index: 50;
}

.hud-left,
.hud-right {
    display: flex;
    align-items: center;
    gap: 9px;
    pointer-events: auto;
}

.hud-right { flex-wrap: wrap; justify-content: flex-end; }

.princess-title-badge {
    background: linear-gradient(135deg, #FFE082, #FFB300);
    color: #4E2C00;
    padding: 9px 20px;
    border-radius: 50px;
    font-size: 18px;
    font-weight: 900;
    box-shadow: 0 6px 18px rgba(255, 179, 0, 0.42);
    display: flex;
    align-items: center;
    gap: 8px;
    border: 3px solid #FFFFFF;
}

.hud-btn {
    border: 2.5px solid rgba(255, 255, 255, 0.95);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #3E3350;
    padding: 9px 16px;
    border-radius: 50px;
    font-size: 14.5px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(60, 40, 90, 0.16);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.1s ease, background 0.15s ease;
}

.hud-btn:active {
    transform: scale(0.92);
    background: #FFF9C4;
}

.hud-home-btn {
    width: 46px;
    height: 46px;
    padding: 0;
    justify-content: center;
    font-size: 19px;
}

.garden-exit-btn {
    background: linear-gradient(135deg, #FF4081, #FF80AB) !important;
    color: #FFFFFF !important;
    font-weight: 900 !important;
    box-shadow: 0 4px 16px rgba(255, 64, 129, 0.45) !important;
}

/* ------------------------------------------------------- ARABA KONTROLLERİ */
.driving-hud {
    position: absolute;
    bottom: max(100px, env(safe-area-inset-bottom));
    right: max(18px, env(safe-area-inset-right));
    display: flex;
    gap: 12px;
    z-index: 55;
    pointer-events: auto;
}

.driving-btn {
    border: 3.5px solid #FFFFFF;
    border-radius: 24px;
    padding: 10px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s ease;
}

.driving-btn:active { transform: scale(0.9); }
.driving-btn.honk-btn { background: linear-gradient(135deg, #FFD600, #FF9100); }
.driving-btn.exit-btn { background: linear-gradient(135deg, #FF1744, #D50000); }
.d-icon { font-size: 30px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2)); }
.d-label { font-size: 12.5px; font-weight: 900; color: #FFFFFF; margin-top: 2px; }

/* ------------------------------------------------------------ ZIPLAMA DÜĞMESİ */
.jump-fab {
    position: absolute;
    right: max(22px, env(safe-area-inset-right));
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + 104px);
    width: 72px !important;
    height: 72px !important;
    border-radius: 50% !important;
    z-index: 50;
    pointer-events: auto;
}

/* Sol başparmak joystick'i: dinlenirken köşede soluk durur, dokununca parmağın altına gelir */
#virtual-joystick-base.resting { opacity: 0.55; }

.dpad-btn {
    width: 62px;
    height: 62px;
    border: 3.5px solid #FFFFFF;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 20px rgba(60, 40, 90, 0.2);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.08s ease, background 0.1s ease;
    user-select: none;
    touch-action: none;
}

.dpad-btn:active,
.dpad-btn.pressed {
    transform: scale(0.88);
    background: #FFE082;
    border-color: #FFB300;
}

.dpad-btn.jump-btn {
    background: linear-gradient(135deg, #FF4081, #FF80AB);
    color: #FFFFFF;
    font-size: 30px;
    box-shadow: 0 8px 22px rgba(255, 64, 129, 0.45);
}

.dpad-btn.jump-btn:active,
.dpad-btn.jump-btn.pressed {
    background: #D81B60;
    transform: scale(0.88);
}

.dpad-btn.jump-btn.ride-exit {
    flex-direction: column;
    gap: 1px;
    font-size: 21px;
    line-height: 1;
    background: linear-gradient(135deg, #FF7043, #F4511E);
}
.ride-exit-label { font-size: 12px; font-weight: 900; }

/* --------------------------------------------------------- SAĞ ALT EYLEMLER */
.kingdom-bottom-hud {
    position: absolute;
    bottom: max(16px, env(safe-area-inset-bottom));
    right: max(18px, env(safe-area-inset-right));
    display: flex;
    gap: 12px;
    pointer-events: auto;
    z-index: 50;
}

.kingdom-action-btn {
    border: 4px solid #FFFFFF;
    border-radius: 24px;
    padding: 11px 17px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(60, 40, 90, 0.22);
    transition: transform 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.kingdom-action-btn:active { transform: scale(0.91); }

.action-icon {
    font-size: 33px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.18));
}

.action-label {
    font-size: 12.5px;
    font-weight: 900;
    color: #FFFFFF;
    margin-top: 3px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.wand-btn { background: linear-gradient(135deg, #FF4081, #E040FB); }
.dress-btn { background: linear-gradient(135deg, #00E5FF, #2979FF); }
.zoom-btn { background: linear-gradient(135deg, #FFD600, #FF9100); }

/* -------------------------------------------------------------- İNŞA ÇEKMECESİ */
.builder-drawer {
    position: absolute;
    bottom: -200px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 4px solid #FFFFFF;
    border-radius: 30px;
    padding: 16px 24px;
    box-shadow: 0 16px 40px rgba(60, 40, 90, 0.26);
    z-index: 60;
    transition: bottom 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.builder-drawer.active { bottom: max(100px, env(safe-area-inset-bottom)); }

.drawer-title {
    font-size: 16px;
    font-weight: 900;
    color: #6A1B9A;
    margin-bottom: 12px;
}

.builder-items-row { display: flex; gap: 14px; }

.builder-item-btn {
    background: #FFF0F5;
    border: 3.5px solid #FF80AB;
    border-radius: 20px;
    padding: 11px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: transform 0.12s ease;
}

.builder-item-btn:active { transform: scale(0.9); }
.b-icon { font-size: 34px; }
.b-name { font-size: 12px; font-weight: 800; color: #4A3B5C; margin-top: 4px; }

/* ------------------------------------------------------------------ GARDIROP */
.wardrobe-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30, 20, 45, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.wardrobe-modal-card {
    background: #FFFFFF;
    width: 100%;
    max-width: 440px;
    border-radius: 32px;
    padding: 24px;
    box-shadow: 0 22px 48px rgba(0,0,0,0.3);
    border: 4px solid #FF80AB;
}

.w-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.w-modal-header h3 { font-size: 22px; font-weight: 900; color: #D81B60; }

.w-modal-close {
    background: #F1EBF7;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    font-size: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5C4A72;
}

.w-section-label { font-size: 14.5px; font-weight: 800; color: #5C4A72; margin-bottom: 10px; }

.w-color-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.w-color-dot,
.w-dress-dot {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 4px solid #FFFFFF;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
    cursor: pointer;
    transition: transform 0.12s ease;
}

.w-color-dot:active,
.w-dress-dot:active { transform: scale(1.18); }

.toggle-wings-btn {
    background: linear-gradient(135deg, #00E5FF, #00B0FF);
    color: #FFFFFF;
    padding: 13px 28px;
    border-radius: 50px;
    font-size: 15.5px;
    font-weight: 900;
    box-shadow: 0 6px 18px rgba(0,176,255,0.45);
    cursor: pointer;
}

/* Yüzen emoji (partikül motoru tarafından kullanılır) */
.studio-floating-emoji {
    position: fixed;
    font-size: 42px;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    animation: floatUpFade 0.9s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes floatUpFade {
    0%   { opacity: 1; transform: translate(-50%, -50%) scale(0.6); }
    50%  { transform: translate(-50%, -100%) scale(1.3); }
    100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}

/* ------------------------------------------------------------ DUYARLILIK */
@media (max-width: 900px) {
    .hud-label { display: none; }
    .hud-btn { padding: 0; width: 46px; height: 46px; justify-content: center; font-size: 19px; }
    .princess-title-badge { font-size: 16px; padding: 8px 16px; }
    .kingdom-action-btn { padding: 10px 13px; border-radius: 21px; }
    .action-icon { font-size: 29px; }
    .action-label { font-size: 11px; }
    .dpad-btn { width: 58px; height: 58px; border-radius: 20px; }
}

@media (max-width: 620px) {
    .princess-title-badge { display: none; }
    .kingdom-bottom-hud { gap: 8px; }
    .kingdom-action-btn { padding: 9px 11px; }
    .action-icon { font-size: 25px; }
    .action-label { display: none; }
    .dpad-btn { width: 54px; height: 54px; font-size: 21px; }
    .builder-items-row { gap: 8px; }
    .builder-item-btn { padding: 9px 10px; }
    .b-name { font-size: 10px; }
}

@media (max-height: 520px) and (orientation: landscape) {
    .dpad-btn { width: 50px; height: 50px; }
    .action-icon { font-size: 24px; }
    .kingdom-action-btn { padding: 8px 12px; }
}

/* ---------- Görüntü katmanı: sinematik kenar gölgesi ve "dokun" baloncuğu ---------- */
#canvas-3d-container::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at 50% 45%, transparent 58%, rgba(20, 10, 40, 0.28) 100%);
}

.world-prompt {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 40;
    width: 84px;
    height: 84px;
    margin: -96px 0 0 -42px;
    border-radius: 50%;
    border: 4px solid #fff;
    background: radial-gradient(circle at 35% 30%, #fff, #FFE3EE 70%);
    box-shadow: 0 12px 26px rgba(60, 20, 80, 0.35), 0 0 0 6px rgba(255, 255, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    will-change: transform;
}

.world-prompt::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -14px;
    margin-left: -10px;
    border: 10px solid transparent;
    border-top: 12px solid #fff;
    border-bottom: 0;
}

.world-prompt .wp-icon {
    font-size: 42px;
    line-height: 1;
    animation: wpBob 1.1s ease-in-out infinite;
}

.world-prompt .wp-hand {
    position: absolute;
    right: -18px;
    bottom: -14px;
    font-size: 34px;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
    animation: wpTap 1.1s ease-in-out infinite;
}

.world-prompt.show { animation: wpIn 0.45s cubic-bezier(0.22, 1.4, 0.36, 1); }
.world-prompt.pop .wp-icon { animation: wpPop 0.4s ease; }

@keyframes wpIn { from { scale: 0.2; opacity: 0; } to { scale: 1; opacity: 1; } }
@keyframes wpBob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -5px; } }
@keyframes wpTap { 0%, 100% { translate: 0 0; scale: 1; } 50% { translate: -4px -6px; scale: 0.9; } }
@keyframes wpPop { 0% { scale: 1; } 40% { scale: 1.4; } 100% { scale: 1; } }

/* 3D model kullanılırken prensesin saç/elbise rengi değişmez: gardıropta yalnızca kanat seçeneği */
.wardrobe-modal-overlay.model-mode .w-section-label,
.wardrobe-modal-overlay.model-mode .w-color-row { display: none; }

/* --- Yıldız Avı sayacı (kingdom-extras.js) --- */
.kx-yildiz-sayaci {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 74px);
    left: calc(env(safe-area-inset-left, 0px) + 16px);
    z-index: 20;
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 8px 18px 8px 12px;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.94);
    border: 3px solid #FFE082;
    box-shadow: 0 6px 18px rgba(255, 179, 0, 0.35);
    color: #6B4100;
    font-weight: 900;
    pointer-events: none;
}

.kx-yildiz-sayaci .kx-yildiz { font-size: 26px; align-self: center; filter: drop-shadow(0 2px 3px rgba(255, 160, 0, 0.5)); }
.kx-yildiz-sayaci b { font-size: 26px; line-height: 1; }
.kx-yildiz-sayaci small { font-size: 16px; opacity: 0.7; }
.kx-yildiz-sayaci.kx-pop { animation: kxPop 0.6s cubic-bezier(0.22, 1.6, 0.36, 1); }
.kx-yildiz-sayaci.kx-tamam { background: linear-gradient(135deg, #FFE082, #FFB300); border-color: #fff; }

@keyframes kxPop {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.35) rotate(-4deg); }
    100% { transform: scale(1); }
}

@media (max-width: 640px) {
    .kx-yildiz-sayaci { top: calc(env(safe-area-inset-top, 0px) + 64px); padding: 6px 14px 6px 10px; }
    .kx-yildiz-sayaci .kx-yildiz, .kx-yildiz-sayaci b { font-size: 21px; }
}
