* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Arial', sans-serif;
    background-color: #333;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
    max-width: 600px; /* Limit width for desktop testing */
    margin: 0 auto;
    background-color: #fff;
}

.page {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.hidden {
    display: none !important;
}

/* Start Page */
#start-page {
    background-color: #f0f0f0;
    background-image: url('image/bg1.png'); /* Default bg */
    background-size: cover;
    background-position: center;
    /* justify-content: flex-start; */ /* Removed to allow bottom alignment */
    /* padding-top: 30px; */
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Space between title/char and menu */
    align-items: center;
    transition: background-image 1s ease-in-out; /* Smooth transition */
}

.start-content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    flex: 1;
    position: relative;
    bottom: -60px;
}

.floating-char {
    width: 150px; /* Adjust size as needed */
    height: auto;
    margin-top: 20px;
    animation: floatChar 2s ease-in-out infinite alternate;
}

@keyframes floatChar {
    from { transform: translateY(0); }
    to { transform: translateY(-20px); }
}

.home-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    z-index: 20;
    background: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent);
}

.coin-display {
    display: flex;
    align-items: center;
    background: rgba(0,0,0,0.6);
    padding: 5px 10px;
    border-radius: 20px;
    color: #FFC107;
    font-weight: bold;
    font-size: 16px;
}

.coin-icon {
    /* width: 24px; */
    height: 26px;
    margin-right: 5px;
}

.wallet-btn {
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 5px;
}

.wallet-icon-img {
    /* width: 16px; */
    height: 26px;
    filter: invert(1); /* Make it white if icon is black, or use a white icon */
}

.game-title {
    font-size: 32px;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin-bottom: 30px;
    margin-top: 20px;
}

.game-logo {
    max-width: 40%;
    height: auto;
    margin-bottom: 10px;
}

/* NEW MENU LAYOUT */
.home-menu {
    width: 90%; 
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 60px; /* Space from bottom */
    z-index: 10;
}

.menu-main-grid {
    display: flex;
    width: 100%;
    height: 220px; /* Fixed height for the block area */
    gap: 15px;
}

.menu-right-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%;
}

.btn-black {
    background-color: #000;
    color: #ff9800;
    border: none;
    border-radius: 5px; /* Square-ish */
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    transition: transform 0.1s;
    cursor: pointer;
}

.btn-black:active {
    transform: scale(0.98);
}

.big-block-btn {
    flex: 1;
    height: 100%;
    font-size: 28px;
    letter-spacing: 2px;
    background: url('image/btnbg1.png') no-repeat center center;
    background-size: 100% 100%;
   
}

.small-block-btn {
    flex: 1;
    width: 100%;
    font-size: 18px;
    background: url('image/btnbg3.png') no-repeat center center;
    background-size: 100% 100%;
}

.menu-bottom-row {
    display: flex;
    width: 100%;
    justify-content: space-between;
    padding: 0 5px;
}

.text-link-btn {
    background: transparent;
    border: none;
    color: #fff; /* Changed from orange to white */
    font-size: 18px;
    /* font-weight: bold; */
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    gap: 8px; /* Added gap for icon */
}
/* END NEW MENU LAYOUT */

.menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
}

.menu-row {
    display: flex;
    gap: 10px;
    width: 100%;
}

.menu-row .btn {
    flex: 1;
}

.btn {
    /* Base btn styles if needed, but overridden by specific classes */
    /* padding: 15px 0; */
    /* width: 100%; */
    /* font-size: 18px; */
    /* border-radius: 30px; */
}
#btn-action ,#tutorial-start-btn,#do-withdraw-btn{
    /* Base btn styles if needed, but overridden by specific classes */
    padding: 15px 0;
    width: 100%;
    font-size: 18px;
    border-radius: 30px;
    color: #fff;
    border: none;
}
.primary-btn {
    background-color: #ff9800;
    font-size: 24px;
    padding: 15px 40px;
    width: 100%;
    border-radius: 30px;
    color: white;
    border: none;
}

.secondary-btn {
    background-color: #4CAF50; 
    font-size: 16px;
    padding: 10px 0;
    width: 100%;
    border-radius: 30px;
    color: white;
    border: none;
}

/* Select Page */
#select-page {
    background-color: #2d2d2d;
    padding: 20px;
}

.select-title {
    margin-bottom: 30px;
    font-size: 28px;
    color: #fff;
}

.character-list {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 20px;
}
.character-list h3{
    color: #ff9800 !important;
}

.char-option {
    width: 100%;
    height: 140px; /* Increased height */
    background: url('image/btnbg2.png') no-repeat center center;
    background-size: 100% 100%;
    border-radius: 15px;
    display: flex;
    align-items: center;
    padding: 10px 20px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    border-left: 10px solid var(--theme-color);
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: visible;
}

/* Right alignment for even items */
.char-option:nth-child(even) {
    flex-direction: row-reverse;
    border-left: none;
    border-right: 10px solid var(--theme-color);
    text-align: right;
}

.char-option:active {
    transform: scale(0.98);
}

.char-option.selected {
    background-color: #fff;
    box-shadow: 0 0 0 3px var(--theme-color);
}

/* Replaced .char-img-box img with .char-img */
.char-img {
    width: 150px; /* 2x larger roughly */
    height: 200px;
    object-fit: contain;
    margin: 0 10px;
    flex-shrink: 0;
}

.char-info {
    flex: 1;
    /* text-align is handled by parent for right aligned items */
}

.char-info h3 {
    font-size: 22px;
    margin-bottom: 5px;
    color: #333;
}

.char-info p {
    font-size: 16px;
    color: #888;
}

/* Floating Score */
.floating-score {
    position: absolute;
    font-size: 24px; /* Slightly smaller for multi-line */
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
    pointer-events: none;
    z-index: 20;
    animation: floatUp 1s forwards;
    text-align: center;
    line-height: 1.2;
}

@keyframes floatUp {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    50% { transform: translateY(-50px) scale(1.2); opacity: 1; }
    100% { transform: translateY(-100px) scale(1); opacity: 0; }
}

/* Game Page */
#game-page {
    display: block; /* Override flex */
    overflow: hidden;
}

#background-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('image/bg1.png');
    background-size: cover;
    background-position: center;
    z-index: 0;
    transition: background-image 1s ease-in-out;
}

#game-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: flex;
}

.lane {
    flex: 1;
    height: 100%;
    /* border-right: 1px dashed rgba(255, 255, 255, 0.3); */
    position: relative;
}

.lane:last-child {
    /* border-right: none; */
}

#player {
    position: absolute;
    bottom: 120px; /* Above controls */
    width: 33.33%; /* 1/3 of screen width */
    height: 100px;
    z-index: 5;
    display: flex;
    justify-content: center;
    align-items: flex-end; /* Align to bottom */
    transition: left 0.2s ease-out; /* Smooth lane switching */
}

#player img {
    height: 230%;
    width: auto;
    max-width: none;
}

.item {
    position: absolute;
    width: 80%;
    left: 10%;
    height: auto;
}

/* UI Layer */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through to controls */
}

#score-board {
    position: absolute;
    top: 20px;
    left: 20px;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 2px #000;
    line-height: 1.2;
}

.score-label {
    font-size: 16px;
    font-weight: normal;
}

#score {
    font-size: 32px;
}

#progress-container {
    position: absolute;
    top: 20px;
    right: 60px; /* Space for exit button */
    width: 150px;
    height: 20px;
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    overflow: hidden;
    /* border: 2px solid #fff; */ /* Removed border */
    display: flex;
    align-items: center;
    justify-content: center;
}

#progress-bar {
    width: 0%;
    height: 100%;
    background-color: #ff8a00; /* Changed to #ff8a00 */
    transition: width 0.1s linear;
    position: absolute;
    left: 0;
    top: 0;
    z-index: 1;
}

#timer-display {
    position: relative;
    z-index: 2;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.8);
}

.icon-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0,0,0,0.5);
    /* border: 2px solid #fff; */ /* Removed border */
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    padding: 0;
    z-index: 100; /* Ensure it's on top */
    border: none; /* Explicitly remove default border */
    pointer-events: auto; /* Re-enable clicks blocked by parent #ui-layer */
}

/* Controls */
#controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    height: 80px;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    padding: 0 40px;
}

.control-btn {
    width: 80px;
    height: 80px;
    background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black */
    border-radius: 50%; /* Circle */
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.control-btn img {
    width: 60%;
    height: 60%;
    object-fit: contain;
}

/* Modal */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: transparent;
    text-align: center;
    width: 80%;
    padding: 20px;
}

.modal-content img {
    max-width: 100%;
    max-height: 60vh;
    margin-bottom: 20px;
    border-radius: 10px;
}

/* Result Page */
#result-page {
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 50;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
