:root {
    --game-width: 100vw;
    --game-height: 100%;
    --gold-border: rgba(232, 199, 134, 0.7);
    --gold-text: #f5dda9;
    --bg-panel: rgba(22, 11, 2, 0.98);
    --tg-safe-top: env(safe-area-inset-top, 0px);
    --editor-safe-gap: 16px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    position: fixed;
    inset: 0;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
}

#unity-container {
    position: fixed;
    left: 50%;
    top: 0;
    bottom: 0;
    width: var(--game-width);
    height: var(--game-height);
    transform: translateX(-50%);
    overflow: hidden;
    background: #000;
}

#unity-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100% !important;
    height: 100% !important;
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    background: #000;
    touch-action: none;
}

/* DOM-поле Unity сразу показывается под safe area. */

body > div:has(> input:not([type="hidden"])),
body > div:has(> textarea) {
    position: fixed !important;
    left: 14px !important;
    right: 14px !important;
    top: calc(var(--tg-safe-top) + var(--editor-safe-gap)) !important;
    bottom: auto !important;
    width: auto !important;
    height: 54px !important;
    min-width: 0 !important;
    min-height: 54px !important;
    margin: 0 !important;
    padding: 5px !important;
    display: flex !important;
    align-items: center !important;

    background: var(--bg-panel) !important;
    border: 1.5px solid var(--gold-border) !important;
    border-radius: 14px !important;

    z-index: 1000000 !important;
    pointer-events: auto !important;
    transform: none !important;

    opacity: 1 !important;
    visibility: visible !important;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.78),
    0 12px 36px rgba(0, 0, 0, 0.95),
    0 0 16px rgba(232, 199, 134, 0.3) !important;
    backdrop-filter: blur(5px) !important;
}

body > div:has(> input:not([type="hidden"])) > input,
body > div:has(> textarea) > textarea {
    position: relative !important;
    flex: 1 1 auto !important;
    height: 100% !important;
    width: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 14px !important;

    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    color: var(--gold-text) !important;
    caret-color: #f0d594 !important;
    font-size: 16px !important;
    font-family: inherit !important;

    -webkit-user-select: text !important;
    user-select: text !important;
    pointer-events: auto !important;
}

body > div:has(> input:not([type="hidden"])) > button,
body > div:has(> textarea) > button {
    position: relative !important;
    flex: 0 0 auto !important;
    height: 44px !important;
    min-width: 82px !important;
    margin: 0 0 0 8px !important;
    padding: 0 16px !important;

    border: 0 !important;
    border-radius: 9px !important;
    background: linear-gradient(90deg, #a67631 0%, #d7ac64 42%, #f0d594 100%) !important;
    color: #100802 !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45) !important;

    cursor: pointer !important;
    pointer-events: auto !important;
}

body > div:has(> input:not([type="hidden"])) > button:active,
body > div:has(> textarea) > button:active {
    filter: brightness(0.9) !important;
    transform: scale(0.98) !important;
}

/* =================================================
   PROBES
   ================================================= */

#safe-area-probe {
    position: fixed;
    visibility: hidden;
    pointer-events: none;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

/* =================================================
   LANDSCAPE BLOCKER
   ================================================= */

#orientation-blocker {
    position: fixed;
    inset: 0;
    z-index: 9999999;
    display: none;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 42%, #543006 0%, #281503 40%, #100802 75%, #000 100%);
    color: #f5dda9;
    text-align: center;
    padding: 20px;
}

@media screen and (orientation: landscape) and (max-height: 560px) {
    #orientation-blocker {
        display: flex !important;
    }
}

.orientation-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.phone-rotate-icon {
    font-size: 48px;
    animation: rotatePhone 2s ease-in-out infinite;
}

.orientation-title {
    font-size: 20px;
    font-weight: 700;
    color: #f5dda9;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.orientation-desc {
    font-size: 14px;
    color: rgba(245, 221, 169, 0.7);
    max-width: 260px;
    line-height: 1.4;
}

@keyframes rotatePhone {
    0%, 20% { transform: rotate(90deg); }
    50%, 70% { transform: rotate(0deg); }
    100% { transform: rotate(90deg); }
}
