@font-face {
    font-family: 'Motorway';
    src: url('motorway.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

:root {
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.85);
    --accent-emerald: #10b981;
    --accent-rose: #f43f5e;
    --accent-gold: #f59e0b;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --radius-lg: 16px;
    --radius-md: 10px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #0284c7;
    background-image: 
        radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.4) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(125, 211, 252, 0.4) 0px, transparent 50%);
    color: var(--text-primary);
}

.app-root {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Rotate Device Prompt for Mobile Portrait Mode */
.rotate-device-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(12px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    text-align: center;
    padding: 24px;
}

@media screen and (orientation: portrait) and (max-width: 900px) {
    .rotate-device-overlay {
        display: none !important;
    }
}

.rotate-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 32px;
    border-radius: var(--radius-lg);
    max-width: 320px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
}

.phone-icon {
    font-size: 56px;
    margin-bottom: 16px;
    animation: rotatePulse 2s infinite ease-in-out;
}

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

.rotate-card h2 {
    font-size: 18px;
    font-weight: 800;
    color: var(--accent-gold);
    margin-bottom: 8px;
}

.rotate-card p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000 !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.screen.hidden {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Main Menu Screen with 800x600 logo.png Background Floor */
.main-menu-container {
    position: relative;
    width: min(96vw, calc(96vh * (800 / 600)));
    height: min(96vh, calc(96vw * (600 / 800)));
    aspect-ratio: 800 / 600;
    max-width: 800px;
    max-height: 600px;
    background: url('assets/logo.png') no-repeat center center / contain;
    box-sizing: border-box;
    z-index: 10001 !important;
    pointer-events: auto !important;
}

.btn-menu-img {
    position: absolute;
    width: 29.375%; /* 235 / 800 */
    height: 39.1667%; /* 235 / 600 */
    cursor: pointer;
    touch-action: manipulation !important;
    pointer-events: auto !important;
    transition: transform 0.18s ease-in-out, filter 0.18s ease-in-out;
    user-select: none;
    -webkit-user-drag: none;
}

.btn-menu-img:hover {
    transform: scale(1.06);
    filter: drop-shadow(0 0 16px rgba(255, 255, 255, 0.45));
}

.btn-menu-img:active {
    transform: scale(0.95);
}

.btn-menu-pc {
    left: 18.75%; /* 150 / 800 */
    top: 56.6667%; /* 340 / 600 */
}

.btn-menu-pvp {
    left: 52.0%; /* 416 / 800 */
    top: 56.6667%; /* 340 / 600 */
}

/* Submode Screen with 800x600 logo.png Background Floor */
.submode-container {
    position: relative;
    width: min(96vw, calc(96vh * (800 / 600)));
    height: min(96vh, calc(96vw * (600 / 800)));
    aspect-ratio: 800 / 600;
    max-width: 800px;
    max-height: 600px;
    background: url('assets/logo.png') no-repeat center center / contain;
    box-sizing: border-box;
    z-index: 10001 !important;
    pointer-events: auto !important;
}

.btn-menu-img,
.btn-submode-img {
    position: absolute;
    cursor: pointer;
    touch-action: manipulation !important;
    pointer-events: auto !important;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.3s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.btn-menu-img:hover,
.btn-submode-img:hover {
    transform: scale(1.15);
    filter: brightness(1.15) drop-shadow(0 0 20px rgba(255, 255, 255, 0.6));
}

.btn-menu-img:active,
.btn-submode-img:active {
    transform: scale(0.92);
}

.btn-submode-back {
    left: 4.0%; /* 32 / 800 (Moved to Top-Left Corner) */
    top: 3.3333%; /* 20 / 600 */
    width: 6.5%; /* 52 / 800 (Smaller Compact Size) */
    height: 8.5%; /* 51 / 600 */
}

.btn-submode-king {
    left: 7.0%; /* 56 / 800 */
    top: 56.6667%; /* 340 / 600 */
    width: 27.375%; /* 219 / 800 */
    height: 38.0%; /* 228 / 600 */
}

.btn-submode-score {
    left: 36.5%; /* 292 / 800 */
    top: 56.6667%; /* 340 / 600 */
    width: 27.25%; /* 218 / 800 */
    height: 37.1667%; /* 223 / 600 */
}

.btn-submode-time {
    left: 67.25%; /* 538 / 800 */
    top: 56.6667%; /* 340 / 600 */
    width: 27.375%; /* 219 / 800 */
    height: 37.1667%; /* 223 / 600 */
}

.menu-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 36px 28px;
    border-radius: var(--radius-lg);
    text-align: center;
    backdrop-filter: blur(16px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    max-width: 440px;
    width: 90%;
    z-index: 10001 !important;
    pointer-events: auto !important;
}

.game-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
}

.logo-piece {
    width: 56px;
    height: 56px;
    filter: drop-shadow(0 0 12px rgba(16, 185, 129, 0.6));
}

.game-logo h1 {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.version {
    font-size: 11px;
    color: var(--accent-emerald);
    background: rgba(16, 185, 129, 0.15);
    padding: 3px 10px;
    border-radius: 12px;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn {
    touch-action: manipulation !important;
    pointer-events: auto !important;
}

.btn * {
    pointer-events: none !important;
}

.btn-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation !important;
    pointer-events: auto !important;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-menu:hover {
    transform: scale(1.08) !important;
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--accent-emerald);
    box-shadow: 0 10px 25px -5px rgba(16, 185, 129, 0.4), 0 0 16px rgba(16, 185, 129, 0.3) !important;
}

.btn-menu:active {
    transform: scale(0.95) !important;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
}

.btn-menu img {
    height: 26px;
}

/* Guide Screen Modal */
.guide-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 32px;
    border-radius: var(--radius-lg);
    text-align: center;
    backdrop-filter: blur(16px);
    max-width: 480px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
}

.guide-card h2 {
    font-size: 22px;
    margin-bottom: 20px;
    color: var(--accent-gold);
}

.guide-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.guide-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: var(--radius-md);
    text-align: left;
}

.guide-item img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.guide-item p {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.4;
}

/* Game Screen HUD */
.hud-bar {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap !important;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 51px !important;
    min-height: 51px !important;
    max-height: 51px !important;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0 16px;
    border-radius: 30px;
    backdrop-filter: blur(12px);
    z-index: 10;
    max-width: 95vw;
    box-sizing: border-box !important;
    white-space: nowrap !important;
    overflow: hidden;
}

.team-score {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 14px;
}

.score-icon {
    width: 24px;
    height: 24px;
}

.green-score .score-val {
    color: var(--accent-emerald);
    font-size: 18px;
}

.red-score .score-val {
    color: var(--accent-rose);
    font-size: 18px;
}

.turn-status {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-gold);
    background: rgba(245, 158, 11, 0.15);
    padding: 4px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

.btn-menu-return {
    padding: 4px 10px;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
}

/* Responsive Canvas Container with Vibrant Light Blue WebGL Liquid Background Floor */
.canvas-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#liquidCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    z-index: 1;
    background: linear-gradient(135deg, #0284c7 0%, #38bdf8 50%, #7dd3fc 100%);
    pointer-events: none;
}

#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    touch-action: none !important;
    pointer-events: auto !important;
    z-index: 2;
}

/* Change Board Button 7px Above Board Top-Right Edge (X=640, Y=53px) */
.btn-board-change {
    position: absolute;
    left: 80.0%; /* 640 / 800 (Aligned to board right edge) */
    top: 8.8333%; /* 53 / 600 (Exactly 7px above Y=60 board top edge) */
    transform: translateX(-100%) translateY(-100%);
    width: 3.5%; /* Base size set to hover scale size */
    height: 3.2%;
    object-fit: contain;
    z-index: 10;
    cursor: pointer;
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.28s ease !important;
    pointer-events: auto !important;
}

.btn-board-change:hover {
    transform: translateX(-100%) translateY(-100%) scale(1.20) !important;
    filter: brightness(1.25) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.5)) !important;
}

.btn-board-change:active {
    transform: translateX(-100%) translateY(-100%) scale(0.88) !important;
}

/* Back Button 5px Below Game Board (Half-Size: 5.0% width, 545px top) */
.btn-board-back {
    position: absolute;
    left: 50%;
    top: 90.8333%; /* 545 / 600 (Exactly 5px below board bottom edge Y=540) */
    transform: translateX(-50%);
    width: 5.0%; /* 40 / 800 (Half Size) */
    height: 4.5%; /* 27 / 600 */
    object-fit: contain;
    z-index: 10;
    cursor: pointer;
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.28s ease !important;
    pointer-events: auto !important;
}

.btn-board-back:hover {
    transform: translateX(-50%) scale(1.20) !important;
    filter: brightness(1.25) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.5)) !important;
}

.btn-board-back:active {
    transform: translateX(-50%) scale(0.92);
}

/* Universal Screen Overlay Animation */
.screen:not(.hidden) {
    animation: screenOverlayFade 0.4s ease-out forwards;
}

@keyframes screenOverlayFade {
    0% {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    100% {
        opacity: 1;
        backdrop-filter: blur(16px);
    }
}

/* Universal 800x600 Menu Container Spring Bounce Entrance */
.screen:not(.hidden) .main-menu-container,
.screen:not(.hidden) .submode-container,
.screen:not(.hidden) .win-container {
    animation: menuContainerSpringPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 0.05s both;
}

@keyframes menuContainerSpringPop {
    0% {
        opacity: 0;
        transform: scale(0.65) translateY(45px);
        filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0));
    }
    100% {
        opacity: 1;
        transform: scale(1.0) translateY(0px);
        filter: drop-shadow(0 25px 50px rgba(0, 0, 0, 0.75));
    }
}

/* Main Menu & Submode Screen Spring Pop Containers */

@keyframes buttonSpringPop {
    0% {
        opacity: 0;
        transform: scale(0.4) translateY(25px);
    }
    100% {
        opacity: 1;
        transform: scale(1.0) translateY(0px);
    }
}

/* Win Screen Inner Elements Staggered Pop */
.screen#win-screen:not(.hidden) .win-king-img {
    animation: winKingPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

@keyframes winKingPop {
    0% {
        opacity: 0;
        transform: scale(0.3) rotate(-20deg);
    }
    100% {
        opacity: 1;
        transform: scale(1.0) rotate(0deg);
    }
}

.screen#win-screen:not(.hidden) #win-title,
.screen#win-screen:not(.hidden) #win-subtitle {
    animation: winTextFadeUp 0.45s ease-out 0.35s both;
}

@keyframes winTextFadeUp {
    0% {
        opacity: 0;
        transform: translateY(18px);
    }
    100% {
        opacity: 1;
        transform: translateY(0px);
    }
}

.screen#win-screen:not(.hidden) .score-summary-box {
    animation: winBoxPop 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.45s both;
}

@keyframes winBoxPop {
    0% {
        opacity: 0;
        transform: scale(0.92) translateY(15px);
    }
    100% {
        opacity: 1;
        transform: scale(1.0) translateY(0px);
    }
}

/* Win Screen with 800x600 sonuc.png Background Floor */
.win-container {
    position: relative;
    width: min(96vw, calc(96vh * (800 / 600)));
    height: min(96vh, calc(96vw * (600 / 800)));
    aspect-ratio: 800 / 600;
    max-width: 800px;
    max-height: 600px;
    background: url('assets/sonuc.png') no-repeat center center / contain;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001 !important;
    pointer-events: auto !important;
}

.btn-win-back {
    left: 87.5%; /* 700 / 800 */
    top: 3.3333%; /* 20 / 600 */
    width: 10.0%; /* 80 / 800 */
    height: 13.0%; /* 78 / 600 */
    z-index: 10002;
}

/* OyunKuzusu Logo Button at Bottom Center of Win Screen (37% + 26% + 37% = 100% Cross-Browser Center) */
.btn-win-logo {
    position: absolute;
    left: 37.0%;
    width: 26.0%; /* 208 / 800 */
    bottom: 3.5%;
    max-height: 12.0%; /* 72 / 600 */
    object-fit: contain;
    z-index: 10002;
    cursor: pointer;
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.28s ease !important;
    pointer-events: auto !important;
}

.btn-win-logo:hover {
    transform: scale(1.10) !important;
    filter: brightness(1.2) drop-shadow(0 6px 16px rgba(0, 0, 0, 0.5)) !important;
}

.btn-win-logo:active {
    transform: scale(0.92) !important;
}

.win-content-centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 92%;
    max-width: 550px;
    transform: scale(1.15);
}

.win-king-img {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.win-content-centered h1 {
    font-size: 28px;
    margin-bottom: 6px;
}

.win-content-centered p {
    color: var(--text-muted);
    font-size: 16px;
    margin-bottom: 12px;
}

.btn-primary {
    background: var(--accent-emerald);
    color: #000;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}

/* Rule Submode Selection Menu */
.rule-card {
    max-width: 480px;
    width: 92%;
}

.submode-title {
    font-size: 13px;
    color: var(--accent-gold);
    background: rgba(245, 158, 11, 0.15);
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 600;
}

.btn-rule {
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
    padding: 12px 16px;
}

.rule-icon {
    font-size: 28px;
    line-height: 1;
}

.rule-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.rule-name {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
}

.rule-desc {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

/* HUD Center Group & Timer Badge */
.hud-center-group {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 8px;
    white-space: nowrap !important;
    flex-shrink: 0;
}

.timer-badge {
    font-size: 13px;
    font-weight: 800;
    color: #f43f5e;
    background: rgba(244, 63, 94, 0.18);
    border: 1px solid rgba(244, 63, 94, 0.4);
    padding: 4px 10px;
    border-radius: 14px;
    letter-spacing: 0.5px;
    box-shadow: 0 0 12px rgba(244, 63, 94, 0.3);
    white-space: nowrap !important;
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .hud-bar {
        gap: 6px;
        padding: 0 10px;
        top: 6px;
    }
    .team-score {
        font-size: 12px;
        gap: 4px;
    }
    .score-icon {
        width: 20px;
        height: 20px;
    }
    .turn-status {
        font-size: 11px;
        padding: 3px 6px;
    }
    .timer-badge {
        font-size: 11px;
        padding: 3px 6px;
    }
    .btn-menu-return {
        padding: 3px 6px;
        font-size: 10px;
    }
}

/* Detailed Score Summary Box on Win Screen */
.detailed-win-card {
    max-width: 460px;
    width: 92%;
}

.score-summary-box {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 16px 0 20px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.summary-header {
    font-size: 13px;
    font-weight: 800;
    color: var(--accent-gold);
    letter-spacing: 0.8px;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 8px;
}

.summary-mode {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--text-muted);
}

.summary-mode strong {
    color: #ffffff;
}

.summary-grid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(0, 0, 0, 0.3);
    padding: 14px 16px;
    border-radius: var(--radius-md);
}

.summary-team {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.team-title {
    font-size: 14px;
    font-weight: 700;
}

.red-team-box .team-title {
    color: #f43f5e;
}

.green-team-box .team-title {
    color: #10b981;
}

.team-score-num {
    font-size: 22px;
    font-weight: 800;
    color: #ffffff;
}

.summary-vs {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-muted);
}

.summary-footer {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-emerald);
    background: rgba(16, 185, 129, 0.12);
    padding: 8px 12px;
    border-radius: var(--radius-md);
}

