:root {
    --bg-dark: #0a0d14;
    --bg-card: rgba(22, 28, 45, 0.95);
    
    --color-a: #f1c40f; /* Yellow */
    --color-b: #3498db; /* Blue */
    --color-c: #e67e22; /* Orange */
    --color-d: #2ecc71; /* Green */
    --color-e: #9b59b6; /* Purple */

    --shadow-a: #b78a05;
    --shadow-b: #1f618d;
    --shadow-c: #a04000;
    --shadow-d: #1e8449;
    --shadow-e: #6c3483;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

body.controller-body {
    background: #0a0d14;
    color: #ffffff;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for iOS/Android */
    overflow: hidden;
    position: fixed;
    width: 100%;
}

.mobile-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.ctrl-view {
    display: none;
    height: 100%;
    width: 100%;
}

.ctrl-view.active {
    display: flex;
    flex-direction: column;
}

/* 1. JOIN VIEW */
#view-join {
    padding: 1.5rem;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 30%, #1e263d 0%, #0a0d14 100%);
    overflow-y: auto;
}

.join-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    padding: 2rem 1.6rem;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
}

.join-brand {
    text-align: center;
    margin-bottom: 1.8rem;
}

.brand-icon {
    font-size: 3rem;
    filter: drop-shadow(0 0 12px #f1c40f);
}

.brand-title {
    font-family: 'Russo One', sans-serif;
    font-size: 2.2rem;
    letter-spacing: 2px;
    color: #00f2fe;
    text-shadow: 0 0 15px rgba(0, 242, 254, 0.5);
}

.brand-sub {
    font-size: 0.95rem;
    color: #94a3b8;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
}

.join-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: #cbd5e1;
    margin-bottom: 0.4rem;
}

.input-styled {
    width: 100%;
    background: rgba(10, 14, 24, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    padding: 0.85rem 1rem;
    font-size: 1.1rem;
    color: #fff;
    font-weight: 700;
    outline: none;
    transition: border-color 0.2s;
}

.input-styled:focus {
    border-color: #00f2fe;
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.3);
}

.input-styled.uppercase {
    text-transform: uppercase;
    letter-spacing: 3px;
    font-size: 1.3rem;
}

.avatar-selector {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

.avatar-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    font-size: 1.6rem;
    padding: 0.5rem 0;
    cursor: pointer;
    transition: all 0.15s ease;
}

.avatar-btn.selected {
    border-color: #00f2fe;
    background: rgba(0, 242, 254, 0.2);
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.5);
}

.btn-join {
    margin-top: 0.5rem;
    background: linear-gradient(135deg, #00b09b, #96c93d);
    border: none;
    color: #fff;
    padding: 1.1rem;
    border-radius: 16px;
    font-size: 1.25rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(0, 176, 155, 0.4);
    letter-spacing: 1px;
}

/* 2. KEYPAD CONTROLLER VIEW */
#view-pad {
    padding: 0.8rem;
    gap: 0.6rem;
    height: 100%;
}

.pad-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(18, 24, 38, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 0.6rem 1rem;
    backdrop-filter: blur(10px);
}

.pad-player-pill {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.pad-avatar {
    font-size: 1.8rem;
}

.pad-name {
    font-weight: 800;
    font-size: 1.1rem;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pad-stats {
    display: flex;
    gap: 0.6rem;
}

.stat-bubble {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.3rem 0.6rem;
    text-align: center;
}

.stat-bubble .lbl {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    color: #94a3b8;
}

.stat-bubble .val {
    font-family: 'Russo One', sans-serif;
    font-size: 1.1rem;
    color: #00f2fe;
}

.status-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 0.45rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: #cbd5e1;
}

.pulse-dot {
    width: 10px;
    height: 10px;
    background: #00ff88;
    border-radius: 50%;
    box-shadow: 0 0 8px #00ff88;
    animation: pulse 1.2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(1.3); }
}

/* KEYPAD 5 BUTTONS A, B, C, D, E */
.keypad-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.keypad-grid {
    flex: 1;
    display: grid;
    grid-template-rows: repeat(5, 1fr);
    gap: 0.6rem;
}

.key-btn {
    border: none;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.08s ease, filter 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 6px 0 var(--btn-shadow), 0 10px 15px rgba(0, 0, 0, 0.4);
}

.key-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 var(--btn-shadow), 0 4px 8px rgba(0, 0, 0, 0.3);
}

.key-letter {
    font-family: 'Russo One', sans-serif;
    font-size: 2.8rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Individual Key Button Styles */
.key-a {
    background: linear-gradient(180deg, #f1c40f, #d4ac0d);
    color: #1a1a1a;
    --btn-shadow: var(--shadow-a);
}

.key-b {
    background: linear-gradient(180deg, #3498db, #2980b9);
    color: #ffffff;
    --btn-shadow: var(--shadow-b);
}

.key-c {
    background: linear-gradient(180deg, #e67e22, #d35400);
    color: #ffffff;
    --btn-shadow: var(--shadow-c);
}

.key-d {
    background: linear-gradient(180deg, #2ecc71, #27ae60);
    color: #ffffff;
    --btn-shadow: var(--shadow-d);
}

.key-e {
    background: linear-gradient(180deg, #9b59b6, #8e44ad);
    color: #ffffff;
    --btn-shadow: var(--shadow-e);
}

/* Keypad states */
.keypad-grid.locked .key-btn {
    opacity: 0.3;
    filter: grayscale(40%);
    pointer-events: none;
}

.keypad-grid.locked .key-btn.selected-key {
    opacity: 1;
    filter: none;
    transform: translateY(2px) scale(1.02);
    box-shadow: 0 0 25px currentColor;
    border: 3px solid #ffffff;
}

/* FEEDBACK OVERLAY TOAST */
.feedback-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 13, 20, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 100;
    animation: fadeIn 0.25s ease;
}

.feedback-overlay.hidden {
    display: none;
}

.feedback-card {
    background: var(--bg-card);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    padding: 2rem 1.5rem;
    text-align: center;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
}

.feedback-icon {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
}

.feedback-title {
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 0.5rem;
}

.feedback-msg {
    font-size: 1.05rem;
    color: #94a3b8;
    margin-bottom: 1rem;
}

.feedback-badge {
    display: inline-block;
    font-family: 'Russo One', sans-serif;
    font-size: 1.6rem;
    padding: 0.5rem 1.4rem;
    border-radius: 14px;
    margin-top: 0.5rem;
}

.feedback-badge.pos {
    background: rgba(0, 255, 136, 0.2);
    color: #00ff88;
    border: 1px solid #00ff88;
}

.feedback-badge.neg {
    background: rgba(255, 51, 102, 0.2);
    color: #ff3366;
    border: 1px solid #ff3366;
}
