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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1a1a2e;
    color: #eee;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    position: fixed;
}

#game-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #1a1a2e;
}

canvas {
    background: #2d6a4f;
    border: 4px solid #ffcb05;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Desktop hint */
#desktop-hint {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    font-size: 0.85rem;
    color: #aaa;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 16px;
    border-radius: 20px;
    z-index: 5;
    pointer-events: none;
}

/* Mobile controls */
#mobile-controls {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#joystick-zone {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 140px;
    height: 140px;
    pointer-events: auto;
}

#joystick-base {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.4);
    top: 10px;
    left: 10px;
}

#joystick-knob {
    position: absolute;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.9);
    top: 43px;
    left: 43px;
    transition: transform 0.05s;
}

#action-buttons {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: auto;
}

.action-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.5);
    background: rgba(60, 90, 166, 0.7);
    color: white;
    font-size: 0.85rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
}

.action-btn:active {
    background: rgba(60, 90, 166, 0.9);
    transform: scale(0.95);
}

#btn-throw {
    background: rgba(230, 57, 70, 0.75);
}

#btn-battle {
    background: rgba(42, 157, 143, 0.75);
}

#btn-menu {
    background: rgba(155, 93, 229, 0.75);
}

/* Modals */
.modal, #collection-panel, #quest-panel, #shop-panel, #menu-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #16213e;
    border: 2px solid #ffcb05;
    border-radius: 16px;
    padding: 24px;
    max-width: 90%;
    max-height: 85%;
    width: 500px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    z-index: 20;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#collection-panel.hidden,
#quest-panel.hidden,
#shop-panel.hidden,
#menu-panel.hidden {
    display: none;
}

.modal h2, #collection-panel h2, #quest-panel h2, #shop-panel h2, #menu-panel h2 {
    text-align: center;
    color: #ffcb05;
    margin-bottom: 8px;
}

.modal button, #collection-panel button, #quest-panel button, #shop-panel button, #menu-panel button {
    padding: 12px 20px;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    background: #3c5aa6;
    color: white;
    cursor: pointer;
    transition: background 0.2s;
    pointer-events: auto;
}

.modal button:hover, #collection-panel button:hover, #quest-panel button:hover, #shop-panel button:hover, #menu-panel button:hover {
    background: #2a3f75;
}

/* Collection cards */
#collection-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin: 16px 0;
    max-height: 360px;
    overflow-y: auto;
}

.creature-card {
    background: #0f3460;
    border-radius: 10px;
    padding: 10px;
    width: 100px;
    text-align: center;
    border: 2px solid transparent;
    transition: transform 0.15s, border-color 0.15s;
}

.creature-card:hover {
    transform: translateY(-3px);
    border-color: #ffcb05;
}

.creature-card .icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    margin: 0 auto 8px;
    border: 2px solid #eee;
}

.creature-card .name {
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 2px;
}

.creature-card .info {
    font-size: 0.75rem;
    color: #aaa;
    margin-bottom: 6px;
}

.creature-card .hp-bar {
    height: 6px;
    background: #333;
    border-radius: 3px;
    overflow: hidden;
}

.creature-card .hp-bar span {
    display: block;
    height: 100%;
    background: #2a9d8f;
}

/* Quest panel */
#quest-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 16px 0;
    max-height: 360px;
    overflow-y: auto;
}

.quest-row {
    background: #0f3460;
    border-radius: 10px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.quest-info {
    flex: 1;
    min-width: 180px;
}

.quest-info strong {
    display: block;
    margin-bottom: 4px;
}

.quest-info span {
    font-size: 0.85rem;
    color: #aaa;
}

.quest-progress {
    width: 120px;
}

.quest-bar {
    height: 8px;
    background: #333;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}

.quest-bar span {
    display: block;
    height: 100%;
    background: #2a9d8f;
}

.claim-btn {
    padding: 6px 12px;
    font-size: 0.9rem;
    margin: 0;
}

.claimed {
    color: #2a9d8f;
    font-weight: bold;
}

/* Shop panel */
#shop-stock {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
    max-height: 360px;
    overflow-y: auto;
}

.shop-item {
    background: #0f3460;
    border-radius: 10px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shop-item span {
    font-size: 0.9rem;
}

.shop-item button {
    margin: 0;
    padding: 6px 12px;
    font-size: 0.9rem;
}

/* Mobile / desktop visibility */
@media (hover: hover) and (pointer: fine) {
    .hidden-on-desktop {
        display: none !important;
    }
}

@media (hover: none) and (pointer: coarse) {
    .hidden-on-mobile {
        display: none !important;
    }

    #desktop-hint {
        display: none;
    }

    canvas {
        border: none;
        border-radius: 0;
        width: 100%;
        height: 100%;
    }

    #game-wrapper {
        padding: 0;
    }
}

/* Small screens */
@media (max-width: 600px) {
    #joystick-zone {
        width: 120px;
        height: 120px;
    }

    #joystick-base {
        width: 100px;
        height: 100px;
        top: 10px;
        left: 10px;
    }

    #joystick-knob {
        width: 44px;
        height: 44px;
        top: 38px;
        left: 38px;
    }

    .action-btn {
        width: 60px;
        height: 60px;
        font-size: 0.75rem;
    }
}
