/**
 * Matkot player: vista desde la raqueta hacia el cielo.
 * Cerca (raqueta) = pelota grande; cenit = pelota chica.
 */

html, body {
    margin: 0;
    height: 100%;
    background: #111;
}

#host {
    position: fixed;
    inset: 0;
}

#host.mk-active {
    display: block;
}

.mk-scene {
    position: absolute;
    inset: 0;
    overflow: hidden;
    font-family: "Segoe UI", "Noto Sans", Arial, sans-serif;
    color: #fff;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.mk-sky {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 48%;
    background: linear-gradient(180deg, #5ba3d9 0%, #a8d4f0 70%, #c5e0c8 100%);
}

/* Pared verde de frontón: solo práctica */
.mk-wall {
    position: absolute;
    left: 6%;
    right: 6%;
    top: 18%;
    height: 48%;
    z-index: 1;
    background:
        linear-gradient(90deg, rgba(0,0,0,0.12), transparent 12%, transparent 88%, rgba(0,0,0,0.12)),
        linear-gradient(180deg, #7bc87b 0%, #5aaa5a 40%, #3f8f3f 100%);
    border: 2px solid rgba(255,255,255,0.28);
    border-bottom: 3px solid rgba(0,0,0,0.2);
    border-radius: 6px 6px 2px 2px;
    box-shadow:
        inset 0 12px 28px rgba(255,255,255,0.12),
        inset 0 -16px 24px rgba(0,0,0,0.18),
        0 8px 20px rgba(0,0,0,0.15);
    pointer-events: none;
}

.mk-multi .mk-sky {
    height: 58%;
    background: linear-gradient(180deg, #4a90c8 0%, #87c0e8 55%, #d4e8c8 100%);
}

.mk-multi .mk-grass {
    height: 42%;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(255,255,255,0.14), transparent 50%),
        linear-gradient(180deg, #c9b896 0%, #b89a6a 45%, #9a7a4a 100%);
    border-top: 2px solid rgba(255,255,255,0.22);
}

.mk-wall::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 58%;
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    border-radius: 50%;
    background: rgba(255,255,255,0.35);
    box-shadow: 0 0 0 2px rgba(255,255,255,0.15);
}

.mk-grass {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 34%;
    z-index: 2;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(255,255,255,0.1), transparent 55%),
        linear-gradient(180deg, #6aad6a 0%, #4a9a4a 55%, #3d7a3d 100%);
    border-top: 2px solid rgba(255,255,255,0.18);
}

.mk-paddle {
    position: absolute;
    left: 50%;
    bottom: 6%;
    width: min(72vw, 280px);
    height: min(28vw, 110px);
    transform: translateX(-50%);
    border-radius: 50% 50% 42% 42%;
    background:
        radial-gradient(ellipse at 50% 35%, #f5d0c8 0%, #e8a090 40%, #c45c4a 75%, #8b3a2e 100%);
    border: 3px solid rgba(80, 40, 30, 0.55);
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
    z-index: 4;
    cursor: pointer;
    transition: left 0.28s ease-out;
}

.mk-paddle::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -18%;
    width: 14%;
    height: 42%;
    transform: translateX(-50%);
    background: linear-gradient(180deg, #c4a574, #8b6914);
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.2);
}

.mk-shadow {
    position: absolute;
    left: 50%;
    bottom: 14%;
    width: min(28vw, 110px);
    height: min(10vw, 40px);
    transform: translateX(-50%) scale(1);
    transform-origin: center center;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 50%;
    z-index: 3;
    pointer-events: none;
    transition: opacity 0.05s linear;
}

.mk-ball {
    position: absolute;
    left: 50%;
    bottom: 18%;
    width: min(42vw, 160px);
    height: min(42vw, 160px);
    border-radius: 50%;
    background: #c9f364;
    box-shadow: inset -8px -6px 0 rgba(255,255,255,0.35);
    z-index: 5;
    transform: translateX(-50%) scale(1);
    transform-origin: center bottom;
    pointer-events: none;
    will-change: transform, bottom, left;
    transition: background 0.08s ease, box-shadow 0.08s ease, filter 0.08s ease;
}

.mk-ball.is-miss {
    background: #ff6b5a;
    box-shadow:
        inset -8px -6px 0 rgba(255,255,255,0.25),
        0 0 22px rgba(255, 70, 50, 0.65);
    filter: brightness(1.15);
}

.mk-hud {
    position: absolute;
    top: max(0.75rem, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: center;
    padding: 0.35rem 0.85rem;
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 12px;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    pointer-events: none;
}

.mk-room-line.is-hidden {
    display: none;
}

.mk-lobby {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem;
    background: rgba(8, 24, 48, 0.88);
    color: #fff;
    font-family: "Segoe UI", "Noto Sans", Arial, sans-serif;
    text-align: center;
}

.mk-lobby.is-hidden {
    display: none;
}

.mk-lobby h1 {
    margin: 0 0 0.5rem;
    font-size: 1.75rem;
}

.mk-lobby p {
    margin: 0;
    opacity: 0.85;
    font-size: 0.95rem;
    max-width: 22em;
}

.mk-lobby-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0.5rem;
}

.mk-lobby input {
    font-size: 1.1rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    text-align: center;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.35);
    background: rgba(0,0,0,0.35);
    color: #fff;
    width: 8rem;
}

.mk-lobby button {
    font-size: 1rem;
    font-weight: 600;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    background: #c9f364;
    color: #1a2a0a;
}

.mk-lobby button.secondary {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.mk-lobby-status {
    min-height: 1.4em;
    font-size: 0.9rem;
    color: #c9f364;
}

.mk-lobby-status.is-error {
    color: #ffb4a8;
}

.mk-lobby-share {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    max-width: 22rem;
    font-size: 0.85rem;
}

.mk-lobby-share.is-hidden {
    display: none;
}

.mk-share-code {
    margin: 0;
    opacity: 0.9;
}

.mk-share-code strong {
    letter-spacing: 0.12em;
    font-size: 1.15rem;
}

.mk-share-link {
    display: block;
    width: 100%;
    word-break: break-word;
    font-size: 0.78rem;
    line-height: 1.35;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    opacity: 0.95;
    margin: 0;
    cursor: default;
    pointer-events: none;
}

.mk-lobby-share .secondary {
    font-size: 0.85rem;
    padding: 0.4rem 0.85rem;
}

.mk-gesture-need.is-hidden {
    display: none;
}

.mk-debug {
    display: none !important;
}

.mk-tilt-flip {
    position: absolute;
    top: max(0.35rem, env(safe-area-inset-top));
    right: 3.55rem;
    z-index: 30;
    margin: 0;
    padding: 0.28rem 0.5rem;
    font-size: 0.68rem;
    font-weight: 600;
    color: rgba(255,255,255,0.7);
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 6px;
    cursor: pointer;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
    max-width: 5.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mk-tilt-flip.is-on {
    color: #1a2a0a;
    background: rgba(201, 243, 100, 0.9);
    border-color: transparent;
}

.mk-tilt-flip:active {
    background: rgba(0,0,0,0.55);
    color: #fff;
}

.mk-quit {
    position: absolute;
    top: max(0.35rem, env(safe-area-inset-top));
    right: 0.45rem;
    z-index: 30;
    margin: 0;
    padding: 0.28rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: rgba(255,255,255,0.75);
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 6px;
    cursor: pointer;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
}

.mk-quit:active {
    background: rgba(0,0,0,0.55);
    color: #fff;
}

.mk-hud strong {
    font-weight: 700;
}

.mk-hint {
    position: absolute;
    left: 50%;
    bottom: 42%;
    transform: translateX(-50%);
    z-index: 6;
    margin: 0;
    padding: 0.4rem 0.9rem;
    background: rgba(0,0,0,0.4);
    border-radius: 999px;
    font-size: 0.9rem;
    pointer-events: none;
    opacity: 0.9;
}

.mk-hint.is-hidden {
    display: none;
}

.mk-hint.is-miss-msg {
    background: rgba(120, 20, 16, 0.72);
    color: #ffe8e4;
    font-size: 0.95rem;
    max-width: 92%;
    text-align: center;
    white-space: normal;
    line-height: 1.25;
}

.mk-intro {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    text-align: center;
    background: rgba(8, 24, 48, 0.72);
    color: #fff;
    cursor: pointer;
    transition: opacity 0.45s ease, visibility 0.45s ease;
}

.mk-intro.is-gone {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.mk-intro-line {
    margin: 0 0 0.65rem;
    font-family: "Segoe UI", "Noto Sans", Arial, sans-serif;
    font-size: clamp(1.15rem, 5.5vw, 1.75rem);
    font-weight: 600;
    line-height: 1.3;
    max-width: 18em;
}

.mk-intro-em {
    font-size: clamp(1.35rem, 6.5vw, 2.1rem);
    font-weight: 800;
    margin-bottom: 1.25rem;
}

.mk-intro-tap {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.75;
}
