/* ========================================
   Planet Leap - Styles
   ======================================== */

@font-face {
    font-family: 'Montserrat';
    src: url('assets/fonts/Montserrat-Bold.otf') format('opentype');
    font-weight: bold;
}

@font-face {
    font-family: 'WebServeroff';
    src: url('assets/fonts/Web_Serveroff.otf') format('opentype');
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0D0816;
    font-family: 'WebServeroff', 'Arial Black', sans-serif;
    user-select: none;
    -webkit-user-select: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    overflow: hidden;
    /* Lock to 9:16 portrait aspect ratio, fit within viewport */
    width: min(100vw, 56.25vh);   /* 9/16 = 0.5625 */
    height: min(100vh, 177.78vw); /* 16/9 = 1.7778 */
    max-width: 500px;
    max-height: 889px;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* Screen base */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.screen > * {
    pointer-events: auto;
}

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

.screen.hidden > * {
    pointer-events: none !important;
}

.overlay {
    background: rgba(13, 8, 22, 0.85);
    justify-content: center;
    align-items: center;
}

/* Loading Screen */
#loading-screen {
    background: #0D0816;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.loading-text {
    color: rgba(255, 255, 255, 0.5);
    font-size: 18px;
    letter-spacing: 2px;
}

/* Warmup Screen */
#warmup-screen {
    justify-content: space-between;
    align-items: center;
    padding: 40px 20px 30px;
    pointer-events: auto;
}

.warmup-top {
    display: flex;
    justify-content: center;
    margin-top: 40px;
}

#logo {
    width: 70%;
    max-width: 300px;
    image-rendering: auto;
}

.warmup-center {
    display: flex;
    justify-content: center;
}

.tap-to-play {
    color: rgba(255, 255, 255, 0.6);
    font-size: 16px;
    letter-spacing: 4px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.warmup-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.warmup-buttons {
    display: flex;
    gap: 20px;
}

/* Money Display */
.money-display {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #FFD700;
    font-size: 20px;
    font-weight: bold;
}

.money-display.small {
    font-size: 14px;
    gap: 4px;
}

.coin-icon {
    width: 24px;
    height: 24px;
    image-rendering: pixelated;
}

.money-display.small .coin-icon {
    width: 16px;
    height: 16px;
}

/* HUD */
#hud-screen {
    padding: 15px;
    pointer-events: none;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.score-container {
    pointer-events: none;
}

#score-label {
    color: white;
    font-size: 32px;
    font-weight: bold;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.hud-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.best-score {
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
    padding: 15px;
    pointer-events: none;
}

/* Buttons */
.game-btn {
    border: none;
    cursor: pointer;
    font-family: 'WebServeroff', sans-serif;
    font-weight: bold;
    transition: transform 0.1s ease, opacity 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.game-btn:active {
    transform: scale(0.9);
}

.circle-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.circle-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.icon-btn {
    width: 36px;
    height: 36px;
    background: none;
    padding: 0;
    opacity: 0.6;
}

.icon-btn img {
    width: 100%;
    height: 100%;
    filter: brightness(0) invert(1);
}

.primary-btn {
    background: #4FC3F7;
    color: #0D0816;
    font-size: 18px;
    padding: 14px 40px;
    border-radius: 30px;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.primary-btn .coin-icon {
    width: 20px;
    height: 20px;
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 14px;
    padding: 10px 30px;
    border-radius: 25px;
    letter-spacing: 1px;
}

/* Dead Screen */
.dead-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.dead-score {
    color: white;
    font-size: 48px;
    font-weight: bold;
}

.dead-score .km {
    font-size: 24px;
    opacity: 0.6;
}

.dead-best {
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
}

.dead-new-record {
    color: #FFD700;
    font-size: 16px;
    letter-spacing: 3px;
    animation: pulse 1s ease-in-out infinite;
}

.dead-buttons {
    display: flex;
    gap: 20px;
    margin-top: 10px;
}

/* Pause Screen */
.pause-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.pause-content h2 {
    color: white;
    font-size: 28px;
    letter-spacing: 4px;
}

.pause-buttons {
    display: flex;
    gap: 20px;
}

/* Characters Screen */
.characters-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
    max-height: 100%;
    padding: 30px 20px;
}

.characters-content h2 {
    color: white;
    font-size: 22px;
    letter-spacing: 3px;
}

.character-count {
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-height: 50vh;
    overflow-y: auto;
    padding: 10px;
    width: 100%;
}

.character-cell {
    aspect-ratio: 1;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: transform 0.1s ease, background 0.2s ease;
    padding: 8px;
}

.character-cell:active {
    transform: scale(0.9);
}

.character-cell.selected {
    background: rgba(79, 195, 247, 0.3);
    border: 2px solid #4FC3F7;
}

.character-cell.locked {
    opacity: 0.4;
}

.character-cell img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: auto;
}

.character-cell .lock-icon {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    opacity: 0.6;
}

.characters-bottom {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

/* Levels Screen */
.levels-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 30px 20px;
}

.levels-content h2 {
    color: white;
    font-size: 22px;
    letter-spacing: 3px;
}

.levels-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 300px;
}

.level-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-family: 'WebServeroff', sans-serif;
    font-weight: bold;
    font-size: 16px;
    padding: 16px 24px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.1s ease;
}

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

.level-btn.selected {
    background: rgba(79, 195, 247, 0.3);
    border: 2px solid #4FC3F7;
}

.level-btn.locked {
    opacity: 0.4;
    cursor: default;
}

.level-btn .level-best {
    font-size: 12px;
    opacity: 0.5;
}

/* Lottery Screen */
.lottery-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.lottery-unknown {
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 60px;
    color: rgba(255, 255, 255, 0.3);
    animation: lotteryPulse 0.8s ease-in-out infinite;
}

@keyframes lotteryPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.lottery-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#lottery-chapi-img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    image-rendering: auto;
}

#lottery-chapi-name {
    color: white;
    font-size: 20px;
    letter-spacing: 2px;
}

/* Settings Screen */
.settings-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.settings-content h2 {
    color: white;
    font-size: 22px;
    letter-spacing: 3px;
}

.settings-options {
    display: flex;
    gap: 20px;
}

/* Tutorial */
#tutorial-overlay {
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 60px;
    pointer-events: none;
}

#tutorial-overlay > * {
    pointer-events: auto;
}

.tutorial-help img {
    max-width: 80%;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.tutorial-help img.visible {
    opacity: 1;
}

#btn-skip-tutorial {
    margin-top: 20px;
}

/* Money Bonus Popup */
.money-bonus {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #FFD700;
    font-size: 24px;
    font-weight: bold;
    pointer-events: none;
    z-index: 50;
    animation: moneyBonusAnim 1s ease-out forwards;
}

@keyframes moneyBonusAnim {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.5); }
    30% { opacity: 1; transform: translate(-50%, -70%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -100%) scale(1); }
}

/* Scrollbar styles */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}
