* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    touch-action: none;
    -webkit-touch-callout: none;
    user-select: none;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Name input on start screen (transparent overlay, no background) */
#nameOverlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 100;
    pointer-events: none;
}

#nameOverlay.visible {
    display: block;
}

#nameDialog {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #fff;
    font-family: 'Press Start 2P', monospace;
    pointer-events: auto;
}

#nameLabel {
    font-size: clamp(8px, 2.5vmin, 14px);
    color: #60d0f0;
    margin-bottom: 20px;
}

#nameInput {
    display: block;
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(12px, 3vmin, 20px);
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid #60d0f0;
    color: #fff;
    padding: 12px 16px;
    text-align: center;
    text-transform: uppercase;
    width: min(300px, 80vw);
    outline: none;
    border-radius: 8px;
    margin: 0 auto;
}

#nameInput::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

#nameInput:focus {
    border-color: #fff;
    box-shadow: 0 0 12px rgba(96, 208, 240, 0.4);
}

#nameSubmit, #mpStartBtn {
    display: block;
    margin: 20px auto 0;
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(9px, 2.5vmin, 14px);
    background: rgba(96, 208, 240, 0.15);
    border: 2px solid #60d0f0;
    color: #60d0f0;
    padding: 12px 32px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
    width: clamp(140px, 45vmin, 220px);
    box-sizing: border-box;
}

#nameSubmit:hover, #nameSubmit:active,
#mpStartBtn:hover, #mpStartBtn:active {
    background: rgba(96, 208, 240, 0.3);
    color: #fff;
}

#mpStartBtn {
    margin-top: 12px;
}

#nameError {
    display: none;
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(6px, 1.8vmin, 10px);
    color: #ff6666;
    margin-top: 10px;
}

/* Sticker gallery overlay */
#stickerOverlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.85);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#stickerOverlay.visible {
    display: flex;
    justify-content: center;
}

#stickerContainer {
    width: min(500px, 92vw);
    padding: 20px 10px 30px;
    text-align: center;
    font-family: 'Press Start 2P', monospace;
}

#stickerHeader {
    margin-bottom: 16px;
}

#stickerTitle {
    font-size: clamp(14px, 4vmin, 22px);
    color: #60d0f0;
    margin-bottom: 10px;
}

#stickerSubtitle {
    font-size: clamp(6px, 1.8vmin, 10px);
    color: rgba(255, 255, 255, 0.5);
}

#platformButtons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.platformBtn {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(5px, 1.5vmin, 8px);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.7);
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.platformBtn:hover, .platformBtn.active {
    background: rgba(96, 208, 240, 0.2);
    border-color: #60d0f0;
    color: #60d0f0;
}

#platformHelp {
    font-size: clamp(5px, 1.5vmin, 8px);
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.8;
    margin-bottom: 16px;
    min-height: 0;
    transition: min-height 0.2s;
}

#stickerGrid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

@media (max-width: 400px) {
    #stickerGrid {
        grid-template-columns: 1fr;
    }
}

.stickerCard {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.stickerCard img {
    width: 100%;
    max-width: 200px;
    height: auto;
    image-rendering: auto;
    border-radius: 8px;
}

.stickerName {
    font-size: clamp(5px, 1.5vmin, 8px);
    color: rgba(255, 255, 255, 0.6);
}

.stickerSave {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(5px, 1.4vmin, 7px);
    background: rgba(96, 208, 240, 0.15);
    border: 1px solid #60d0f0;
    color: #60d0f0;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.stickerSave:hover, .stickerSave:active {
    background: rgba(96, 208, 240, 0.3);
    color: #fff;
}

#stickerClose {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(8px, 2.2vmin, 12px);
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 0.7);
    padding: 10px 32px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

#stickerClose:hover, #stickerClose:active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Multiplayer lobby overlay */
#mpOverlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 100;
    background: rgba(10, 10, 30, 0.92);
    pointer-events: none;
}

#mpOverlay.visible {
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

#mpDialog {
    text-align: center;
    font-family: 'Press Start 2P', monospace;
    color: #fff;
    max-width: min(360px, 88vw);
}

#mpTitle, #mpWaitTitle, #mpJoinTitle {
    font-size: clamp(10px, 3vmin, 16px);
    color: #60d0f0;
    margin-bottom: 8px;
}

#mpSubtitle, #mpFailedDetail {
    font-size: clamp(6px, 1.8vmin, 9px);
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 20px;
    line-height: 1.6;
}

.mpBtn {
    display: block;
    width: 100%;
    margin: 8px auto;
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(8px, 2.2vmin, 12px);
    background: rgba(96, 208, 240, 0.12);
    border: 2px solid #60d0f0;
    color: #60d0f0;
    padding: 12px 24px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
}

.mpBtn:hover, .mpBtn:active {
    background: rgba(96, 208, 240, 0.3);
    color: #fff;
}

.mpBtnDim {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.5);
}

.mpBtnDim:hover, .mpBtnDim:active {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.8);
}

#mpQRHolder {
    margin: 16px auto;
    display: flex;
    justify-content: center;
}

#mpQRHolder canvas {
    border-radius: 8px;
    image-rendering: pixelated;
}

#mpRoomCode {
    font-size: clamp(14px, 4vmin, 24px);
    color: #fff;
    letter-spacing: 0.3em;
    margin: 8px 0 4px;
}

#mpWaitStatus {
    font-size: clamp(6px, 1.8vmin, 9px);
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 16px;
}

#mpRoomInput {
    display: block;
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(14px, 4vmin, 22px);
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid #60d0f0;
    color: #fff;
    padding: 12px 16px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    width: 100%;
    outline: none;
    border-radius: 8px;
    margin: 12px auto 4px;
}

#mpRoomInput:focus {
    border-color: #fff;
    box-shadow: 0 0 12px rgba(96, 208, 240, 0.4);
}

#mpJoinError {
    display: none;
    font-size: clamp(6px, 1.8vmin, 9px);
    color: #ff6666;
    margin: 6px 0 8px;
}

#mpConnectedMsg {
    font-size: clamp(12px, 3.5vmin, 20px);
    color: #60d0f0;
    margin-bottom: 8px;
}

#mpPeerName {
    font-size: clamp(8px, 2.5vmin, 14px);
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 20px;
}

#mpCountdownNum {
    font-size: clamp(32px, 10vmin, 64px);
    color: #fff;
}

#mpFailedMsg {
    font-size: clamp(10px, 3vmin, 16px);
    color: #ff6666;
    margin-bottom: 12px;
}

#mpWaitPeerName {
    font-size: clamp(10px, 3vmin, 16px);
    color: #60d0f0;
    margin-bottom: 16px;
    text-align: center;
}

#mpWaitPeerDots {
    font-size: clamp(20px, 6vmin, 36px);
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    animation: mpDots 1.5s steps(4, end) infinite;
    width: 3ch;
    overflow: hidden;
    margin: 0 auto;
}

@keyframes mpDots {
    0%   { width: 0ch; }
    25%  { width: 1ch; }
    50%  { width: 2ch; }
    75%  { width: 3ch; }
    100% { width: 3ch; }
}

/* DEV teleport modal */
#devTeleport {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
    background: rgba(10, 10, 30, 0.95);
    border: 2px solid #60d0f0;
    padding: 24px;
    text-align: center;
    font-family: 'Press Start 2P', monospace;
}

#devTeleport.visible {
    display: block;
}

#devTeleportLabel {
    color: #60d0f0;
    font-size: 12px;
    margin-bottom: 12px;
}

#devTeleportInput {
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    background: #0a1628;
    color: #fff;
    border: 1px solid #60d0f0;
    padding: 8px 12px;
    width: 160px;
    text-align: center;
    outline: none;
}

#devTeleportHint {
    color: rgba(255,255,255,0.4);
    font-size: 8px;
    margin: 8px 0 12px;
}

#devTeleportBtns {
    display: flex;
    gap: 12px;
    justify-content: center;
}

#devTeleportBtns button {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    padding: 8px 16px;
    cursor: pointer;
    border: 1px solid #60d0f0;
    background: transparent;
    color: #60d0f0;
}

#devTeleportBtns button:hover {
    background: rgba(96, 208, 240, 0.15);
}
