/* ============================================
   GLOBAL STYLES - Shared across all pages
   ============================================ */

/* Color Variables */
:root {
    --bg-primary: #d94fd4;
    --bg-secondary: #12161b;
    --bg-tertiary: #1f2630;
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --accent-blue: #2a6df5;
    --accent-blue-active: #1e5ae0;
    --accent-green: #3ddc97;
    --accent-green-active: #2fc882;
}

/* Disable pinch + double-tap zoom; allow pan/scroll (see static/js/gestures.js). */
#app,
#app * {
    touch-action: pan-x pan-y;
    -ms-touch-action: pan-x pan-y;
}

/* Common Background */
.page-background {
    background: var(--bg-primary);
}

/* Common Logo Styles */
.app-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    /*margin-bottom: clamp(4px, 1.5vh, 12px);*/
}

.app-logo img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 50vw;
}

/* Common Typography */
.page-title {
    color: var(--text-primary);
    font-family: 'Bungee', sans-serif;
    font-weight: 400;
    line-height: 1.2;
    margin: 0;
}

.page-title-large {
    font-size: clamp(56px, 16vw, 68px);
    width: 100%;
    max-width: none;
    line-height: 1;
}

.page-title-medium {
    font-size: 10vw;
    line-height: 1;
    margin: 0;
    flex-shrink: 1;
    text-align: center;
    width: 90vw;
    max-width: 90vw;
    white-space: nowrap;
}

.page-title-small {
    font-size: clamp(24px, 6vw, 32px);
    line-height: 1;
    margin: 0;
    flex-shrink: 1;
    text-align: center;
    width: 90vw;
    max-width: 90vw;
}
.page-subtitle {
    color: var(--text-primary);
    font-family: 'Zain', sans-serif;
    font-size: clamp(16px, 4.5vw, 20px);
    line-height: 1.5;
    margin: 0;
}

.page-text {
    color: var(--text-secondary);
    font-family: 'Zain', sans-serif;
    font-size: clamp(16px, 4vw, 18px);
    line-height: 1.6;
    margin: 0;
}

/* Common Button Base Styles */
.btn {
    padding: 18px 32px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: clamp(18px, 10vw, 40px);
    cursor: pointer;
    min-height: 56px;
    touch-action: manipulation;
    display: inline-block;
    text-align: center;
    box-shadow: 0 3px 6px 0 rgba(0, 0, 0, 0.3);
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Primary Blue Button */
.btn-primary {
    background: var(--accent-blue);
    color: white;
}

/* Primary Green Button */
.btn-success {
    background: var(--accent-green);
    color: var(--bg-primary);
}

/* Reusable footer CTA button (text + icon on right) */
.btn-footer {
    width: 100%;
    max-width: 82vw;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    column-gap: 10px;
    border: none;
    border-radius: 9999px;
    min-height: 80px;
    padding-top: 22px;
    padding-bottom: 22px;
    padding-left: clamp(16px, 4vw, 28px);
    padding-right: clamp(16px, 4vw, 28px);
    cursor: pointer;
    touch-action: manipulation;
    position: relative;
    font-family: 'Bungee', sans-serif;
    font-size: clamp(18px, 10vw, 52px);
    color: #ffffff;
    box-shadow: 0 3px 6px 0 rgba(0, 0, 0, 0.3);
    font-weight: 400;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.btn-label {
    display: block;
    line-height: 1;
    text-align: center;
    flex: 1 1 auto;
    min-width: 0;
    padding-left: 5px;
    padding-right: 5px;
}

.btn-icon {
    width: 58px;
    height: 58px;
    flex-shrink: 0;
    object-fit: contain;
    display: block;
    margin: 0;
}

/* Short viewports (e.g. 320x568): slightly shorter footer button */
@media (max-height: 658px) {
    .btn-footer {
        min-height: 75px;
        padding-top: 15px;
        padding-bottom: 15px;
    }
}

/* Small phones (e.g. 320x568): full width, icon pinned right so label does not overlap */
@media (max-width: 360px) {
    .btn-footer {
        max-width: 100%;
        padding-left: 14px;
        padding-right: 48px;
        column-gap: 0;
        justify-content: center;
    }

    .btn-label {
        padding-left: 0;
        padding-right: 0;
    }

    .btn-icon {
        position: absolute;
        right: 6px;
        top: 50%;
        transform: translateY(-50%);
    }
}

/* Press-down feedback for interactive buttons */
.btn:active:not(:disabled),
.btn-footer:active:not(:disabled),
.shoot-btn:active:not(:disabled),
button:active:not(:disabled) {
    transform: translateY(4px) scale(0.98);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
}

/* Native switch overlay for iOS haptic on direct tap */
.haptic-overlay-host {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.haptic-overlay-host:has(> img) {
    line-height: 0;
}

.haptic-switch {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
    clip-path: inset(0 round 12px);
    z-index: 5;
}

.haptic-switch-fallback,
.haptic-switch-fallback-label {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    pointer-events: none;
}

/* Button Sizes */
.btn-large {
    padding: 18px 40px;
    font-size: clamp(18px, 4.5vw, 20px);
    min-width: 200px;
}

.btn-full {
    width: 100%;
}

.btn-full-mobile {
    width: calc(100% - 48px);
    max-width: 500px;
}

@media (max-width: 768px) {
    .btn-full-mobile {
        width: calc(100% - 32px);
    }
}

@media (max-width: 360px) {
    .btn-full-mobile {
        width: calc(100% - 24px);
    }
}

/* Safe Area Support Helper */
.safe-area-padding {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.safe-area-top {
    padding-top: max(20px, env(safe-area-inset-top));
}

.safe-area-bottom {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

/* Common Container Styles */
.page-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.page-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Loading Spinner Animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-loading {
    position: relative;
    color: transparent;
}

.btn-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(11, 14, 17, 0.25);
    border-top-color: var(--bg-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Colour Dot (for displaying player colors) */
.colour-dot {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    vertical-align: middle;
    background: transparent;
}

/* Landscape: blur app content and show rotate-to-portrait overlay */
.rotate-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
        env(safe-area-inset-bottom) env(safe-area-inset-left);
    pointer-events: auto;
}

.rotate-overlay.is-visible {
    display: flex;
}

.rotate-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    background: rgba(11, 14, 17, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.rotate-overlay__image {
    position: relative;
    z-index: 2;
    max-width: min(70vw, 320px);
    max-height: min(50vh, 320px);
    width: auto;
    height: auto;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

body.is-landscape #app,
body.is-landscape .end-page {
    filter: blur(12px);
    -webkit-filter: blur(12px);
    pointer-events: none;
    user-select: none;
}

/* Responsive Utilities */
@media (max-width: 480px) {
    .page-title-medium {
        font-size: 10vw;
    }
    
    .page-subtitle {
        font-size: clamp(14px, 3.5vw, 16px);
    }
    
    .page-text {
        font-size: clamp(14px, 3.5vw, 16px);
    }
}
