/* ══════════════════════════════════════════════════════════
   Water Flow — High-Fidelity 3D Gameplay Screen Stylesheet
   Matches Casual Underwater Reference Screenshot 1-to-1:
   - Underwater Coral Reef Background (innerpage.png)
   - Ornate 3-Column Carved Wooden Plaque Header
   - Moves Counter with Golden Brackets » 0 «
   - Center Plaque: Crown + Level Pill + 3 Gold Stars + Cyan Fluid Gauge
   - Blocked (Red) / Flowing (Green) with 3D Glowing LED Gem
   - Chunky 3D Tactile Buttons: Undo (Cyan), Hint (Gold + 25 Coins), Restart (Green)
   ══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@700;800;900&family=Outfit:wght@600;700;800;900&display=swap');

/* ────────────────────────────────────────
   Page Container & Background
   ──────────────────────────────────────── */

.game-page {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100%;
    width: 100%;
    padding-top: max(var(--safe-top, 0px), 2px);
    padding-bottom: max(var(--safe-bottom, 0px), 2px);
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden;
    max-width: 480px;
    margin: 0 auto;

    /* Transparent so global hardware-accelerated background video shows through */
    background: transparent;
}

/* ────────────────────────────────────────
   Background Video (innervideo.mp4)
   ──────────────────────────────────────── */

.game-bg-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    pointer-events: none;
    z-index: 0;
}

/* Subtle ambient underwater light rays effect */
.game-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 15%, rgba(56, 189, 248, 0.18) 0%, rgba(7, 25, 44, 0.25) 55%, rgba(4, 14, 26, 0.6) 100%);
    pointer-events: none;
    z-index: 1;
}

/* Floating underwater bubbles animation */
.game-page::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 18% 85%, rgba(255, 255, 255, 0.12) 2px, transparent 3px),
        radial-gradient(circle at 82% 70%, rgba(255, 255, 255, 0.15) 3px, transparent 4px),
        radial-gradient(circle at 35% 45%, rgba(255, 255, 255, 0.1) 2px, transparent 3px),
        radial-gradient(circle at 65% 30%, rgba(255, 255, 255, 0.14) 2.5px, transparent 3.5px);
    pointer-events: none;
    z-index: 1;
    animation: floatingBubblesAmbient 12s linear infinite alternate;
}

@keyframes floatingBubblesAmbient {
    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(-16px);
    }
}

/* ────────────────────────────────────────
   Discreet Top Utility Bar (Back, Coins, Pause)
   ──────────────────────────────────────── */

.game__top-bar {
    position: relative;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px 2px 14px;
    height: 40px;
    flex-shrink: 0;
}

.game__util-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(28, 59, 94, 0.95) 0%, rgba(14, 34, 56, 0.98) 100%);
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-top: 1.5px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 3px 0 #071526, 0 4px 8px rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #BAE6FD;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, color 0.12s ease;
    padding: 0;
}

.game__util-btn:hover {
    color: #FFFFFF;
    border-color: #38BDF8;
}

.game__util-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #071526, 0 2px 4px rgba(0, 0, 0, 0.4);
}

.game__util-btn svg {
    width: 16px;
    height: 16px;
}

/* Bold Clean Centered Level (Reference Style) */
.game__top-level {
    font-family: 'Outfit', sans-serif;
    font-size: 19px;
    font-weight: 900;
    letter-spacing: 0.5px;
    color: #FFFFFF;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9), 0 0 12px rgba(56, 189, 248, 0.4);
    display: flex;
    align-items: center;
    gap: 5px;
    user-select: none;
}

.game__top-level span {
    color: #FEF08A;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.95), 0 0 12px rgba(245, 158, 11, 0.7);
}

.game__top-right-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.game__coins-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    background: linear-gradient(180deg, #A16207 0%, #713F12 100%);
    border: 1.5px solid #FDE047;
    border-top: 1.5px solid #FEF08A;
    border-radius: 9999px;
    box-shadow: 0 2px 0 #451A03, 0 3px 8px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    cursor: pointer;
    color: #FEF08A;
    transition: transform 0.12s ease, filter 0.12s ease;
}

.game__coins-pill:hover {
    filter: brightness(1.1);
}

.game__coins-pill:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #451A03;
}

.coins-pill__icon {
    font-size: 13px;
    line-height: 1;
}

.coins-pill__val {
    font-family: var(--font-mono, 'Outfit', monospace);
    font-size: 12px;
    font-weight: 900;
    color: #FFFBEB;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    letter-spacing: 0.5px;
}

/* ────────────────────────────────────────
   Minimized 3-Widget Status Header
   (Matches Reference Design + Our Rich Theme Colors)
   - Left Box: Moves Capsule [ ↗ 1 ]
   - Center Plaque: 3 Stars Rating Meter [ ★ ★ ★ ] + Micro Liquid Gauge
   - Right Box: Status Capsule [ 🔴 Blocked ]
   ──────────────────────────────────────── */

.game__wood-header {
    position: relative;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 14px 4px 14px;
    margin: 0 auto;
    width: 100%;
    max-width: 380px;
    flex-shrink: 0;
}

/* Minimized Side Wooden Boxes (Left: Moves, Right: Blocked/Flowing) */
.wood-header__box {
    height: 32px;
    min-height: unset;
    flex: 0 0 auto;
    min-width: 66px;
    padding: 0 10px;
    border-radius: 9999px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;

    /* Rich carved wood panel gradient matching our theme */
    background: linear-gradient(180deg, #78350F 0%, #542407 50%, #381604 100%);
    border: 2px solid #D97706;
    border-top: 2px solid #FDE68A;
    border-bottom: 2px solid #270D02;
    box-shadow:
        0 3px 0 #270D02,
        0 4px 8px rgba(0, 0, 0, 0.55),
        inset 0 1px 1px rgba(254, 240, 138, 0.35);
}

/* Moves Icon & Value (Left Box) */
.wood-header__moves-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}

.wood-header__moves-num {
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 900;
    color: #FFFFFF;
    text-shadow: 0 1.5px 3px rgba(0, 0, 0, 0.9);
    min-width: 12px;
    text-align: center;
    line-height: 1;
}

/* Center Box (3 Stars Rating + Micro Progress Line) */
.wood-header__center-plaque {
    height: 32px;
    min-height: unset;
    flex: 0 0 auto;
    padding: 3px 12px;
    border-radius: 9999px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;

    /* Rich carved wood gradient */
    background: linear-gradient(180deg, #78350F 0%, #542407 50%, #381604 100%);
    border: 2px solid #D97706;
    border-top: 2px solid #FDE68A;
    border-bottom: 2px solid #270D02;
    box-shadow:
        0 3px 0 #270D02,
        0 4px 8px rgba(0, 0, 0, 0.55),
        inset 0 1px 1px rgba(254, 240, 138, 0.35);
}

/* 3 Golden Stars Rating */
.wood-header__stars {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    line-height: 1;
}

.wood-star {
    font-size: 14px;
    line-height: 1;
    color: #FBBF24;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
    transition: all 0.25s ease;
}

.wood-star--mid {
    font-size: 16px;
    transform: translateY(-1px);
}

.wood-star.active {
    color: #FBBF24;
    text-shadow: 0 0 8px #F59E0B, 0 0 12px rgba(251, 191, 36, 0.7);
}

.wood-star.dim {
    color: #451A03;
    opacity: 0.45;
    text-shadow: none;
}

/* Micro Fluid Progress Bar Groove */
.wood-header__progress-wrap {
    width: 44px;
}

.wood-header__progress-groove {
    position: relative;
    height: 3px;
    border-radius: 9999px;
    background: #1C0A02;
    overflow: hidden;
}

.wood-header__progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #38BDF8 0%, #00B4D8 100%);
    box-shadow: 0 0 6px #38BDF8;
    border-radius: 9999px;
    transition: width 0.4s ease;
}

/* Right Status Box: Blocked (Red) / Flowing (Green) */
.wood-header__status-text {
    font-family: 'Outfit', sans-serif;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
    line-height: 1;
}

.status-text--blocked {
    color: #EF4444;
}

.status-text--flowing {
    color: #22C55E;
}

/* 3D Glowing LED Jewel Socket */
.wood-header__led-socket {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #180902;
    border: 1.5px solid #78350F;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
}

.wood-header__led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.led--blocked {
    background: radial-gradient(circle at 35% 35%, #FCA5A5 0%, #EF4444 50%, #7F1D1D 100%);
    box-shadow: 0 0 6px #EF4444, 0 0 10px rgba(239, 68, 68, 0.6);
}

.led--flowing {
    background: radial-gradient(circle at 35% 35%, #86EFAC 0%, #22C55E 50%, #064E3B 100%);
    box-shadow: 0 0 6px #22C55E, 0 0 12px rgba(34, 197, 94, 0.7);
}

/* ────────────────────────────────────────
   Canvas Viewport Wrapper
   ──────────────────────────────────────── */

.game__canvas-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    touch-action: none;
    padding: 2px 4px;
    z-index: 10;
}

#gameCanvas {
    display: block;
    cursor: grab;
    touch-action: none;
    outline: none;
    max-width: 100%;
    max-height: 100%;
}

#gameCanvas:active {
    cursor: grabbing;
}

/* ────────────────────────────────────────
   Floating Zoom & Pan HUD Overlay
   ──────────────────────────────────────── */

.game__zoom-hud {
    position: absolute;
    top: 8px;
    right: 12px;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(7, 21, 38, 0.95);
    border: 1px solid rgba(0, 180, 216, 0.35);
    border-top: 1.5px solid rgba(255, 255, 255, 0.3);
    border-radius: 9999px;
    padding: 4px 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55), 0 0 12px rgba(0, 180, 216, 0.2);
    opacity: 0;
    transform: translateY(-8px) scale(0.92);
    pointer-events: none;
    transition: opacity 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
    user-select: none;
    -webkit-user-select: none;
}

.game__zoom-hud--visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.game__zoom-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(0, 180, 216, 0.25);
    color: #ADE8F4;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.game__zoom-btn:hover {
    background: rgba(0, 180, 216, 0.25);
    color: #FFFFFF;
    border-color: #00B4D8;
}

.game__zoom-btn:active {
    transform: scale(0.92);
}

.game__zoom-text {
    font-family: var(--font-mono, monospace);
    font-size: 11px;
    font-weight: 800;
    color: #00B4D8;
    letter-spacing: 0.5px;
    padding: 0 4px;
    text-shadow: 0 0 8px rgba(0, 180, 216, 0.5);
}

.game__zoom-reset {
    font-size: 10px;
    font-weight: 700;
    color: #E2E8F0;
    background: linear-gradient(180deg, #1C3B5E 0%, #0E2238 100%);
    border: 1px solid rgba(0, 180, 216, 0.35);
    border-radius: 9999px;
    padding: 3px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
    transition: all 0.15s ease;
}

/* ────────────────────────────────────────
   Compact Minimized 3D Bottom Control Buttons
   - Left: Undo (Cyan 3D Button)
   - Center: Hint (Golden 3D Button + 25 Coins Pill)
   - Right: Restart (Green 3D Button)
   ──────────────────────────────────────── */

.game__bottom-controls {
    display: none !important;
}

/* Base Ultra-Minimized 3D Button */
.btn-3d {
    position: relative;
    flex: 1;
    max-width: 66px;
    height: 44px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.btn-3d__body {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding-top: 1px;
    transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.12s ease;
    overflow: hidden;
}

/* Glossy top sheen highlight overlay */
.btn-3d__sheen {
    position: absolute;
    top: 0;
    left: 8%;
    right: 8%;
    height: 38%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.65) 0%, rgba(255, 255, 255, 0.08) 100%);
    border-radius: 10px 10px 16px 16px;
    pointer-events: none;
}

.btn-3d__icon {
    width: 17px;
    height: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
    transition: transform 0.2s ease;
    z-index: 2;
}

.btn-3d__icon svg {
    width: 100%;
    height: 100%;
}

.btn-3d__label {
    font-family: 'Outfit', sans-serif;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.2px;
    color: #FFFFFF;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    z-index: 2;
    line-height: 1.1;
}

/* ── 1. Undo Button (Cyan 3D) ── */
.btn-3d--undo .btn-3d__body {
    background: linear-gradient(180deg, #38BDF8 0%, #0284C7 50%, #0369A1 100%);
    border: 2px solid #BAE6FD;
    border-top: 2.5px solid #FFFFFF;
    border-bottom: 2.5px solid #075985;
    box-shadow:
        0 3px 0 #0C4A6E,
        0 4px 8px rgba(0, 0, 0, 0.5),
        inset 0 -1.5px 3px rgba(0, 0, 0, 0.4);
}

.btn-3d--undo:hover:not(:disabled) .btn-3d__body {
    filter: brightness(1.08);
}

.btn-3d--undo:active:not(:disabled) .btn-3d__body {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #0C4A6E, 0 1px 3px rgba(0, 0, 0, 0.4);
}

.btn-3d--undo:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    filter: grayscale(0.5);
}

.btn-3d--undo:disabled .btn-3d__body {
    transform: translateY(1.5px);
    box-shadow: 0 1.5px 0 #0C4A6E;
}

/* ── 2. Hint Button (Golden 3D with 25 Coins floating badge) ── */
.btn-3d--hint {
    height: 46px;
    max-width: 72px;
}

.btn-3d--hint .btn-3d__body {
    background: linear-gradient(180deg, #FDE047 0%, #F59E0B 50%, #D97706 100%);
    border: 2px solid #FEF08A;
    border-top: 2.5px solid #FFFFFF;
    border-bottom: 2.5px solid #92400E;
    box-shadow:
        0 3px 0 #78350F,
        0 4px 8px rgba(0, 0, 0, 0.5),
        0 0 12px rgba(245, 158, 11, 0.25),
        inset 0 -1.5px 3px rgba(0, 0, 0, 0.4);
}

/* Compact side wings */
.btn-3d--hint::before,
.btn-3d--hint::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 4px;
    height: 10px;
    background: #D97706;
    border: 1px solid #FEF08A;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    z-index: 1;
}

.btn-3d--hint::before {
    left: -2px;
    transform: translateY(-50%);
}

.btn-3d--hint::after {
    right: -2px;
    transform: translateY(-50%);
}

.btn-3d--hint:hover .btn-3d__body {
    filter: brightness(1.08);
}

.btn-3d--hint:active .btn-3d__body {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #78350F, 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Floating 25 Coins Badge on Top of Hint */
.btn-3d__floating-badge {
    position: absolute;
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 2.5px;
    padding: 1px 6px;
    border-radius: 9999px;
    background: linear-gradient(180deg, #78350F 0%, #451A03 100%);
    border: 1px solid #FDE047;
    box-shadow: 0 1.5px 0 #270D02, 0 2px 4px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

.badge__coin {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.badge__text {
    font-family: 'Outfit', sans-serif;
    font-size: 8px;
    font-weight: 800;
    color: #FFFBEB;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
    line-height: 1;
}

/* ── 3. Restart Button (Green 3D) ── */
.btn-3d--restart .btn-3d__body {
    background: linear-gradient(180deg, #86EFAC 0%, #22C55E 50%, #15803D 100%);
    border: 2px solid #DCFCE7;
    border-top: 2.5px solid #FFFFFF;
    border-bottom: 2.5px solid #14532D;
    box-shadow:
        0 3px 0 #052E16,
        0 4px 8px rgba(0, 0, 0, 0.5),
        inset 0 -1.5px 3px rgba(0, 0, 0, 0.4);
}

.btn-3d--restart:hover .btn-3d__body {
    filter: brightness(1.08);
}

.btn-3d--restart:hover .btn-3d__icon svg {
    transform: rotate(-45deg);
}

.btn-3d--restart:active .btn-3d__body {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #052E16, 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* ────────────────────────────────────────
   Fallback Error View
   ──────────────────────────────────────── */

.game-error-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 24px;
    text-align: center;
    gap: 16px;
    position: relative;
    z-index: 20;
}

.game-error-view__text {
    font-size: 16px;
    color: #BAE6FD;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.game-error-view__btn {
    padding: 10px 24px;
    border-radius: 14px;
    background: linear-gradient(180deg, #0284C7 0%, #0369A1 100%);
    border: 2px solid #38BDF8;
    color: #FFFFFF;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 0 #0C4A6E;
}