/* Slime Volley - Stylesheet */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');

:root {
    --bg-dark: #0b0d12;
    --bg-panel: #141720;
    --bg-elevated: #1b1f2b;
    --bg-input: #0f121a;
    --border: #242a38;
    --border-soft: #1c2130;
    --border-strong: #333a4a;
    --text: #e7eaf2;
    --text-muted: #a3abbc;
    --text-dim: #6a7384;
    --primary: #7aa6ff;
    --primary-dark: #4c7bd8;
    --secondary: #b497ff;
    --secondary-dark: #8d6aec;
    --danger: #e5787d;
    --success: #6ec896;
    --warning: #f0c067;
    --team-a: #5a9ce8;
    --team-b: #e8706b;
    --font-sans: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-display: 'Space Grotesk', 'Pretendard Variable', Pretendard, system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

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

html, body {
    height: calc(var(--vh, 1vh) * 100);
    overflow: hidden;
}

body {
    background:
        radial-gradient(ellipse at top, rgba(122, 166, 255, 0.06), transparent 55%),
        radial-gradient(ellipse at bottom, rgba(232, 112, 107, 0.04), transparent 60%),
        var(--bg-dark);
    color: var(--text);
    font-family: var(--font-sans);
    font-feature-settings: 'ss01', 'ss02', 'cv01', 'cv11';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    letter-spacing: -0.005em;
}

#app {
    display: flex;
    flex-direction: column;
    height: calc(var(--vh, 1vh) * 100);
    overflow: hidden;
}

/* Header */
#game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 22px;
    background: rgba(15, 17, 24, 0.72);
    border-bottom: 1px solid var(--border-soft);
    backdrop-filter: blur(14px) saturate(150%);
    -webkit-backdrop-filter: blur(14px) saturate(150%);
    position: sticky;
    top: 0;
    z-index: 100;
}

#game-header h1 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text);
}

.back-link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 1.25rem;
    padding: 4px 12px;
    border-radius: 8px;
    transition: all 0.18s ease;
}
.back-link:hover { color: var(--text); background: rgba(255,255,255,0.04); }

.icon-btn {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    font-family: inherit;
    transition: all 0.18s ease;
}
.icon-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); border-color: var(--border-strong); }
.icon-btn.muted { color: var(--danger); border-color: rgba(229, 120, 125, 0.4); }

/* Screens */
.screen {
    display: none;
    flex: 1;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
    min-height: 0;
}
.screen.active {
    display: flex;
}

/* Error Toast */
#error-toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(229, 120, 125, 0.95);
    color: white;
    padding: 10px 22px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 500;
    opacity: 0;
    transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
#error-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Archerlab Link */
.archerlab-link {
    display: inline-block;
    background: linear-gradient(135deg, #10b981, #3b82f6, #10b981);
    background-size: 200% 200%;
    animation: al-grad 3s ease infinite, al-glow 2s ease-in-out infinite;
    color: #fff;
    border: 2px solid rgba(255,255,255,0.5);
    padding: 7px 18px;
    border-radius: 25px;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 20px;
    box-shadow: 0 0 20px rgba(16,185,129,0.5), 0 0 60px rgba(59,130,246,0.2), 0 4px 15px rgba(0,0,0,0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}
.archerlab-link:hover {
    transform: scale(1.08);
    box-shadow: 0 0 30px rgba(16,185,129,0.7), 0 0 80px rgba(59,130,246,0.3);
}
@keyframes al-grad { 0%{background-position:0% 50%} 50%{background-position:100% 50%} 100%{background-position:0% 50%} }
@keyframes al-glow { 0%,100%{box-shadow:0 0 20px rgba(16,185,129,0.5),0 4px 15px rgba(0,0,0,0.3)} 50%{box-shadow:0 0 35px rgba(16,185,129,0.8),0 4px 15px rgba(0,0,0,0.3)} }

/* Menu */
.menu-container {
    text-align: center;
    max-width: 420px;
    width: 100%;
}

.game-logo {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 22px;
    margin-bottom: 22px;
    height: 84px;
}

.logo-slime {
    width: 62px;
    height: 32px;
    border-radius: 60px 60px 0 0;
    position: relative;
    box-shadow: inset 0 -4px 10px rgba(0,0,0,0.15), 0 4px 14px rgba(0,0,0,0.25);
}
.logo-slime.blue { background: linear-gradient(180deg, #7cb7ef 0%, var(--team-a) 60%, #3d80cc 100%); }
.logo-slime.red { background: linear-gradient(180deg, #f29b97 0%, var(--team-b) 60%, #c85952 100%); }
.logo-slime::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
    top: 8px;
    box-shadow: 0 0 2px rgba(0,0,0,0.2);
}
.logo-slime::before {
    content: '';
    position: absolute;
    top: 4px;
    width: 18px;
    height: 5px;
    background: rgba(255,255,255,0.35);
    border-radius: 50%;
    filter: blur(1px);
}
.logo-slime.blue::after { right: 12px; }
.logo-slime.blue::before { left: 10px; }
.logo-slime.red::after { left: 12px; }
.logo-slime.red::before { right: 10px; }

.logo-ball {
    width: 28px;
    height: 28px;
    background: radial-gradient(circle at 35% 30%, #fff7d8 0%, #f5d96a 55%, #c99926 100%);
    border-radius: 50%;
    margin-bottom: 22px;
    box-shadow: 0 2px 10px rgba(201,153,38,0.35), inset -2px -3px 4px rgba(0,0,0,0.15);
    animation: logoBounce 2s ease-in-out infinite;
}

@keyframes logoBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-22px); }
}

.menu-title {
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    color: var(--text);
    margin-bottom: 6px;
}

.menu-subtitle {
    color: var(--text-dim);
    margin-bottom: 36px;
    font-size: 0.92rem;
    font-weight: 400;
    letter-spacing: 0.01em;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 32px;
}

/* Buttons */
.btn {
    border: none;
    padding: 13px 26px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    position: relative;
    letter-spacing: -0.005em;
}

.btn-large {
    padding: 16px 22px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 14px;
}

.btn-icon {
    font-size: 1.2rem;
    width: 28px;
    text-align: center;
    opacity: 0.9;
}

.btn-desc {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.5);
    position: absolute;
    right: 18px;
    font-weight: 400;
    letter-spacing: 0;
}

.btn-primary {
    background: var(--primary);
    color: #0b0d12;
    font-weight: 600;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-primary:hover {
    background: #8db4ff;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(122, 166, 255, 0.25), inset 0 1px 0 rgba(255,255,255,0.25);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-secondary:hover {
    border-color: var(--border-strong);
    background: #232836;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.btn-ghost:hover { border-color: var(--border-strong); color: var(--text); }

.btn-small {
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.18s ease;
}
.btn-small:hover { border-color: var(--border-strong); color: var(--text); }

.btn-small-primary {
    padding: 7px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 8px;
    background: var(--primary);
    color: #0b0d12;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.18s ease;
}
.btn-small-primary:hover { background: #8db4ff; box-shadow: 0 3px 10px rgba(122, 166, 255, 0.22); }

/* Controls Guide */
.controls-guide {
    background: rgba(20, 23, 32, 0.6);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 16px 18px;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.9;
}
.controls-guide strong {
    color: var(--text);
    font-weight: 600;
    letter-spacing: 0.01em;
}

kbd {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: 2px 7px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1;
    display: inline-block;
    min-width: 20px;
    text-align: center;
}

/* Panel */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    padding: 32px 30px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 24px 60px -20px rgba(0,0,0,0.5);
}
.panel-wide { max-width: 620px; }

.panel h2 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--text);
    margin-bottom: 24px;
    text-align: center;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 7px;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.form-inline {
    display: flex;
    align-items: center;
    gap: 10px;
}
.form-inline label {
    margin-bottom: 0;
    white-space: nowrap;
}
.form-inline .input-text {
    flex: 1;
}

.input-text, .input-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.18s ease, background 0.18s ease;
}
.input-text:focus, .input-select:focus {
    outline: none;
    border-color: var(--primary);
    background: #121621;
}
.input-text::placeholder { color: var(--text-dim); }

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.checkbox-label input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}
.form-actions .btn { flex: 1; }

/* Lobby Top */
.lobby-top {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 16px;
}
.lobby-top .form-group {
    flex: 1;
    margin-bottom: 0;
}
.lobby-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Room List */
.room-list {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    background: rgba(11, 13, 18, 0.5);
}

.room-list-empty {
    padding: 42px 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.88rem;
    letter-spacing: 0.005em;
}

.room-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 18px;
    border-bottom: 1px solid var(--border-soft);
    transition: background 0.15s ease;
    cursor: pointer;
}
.room-item:last-child { border-bottom: none; }
.room-item.room-waiting:hover {
    background: rgba(122, 166, 255, 0.06);
}
.room-item.room-playing {
    opacity: 0.45;
    cursor: default;
}

.room-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.room-host {
    font-weight: 600;
    font-size: 0.93rem;
    color: var(--text);
    letter-spacing: -0.005em;
}
.room-detail {
    font-size: 0.78rem;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.room-status {
    display: flex;
    align-items: center;
    gap: 10px;
}
.room-status-badge {
    font-family: var(--font-display);
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.status-waiting {
    background: rgba(110, 200, 150, 0.14);
    color: var(--success);
}
.status-playing {
    background: rgba(229, 120, 125, 0.14);
    color: var(--danger);
}
.room-lock-icon {
    font-size: 0.75rem;
    color: var(--warning);
    margin-left: 6px;
}

/* Room Type Selector */
.room-type-selector {
    display: flex;
    gap: 8px;
}
.room-type-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.18s ease;
}
.room-type-btn.active {
    border-color: var(--primary);
    background: rgba(122, 166, 255, 0.1);
    color: var(--primary);
    font-weight: 600;
}
.room-type-btn:hover:not(.active) {
    border-color: var(--border-strong);
    color: var(--text);
}

/* Room Type Display (in room screen) */
.room-type-display {
    text-align: center;
    margin-bottom: 12px;
    padding: 8px 16px;
    background: rgba(11, 13, 18, 0.5);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.room-type-display .room-type-badge {
    font-family: var(--font-display);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.room-type-badge.badge-public {
    background: rgba(110, 200, 150, 0.14);
    color: var(--success);
}
.room-type-badge.badge-private {
    background: rgba(240, 192, 103, 0.14);
    color: var(--warning);
}

/* Password Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(6, 8, 12, 0.72);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.modal-box {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    max-width: 340px;
    width: 90%;
    text-align: center;
    box-shadow: 0 28px 70px -14px rgba(0,0,0,0.6);
}
.modal-box h3 {
    font-family: var(--font-display);
    font-size: 1.02rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
    margin-bottom: 18px;
}
.modal-box .input-text {
    text-align: center;
    font-size: 1.35rem;
    letter-spacing: 8px;
    margin-bottom: 8px;
    font-family: var(--font-mono);
}
.modal-box .form-actions {
    margin-top: 16px;
}

/* Room Screen */
.room-private-badge {
    color: var(--warning);
    font-size: 0.78rem;
    margin-left: 4px;
}

.room-meta {
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.room-meta span {
    color: var(--text);
    font-weight: 600;
}

/* Player List */
.player-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 12px;
}

.team-group {
    background: rgba(11, 13, 18, 0.5);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    padding: 12px;
}

.team-label {
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 10px;
    padding-bottom: 7px;
    border-bottom: 2px solid;
}
.team-0 .team-label { color: var(--team-a); border-color: var(--team-a); }
.team-1 .team-label { color: var(--team-b); border-color: var(--team-b); }

.player-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 7px;
    margin-bottom: 4px;
    font-size: 0.88rem;
    transition: background 0.18s ease;
}
.player-item.ready { background: rgba(110, 200, 150, 0.09); }
.player-item.empty { opacity: 0.3; }

.player-name { flex: 1; }
.empty-slot { font-style: italic; color: var(--text-dim); }

.player-badge {
    font-family: var(--font-display);
    font-size: 0.62rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.host-badge { background: rgba(240, 192, 103, 0.16); color: var(--warning); }
.ready-badge { background: rgba(110, 200, 150, 0.16); color: var(--success); }
.bot-badge { background: rgba(180, 151, 255, 0.16); color: var(--secondary); }

.btn-ready.active {
    background: var(--success);
    color: #0b120d;
    border-color: transparent;
    font-weight: 600;
}

/* Chat */
.chat-section {
    margin-top: 12px;
    margin-bottom: 8px;
}
.chat-messages {
    height: 100px;
    overflow-y: auto;
    background: rgba(11, 13, 18, 0.5);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 0.8rem;
    margin-bottom: 6px;
    line-height: 1.55;
}
.chat-msg {
    margin-bottom: 3px;
    word-break: break-word;
    color: var(--text-muted);
}
.chat-name {
    color: var(--primary);
    font-weight: 600;
    margin-right: 4px;
}
.chat-input-row {
    display: flex;
    gap: 6px;
}
.chat-input-field {
    flex: 1;
    padding: 6px 10px;
    font-size: 0.85rem;
}

/* Ping Display */
.player-ping {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: auto;
    margin-right: 4px;
    min-width: 46px;
    text-align: center;
    letter-spacing: 0;
}
.ping-good {
    background: rgba(110, 200, 150, 0.16);
    color: var(--success);
}
.ping-ok {
    background: rgba(240, 192, 103, 0.16);
    color: var(--warning);
}
.ping-bad {
    background: rgba(229, 120, 125, 0.16);
    color: var(--danger);
}

.btn-kick {
    background: none;
    border: 1px solid rgba(229, 120, 125, 0.45);
    color: var(--danger);
    width: 22px;
    height: 22px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.18s ease;
}
.btn-kick:hover { opacity: 1; }

.btn-remove-bot {
    border-color: rgba(180, 151, 255, 0.45);
    color: var(--secondary);
}

.btn-add-bot {
    display: block;
    width: 100%;
    padding: 5px 8px;
    margin-top: 4px;
    background: rgba(180, 151, 255, 0.07);
    border: 1px dashed rgba(180, 151, 255, 0.4);
    color: var(--secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    font-family: inherit;
    transition: all 0.18s ease;
}
.btn-add-bot:hover {
    background: rgba(180, 151, 255, 0.14);
    border-style: solid;
}

.player-item.me {
    background: rgba(122, 166, 255, 0.08);
}

/* Room Body Layout */
.room-body {
    flex: 1;
    min-height: 0;
}
.room-sidebar {
    display: flex;
    flex-direction: column;
}
.room-sidebar .chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.room-sidebar .chat-messages {
    flex: 1;
    min-height: 60px;
}

/* Game Screen Layout */
#game-screen.screen {
    position: relative;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 4px;
    overflow: hidden;
}

/* Game Canvas */
.game-canvas-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 820px;
    flex: 1 1 0;
    min-height: 0;
}

.game-canvas-container canvas {
    display: block;
    border-radius: 10px;
    box-shadow: 0 20px 50px -20px rgba(0,0,0,0.5), 0 0 0 1px var(--border-soft);
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Mobile Controls */
.mobile-controls {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
}

.touch-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.touch-zone-left {
    left: 0;
    width: 50%;
}

.touch-zone-right {
    right: 0;
    width: 50%;
}

/* Joystick visual - 캔버스 바깥 사이드 */
.joystick-visual {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 11;
}

.joystick-visual-left {
    left: 12px;
}

.joystick-visual-right {
    right: 12px;
}

.joystick-base {
    width: 100px;
    height: 50px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    position: relative;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.joystick-knob {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    transition: transform 0.1s;
    flex-shrink: 0;
}

.joystick-arrow {
    color: rgba(255, 255, 255, 0.25);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.jump-btn-visual {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.3);
    font-family: var(--font-display);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* 터치 활성화 시 */
.touch-zone-left.active ~ .joystick-visual-left .joystick-base {
    border-color: rgba(122, 166, 255, 0.4);
}
.touch-zone-left.active ~ .joystick-visual-left .joystick-knob {
    background: rgba(122, 166, 255, 0.3);
    border-color: rgba(122, 166, 255, 0.55);
}
.touch-zone-right.active ~ .joystick-visual-right .jump-btn-visual {
    background: rgba(122, 166, 255, 0.15);
    border-color: rgba(122, 166, 255, 0.45);
    color: rgba(122, 166, 255, 0.75);
}

@media (max-width: 768px) {
    .mobile-controls { display: block !important; }
    .controls-guide { display: none !important; }
    .lobby-top { flex-direction: column; align-items: stretch; }
    .lobby-actions { justify-content: flex-end; }
}

@media (hover: none) and (pointer: coarse) {
    .mobile-controls { display: block !important; }
    .controls-guide { display: none !important; }
}

@media (any-pointer: coarse) {
    .mobile-controls { display: block !important; }
    .controls-guide { display: none !important; }
}

/* 모바일 가로 모드: 높이 부족 시 UI 압축 */
@media (max-height: 450px) {
    #game-header {
        padding: 2px 10px;
    }
    #game-header h1 {
        font-size: 0.86rem;
    }
    .icon-btn {
        padding: 2px 8px;
        font-size: 0.72rem;
    }
    .back-link {
        font-size: 1.05rem;
        padding: 2px 6px;
    }
    .screen {
        padding: 8px;
        overflow: hidden;
    }
    #multiplayer-lobby.screen,
    #room-screen.screen {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .archerlab-link {
        font-size: 0.72rem;
        padding: 5px 12px;
        margin-bottom: 8px;
    }
    .game-logo {
        height: 38px;
        margin-bottom: 6px;
        gap: 10px;
    }
    .logo-slime {
        width: 32px;
        height: 16px;
    }
    .logo-slime::before {
        top: 2px;
        width: 10px;
        height: 3px;
    }
    .logo-ball {
        width: 16px;
        height: 16px;
        margin-bottom: 10px;
    }
    .menu-title {
        font-size: 1.3rem;
        margin-bottom: 0;
    }
    .menu-subtitle {
        font-size: 0.75rem;
        margin-bottom: 10px;
    }
    .menu-buttons {
        gap: 6px;
        margin-bottom: 0;
    }
    .btn-large {
        padding: 9px 16px;
    }
    .btn-icon {
        font-size: 1rem;
        width: 22px;
    }
    .btn-desc {
        font-size: 0.6rem;
    }
    .panel {
        padding: 12px 16px;
        border-radius: 12px;
    }
    .panel h2 {
        font-size: 0.92rem;
        margin-bottom: 6px;
    }
    .form-group {
        margin-bottom: 5px;
    }
    .form-group label {
        font-size: 0.72rem;
        margin-bottom: 2px;
    }
    .input-text, .input-select {
        padding: 6px 10px;
        font-size: 0.82rem;
        border-radius: 6px;
    }
    .form-actions {
        margin-top: 6px;
        gap: 8px;
    }
    .form-actions .btn {
        padding: 8px 12px;
        font-size: 0.82rem;
    }
    #multiplayer-lobby.screen,
    #room-screen.screen,
    #create-room.screen,
    #practice-setup.screen {
        align-items: stretch;
        justify-content: center;
        padding: 4px 8px;
    }
    #multiplayer-lobby .panel-wide,
    #room-screen .panel-wide {
        max-height: 100%;
        display: flex;
        flex-direction: column;
        margin: 0 auto;
    }
    #multiplayer-lobby .room-list {
        flex-shrink: 1;
        min-height: 0;
    }
    .room-header-section {
        flex-shrink: 0;
    }
    .room-header-section h2 {
        margin-bottom: 2px;
    }
    .room-body {
        display: flex;
        gap: 8px;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }
    .room-body .player-list {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        margin-bottom: 0;
    }
    .room-sidebar {
        flex: 1;
        min-width: 0;
        min-height: 0;
        overflow: hidden;
    }
    .room-sidebar .chat-section {
        margin-top: 0;
        height: 100%;
    }
    .room-sidebar .chat-messages {
        flex: 1;
        min-height: 0;
        height: auto;
    }
    .panel-wide {
        padding: 8px 14px;
        max-width: 95vw;
    }
    .panel-wide h2 {
        font-size: 0.86rem;
        margin-bottom: 4px;
    }
    .lobby-top {
        flex-direction: row !important;
        align-items: center;
        gap: 8px;
        margin-bottom: 6px;
    }
    .lobby-top .form-group {
        margin-bottom: 0;
    }
    .lobby-top .form-inline {
        gap: 6px;
    }
    .lobby-top .input-text {
        padding: 4px 8px;
        font-size: 0.8rem;
    }
    .lobby-actions {
        gap: 4px;
    }
    .room-list {
        max-height: 35vh;
    }
    .room-list-empty {
        padding: 16px 10px;
    }
    .room-item {
        padding: 7px 10px;
    }
    .room-type-display {
        padding: 2px 10px;
        margin-bottom: 2px;
        font-size: 0.75rem;
    }
    .room-meta {
        font-size: 0.75rem;
        margin-bottom: 2px;
    }
    .player-list {
        gap: 6px;
        margin-bottom: 0;
    }
    .team-group {
        padding: 4px 6px;
    }
    .team-label {
        font-size: 0.65rem;
        margin-bottom: 3px;
        padding-bottom: 2px;
    }
    .player-item {
        padding: 2px 5px;
        font-size: 0.76rem;
        margin-bottom: 1px;
    }
    .btn-add-bot {
        padding: 2px 6px;
        font-size: 0.65rem;
        margin-top: 2px;
    }
    .chat-section {
        margin-top: 0;
        margin-bottom: 0;
    }
    .chat-messages {
        height: 48px;
        padding: 4px 6px;
        font-size: 0.7rem;
        margin-bottom: 3px;
    }
    .chat-input-field {
        padding: 3px 8px;
        font-size: 0.75rem;
    }
    .btn-small, .btn-small-primary {
        padding: 3px 8px;
        font-size: 0.7rem;
    }
    .checkbox-label {
        font-size: 0.78rem;
    }
    .checkbox-label input[type="checkbox"] {
        width: 14px;
        height: 14px;
    }
    #game-screen.screen {
        padding: 0 2px;
    }
    .joystick-base {
        width: 80px;
        height: 40px;
    }
    .joystick-knob {
        width: 22px;
        height: 22px;
    }
    .jump-btn-visual {
        width: 55px;
        height: 55px;
        font-size: 0.62rem;
    }
}

/* 극단적으로 낮은 높이 (300px 이하) */
@media (max-height: 300px) {
    #game-header {
        display: none;
    }
    .panel-wide {
        padding: 4px 8px;
    }
    .panel-wide h2 {
        font-size: 0.8rem;
        margin-bottom: 2px;
    }
    .room-list {
        max-height: 25vh;
    }
    .room-type-display {
        display: none;
    }
    .room-meta {
        margin-bottom: 2px;
    }
    .room-sidebar .chat-messages {
        min-height: 24px;
        font-size: 0.65rem;
    }
    .chat-input-field {
        padding: 2px 6px;
        font-size: 0.65rem;
    }
    .chat-input-row .btn-small {
        padding: 2px 6px;
        font-size: 0.6rem;
    }
    .player-list {
        gap: 4px;
        margin-bottom: 0;
    }
    .team-group {
        padding: 3px 5px;
    }
    .player-item {
        padding: 1px 4px;
        font-size: 0.72rem;
    }
    .btn-add-bot {
        padding: 1px 4px;
        font-size: 0.6rem;
    }
    .form-actions {
        margin-top: 3px;
    }
    .form-actions .btn {
        padding: 4px 8px;
        font-size: 0.72rem;
    }
    #game-screen.screen {
        padding: 0;
    }
    .joystick-base {
        width: 70px;
        height: 36px;
    }
    .joystick-knob {
        width: 20px;
        height: 20px;
    }
    .jump-btn-visual {
        width: 48px;
        height: 48px;
        font-size: 0.6rem;
    }
}

/* Game Over */
.game-over-panel { text-align: center; }

.game-over-score {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    margin: 24px 0;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.game-over-sets {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 14px;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.set-score {
    background: var(--bg-input);
    border: 1px solid var(--border-soft);
    padding: 4px 11px;
    border-radius: 7px;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

#game-over-title.victory {
    font-family: var(--font-display);
    color: var(--warning);
    font-size: 1.9rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

#game-over-title.defeat {
    font-family: var(--font-display);
    color: var(--text-muted);
    font-size: 1.9rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.game-over-mvp {
    margin: 18px 0;
    text-align: center;
}
.mvp-title {
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--warning);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.mvp-names {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}
.mvp-stats {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.6;
    font-variant-numeric: tabular-nums;
}

/* Rotate Overlay (portrait warning) */
#rotate-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 99999;
    background: var(--bg-dark);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 500;
    font-family: var(--font-sans);
    letter-spacing: -0.005em;
}
#rotate-overlay .rotate-icon {
    font-size: 3.4rem;
    animation: rotatePhone 2s ease-in-out infinite;
}
#rotate-overlay .rotate-sub {
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 0.01em;
}
@keyframes rotatePhone {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(90deg); }
    50% { transform: rotate(90deg); }
    75% { transform: rotate(0deg); }
}
@media (max-width: 768px) and (orientation: portrait),
       (hover: none) and (pointer: coarse) and (orientation: portrait) {
    #rotate-overlay { display: flex; }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.screen.active {
    animation: fadeIn 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); border: 2px solid transparent; background-clip: padding-box; }
