/*
Theme Name: Shibawork
Description: 
Version: 1.0
Author: Iwami
*/

/* Reset and Core Setup */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: white;
    font-family: Arial, sans-serif;
}

.viewport-container {
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Content wrapper for maintaining aspect ratio */
.content-wrapper {
    width: 100vw;
    height: 100vh;
    max-width: min(calc(814 * min(100vw/814, 100vh/1343)), 814px);
    max-height: min(calc(1343 * min(100vw/814, 100vh/1343)), 1343px);
    position: relative;
    margin: 0 auto;
}


/* Main Game Interface Container */
.game-interface {
    width: 100vw;
    height: 100vh;
    max-width: min(calc(814 * min(100vw/814, 100vh/1343)), 814px);
    position: relative;
    overflow: hidden;
    margin: 0 auto;
}

/* Background Layer */
.background-layer {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: min(calc(814 * min(100vw/814, 100vh/1343)), 814px);
    height: min(calc(1343 * min(100vw/814, 100vh/1343)), 1343px);
    z-index: 1;
}

.main-bg {
    width: min(calc(1066 * min(100vw/814, 100vh/1343)), 1066px);
    height: min(calc(1759 * min(100vw/814, 100vh/1343)), 1759px);
    position: absolute;
    top: max(calc(-208 * min(100vw/814, 100vh/1343)), -208px);
    left: max(calc(-126 * min(100vw/814, 100vh/1343)), -126px);
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Big-big image for high-resolution displays and modern devices */
@media screen and (min-resolution: 2dppx), 
       screen and (-webkit-min-device-pixel-ratio: 2),
       screen and (min-width: 375px),
       screen and (min-height: 700px) {
    .main-bg {
        content: url('assets/images/home/home-bg-big-big.jpg');
        width: min(calc(1798 * min(100vw/814, 100vh/1343)), 1798px);
        height: min(calc(2969 * min(100vw/814, 100vh/1343)), 2969px);
        top: max(calc(-813 * min(100vw/814, 100vh/1343)), -813px);
        left: max(calc(-492 * min(100vw/814, 100vh/1343)), -492px);
    }
    
    .game-footer {
        max-width: none !important;
        width: 100vw !important;
    }
}

/* Force big-big image on all modern mobile devices */
@media screen and (max-width: 1024px) and (min-width: 320px) and (orientation: portrait) {
    .main-bg {
        content: url('assets/images/home/home-bg-big-big.jpg') !important;
        width: min(calc(1798 * min(100vw/814, 100vh/1343)), 1798px) !important;
        height: min(calc(2969 * min(100vw/814, 100vh/1343)), 2969px) !important;
        top: max(calc(-813 * min(100vw/814, 100vh/1343)), -813px) !important;
        left: max(calc(-492 * min(100vw/814, 100vh/1343)), -492px) !important;
    }
}

/* Mobile menu optimization */
@media screen and (max-width: 768px) {
    .side-menu {
        width: 100vw;
        right: -100vw;
        background: rgba(0, 0, 0, 0.5);
    }
    
    .side-menu.open {
        right: 0;
    }
    
    .side-menu-bg {
        width: 80vw;
        max-width: 400px;
        height: 100dvh;
        margin-left: auto;
    }
    
    .menu-content {
        width: 80vw;
        max-width: 400px;
        margin-left: auto;
        padding: 20px;
        box-sizing: border-box;
    }
}

/* Iframe Modal */
.iframe-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 1000;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
}

.modal-content {
    position: relative;
    width: 98vw;
    height: 98vh;
    margin: 1vh auto;
    background: white;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-close {
    position: absolute;
    top: 10px;
    left: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.9);
}

#modalIframe {
    width: 100%;
    height: 100%;
    border: none;
}

.iframe-modal.show {
    display: block;
}

/* Mobile modal adjustments */
@media screen and (max-width: 768px) {
    .modal-content {
        width: 96vw;
        height: 94vh;
        height: 94dvh;
        margin: 3vh auto;
    }
    
    .modal-close {
        top: 15px;
        left: 15px;
        width: 50px;
        height: 50px;
        font-size: 28px;
    }
}

/* Road Layer */
.road-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.road {
    position: absolute;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.road-1 {
    top: min(calc(466 * min(100vw/814, 100vh/1343)), 466px);
    left: min(calc(342 * min(100vw/814, 100vh/1343)), 342px);
    width: min(calc(219 * min(100vw/814, 100vh/1343)), 219px);
    height: min(calc(165 * min(100vw/814, 100vh/1343)), 165px);
}

.road-2 {
    top: min(calc(630 * min(100vw/814, 100vh/1343)), 630px);
    left: min(calc(153 * min(100vw/814, 100vh/1343)), 153px);
    width: min(calc(266 * min(100vw/814, 100vh/1343)), 266px);
    height: min(calc(243 * min(100vw/814, 100vh/1343)), 243px);
}

/* Building Labels Layer */
.building-labels-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
}

.building-button {
    position: absolute;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 10;
}

.building-button:hover {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

.label-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Building Label Button Positions - Fine-tuned from Figma coordinates */
.machine-factory-button {
    left: min(calc(410 * min(100vw/814, 100vh/1343)), 410px);
    top: min(calc(363 * min(100vw/814, 100vh/1343)), 363px);
    width: min(calc(359 * min(100vw/814, 100vh/1343)), 359px);
    height: auto;
}

.first-casting-button {
    left: min(calc(0 * min(100vw/814, 100vh/1343)), 0px);
    top: min(calc(543 * min(100vw/814, 100vh/1343)), 543px);
    width: min(calc(359 * min(100vw/814, 100vh/1343)), 359px);
    height: auto;
}

.second-casting-button {
    left: min(calc(269 * min(100vw/814, 100vh/1343)), 269px);
    top: min(calc(856 * min(100vw/814, 100vh/1343)), 856px);
    width: min(calc(359 * min(100vw/814, 100vh/1343)), 359px);
    height: auto;
}

.port-button {
    left: min(calc(0 * min(100vw/814, 100vh/1343)), 0px);
    bottom: min(calc(89 * min(100vw/814, 100vh/1343)), 89px);
    width: min(calc(239 * min(100vw/814, 100vh/1343)), 239px);
    height: auto;
}

/* UI Layer */
.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.ui-layer > * {
    pointer-events: auto;
}

/* Header */
.game-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: min(calc(120 * min(100vw/814, 100vh/1343)), 120px);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: min(calc(16 * min(100vw/814, 100vh/1343)), 16px) min(calc(32 * min(100vw/814, 100vh/1343)), 32px);
}

.quest-section {
    position: absolute;
    left: min(calc(20 * min(100vw/814, 100vh/1343)), 20px);
    top: min(calc(15 * min(100vw/814, 100vh/1343)), 15px);
}

.quest-section .quest-cleared {
    width: min(calc(423 * min(100vw/814, 100vh/1343)), 423px);
    height: auto;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.user-section {
    position: absolute;
    right: min(calc(20 * min(100vw/814, 100vh/1343)), 20px);
    top: min(calc(8 * min(100vw/814, 100vh/1343)), 8px);
}

.user-section .username {
    width: min(calc(240 * min(100vw/814, 100vh/1343)), 240px);
    height: auto;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Footer */
.game-footer {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: min(calc(1066 * min(100vw / 814, 100vh / 1343)), 1066px);
    height: min(calc(94 * min(100vw/814, 100vh/1343)), 94px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: min(calc(16 * min(100vw/814, 100vh/1343)), 16px) min(calc(32 * min(100vw/814, 100vh/1343)), 32px);
    background: white;
    z-index: 15;
}

.logo-section .logo {
    width: min(calc(340 * min(100vw/814, 100vh/1343)), 340px);
    height: auto;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.menu-section .menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.menu-section .menu-icon {
    width: min(calc(56 * min(100vw/814, 100vh/1343)), 56px);
    height: auto;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Side Menu */
.side-menu {
    position: fixed;
    top: 0;
    right: min(calc(-606 * min(100vw/814, 100vh/1343)), -606px);
    width: min(calc(606 * min(100vw/814, 100vh/1343)), 606px);
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    z-index: 20;
    transition: right 0.3s ease-in-out;
}

.side-menu.open {
    right: 0;
}

.menu-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.side-menu-bg {
    width: min(calc(606 * min(100vw/814, 100vh/1343)), 606px);
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    background: #864410;
    border-left: min(calc(8 * min(100vw/814, 100vh/1343)), 8px) solid #000000;
    border-top: min(calc(8 * min(100vw/814, 100vh/1343)), 8px) solid #000000;
    border-bottom: min(calc(8 * min(100vw/814, 100vh/1343)), 8px) solid #000000;
    border-top-left-radius: min(calc(20 * min(100vw/814, 100vh/1343)), 20px);
    border-bottom-left-radius: min(calc(20 * min(100vw/814, 100vh/1343)), 20px);
}

.menu-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    padding: min(calc(64 * min(100vw/814, 100vh/1343)), 64px) min(calc(16 * min(100vw/814, 100vh/1343)), 16px);
}

.menu-title {
    color: #FFD700;
    font-size: min(calc(46 * min(100vw/814, 100vh/1343)), 46px);
    font-family: 'Inter', Arial, sans-serif;
    font-weight: 600;
    text-align: center;
    margin: 0 0 min(calc(40 * min(100vw/814, 100vh/1343)), 40px) 0;
}

.menu-close {
    position: absolute;
    bottom: min(calc(30 * min(100vw/814, 100vh/1343)), 30px);
    right: min(calc(30 * min(100vw/814, 100vh/1343)), 30px);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.close-icon {
    width: min(calc(40 * min(100vw/814, 100vh/1343)), 40px);
    height: auto;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.menu-items {
    display: flex;
    flex-direction: column;
    gap: min(calc(20 * min(100vw/814, 100vh/1343)), 20px);
    margin-top: min(calc(20 * min(100vw/814, 100vh/1343)), 20px);
}

.menu-item {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.menu-item:hover {
    opacity: 0.8;
}

.menu-item-image {
    width: 100%;
    height: auto;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Building Button Hover Effects */
.building-button:hover .label-image {
    opacity: 0.9;
    transition: opacity 0.2s ease;
}

/* Image Rendering Optimization */
img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: -moz-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    user-select: none;
    -webkit-user-drag: none;
}

/* Disable text selection */
.game-interface {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Button styles */
button {
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}