/* ==========================================================================
   Name Picker Tool - Modern Glass-morphism Design
   Following virtual-bouncy-balls pattern
   ========================================================================== */

.np-container {
    --primary-color: #15aebf;
    --primary-light: #4ecdc4;
    --primary-dark: #0e9bb2;
    --secondary-color: #ff6b35;
    --secondary-light: #ff8c5a;
    --accent-color: #ffd93d;
    --success-color: #00b894;
    --danger-color: #e17055;
    --warning-color: #fdcb6e;
    --white: #ffffff;
    --gray-100: #f1f3f4;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.25rem;
    --radius-full: 9999px;
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --bg-gradient: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
}

.np-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 95vh;
    padding: 4.5rem;
    gap: 0;
    background: #ffffff;
    align-items: center;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
}

.np-game-container {
    position: relative;
    width: 100%;
    height: 100%;
    flex: 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    overflow: hidden;
    min-height: 400px;
    border-radius: var(--radius-xl);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Watermark */
.np-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    opacity: 0.08;
    pointer-events: none;
    z-index: 1;
    filter: brightness(2);
}

/* Top overlay - controls only */
.np-top-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    z-index: 100;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.2) 80%, transparent 100%);
}

.np-top-overlay > * {
    pointer-events: auto;
}

.np-top-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.np-result-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}

/* Controls */
.np-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.375rem;
    align-items: center;
}

.np-file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
}

.np-file-input-wrapper input[type=file] {
    position: absolute;
    left: -9999px;
    opacity: 0;
    width: 0.1px;
    height: 0.1px;
    pointer-events: none;
}

.np-input-group {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.np-name-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    width: 140px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--white);
    transition: all 0.2s ease;
}

.np-name-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.np-name-input:focus {
    outline: none;
    border-color: var(--primary-light);
    background: rgba(255, 255, 255, 0.25);
}

/* Button styles */
.np-btn {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.8125rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
}

.np-btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
}

.np-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    color: var(--white);
}

.np-btn-file {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5252 100%);
    color: white;
    border-color: #ff8a75;
}

.np-btn-file:hover {
    background: linear-gradient(135deg, #ff5252 0%, #d43d3d 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
    color: white;
}

.np-btn-add {
    background: linear-gradient(135deg, #a18cd1 0%, #9b59b6 100%);
    color: white;
    border-color: #b8a4d9;
}

.np-btn-add:hover {
    background: linear-gradient(135deg, #9176c0 0%, #8e44ad 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(155, 89, 182, 0.4);
    color: white;
}

.np-btn-pick {
    background: var(--bg-gradient);
    color: white;
    border-color: var(--primary-light);
    padding: 0.5rem 1rem;
}

.np-btn-pick:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(21, 174, 191, 0.4);
    color: white;
}

.np-btn-pick:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Stats */
.np-stats {
    display: flex;
    gap: 0.375rem;
    flex-shrink: 0;
}

.np-stat-card {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.np-stat-value {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--white);
}

.np-stat-label {
    font-size: 0.5625rem;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Result display */
.np-result {
    padding: 0.375rem 0.875rem;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--radius-lg);
    font-size: 0.8125rem;
    font-weight: 600;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--white);
    text-align: center;
}

.np-result-success {
    background: rgba(0, 184, 148, 0.4);
    border-color: var(--success-color);
    color: #7dffcc;
}

.np-result-error {
    background: rgba(225, 112, 85, 0.4);
    border-color: var(--danger-color);
    color: #ffb8a8;
}

.np-result-info {
    background: rgba(78, 205, 196, 0.3);
    border-color: var(--primary-light);
    color: #a8f0ec;
}

.np-result-picking {
    background: rgba(253, 203, 110, 0.4);
    border-color: var(--warning-color);
    color: #fff3cd;
    animation: np-pulse 1s ease-in-out infinite;
}

.np-result-winner {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.5) 0%, rgba(255, 165, 0, 0.5) 100%);
    border-color: #ffd700;
    color: #fff;
    font-size: 1rem;
    animation: np-winner-glow 0.5s ease-in-out infinite alternate;
}

@keyframes np-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.02); }
}

@keyframes np-winner-glow {
    0% { box-shadow: 0 0 10px rgba(255, 215, 0, 0.5); }
    100% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 165, 0, 0.4); }
}

/* Crane system */
.np-crane-container {
    position: absolute;
    top: 95px;
    width: 100%;
    height: calc(100% - 95px);
    z-index: 20;
    pointer-events: none;
}

.np-crane {
    pointer-events: auto;
}

.np-crane-track {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    background: linear-gradient(180deg, #555 0%, #333 50%, #555 100%);
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.1);
}

.np-crane {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 70px;
    height: 80px;
    transition: left 1s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.np-crane-head {
    width: 70px;
    height: 18px;
    background: linear-gradient(180deg, #ff6b6b 0%, #ee5252 100%);
    border-radius: 9px;
    position: relative;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.np-crane-cable {
    width: 6px;
    height: 80px;
    background: linear-gradient(90deg, #222 0%, #555 50%, #222 100%);
    margin: 0 auto;
    transition: height 0.8s cubic-bezier(0.25, 0.1, 0.25, 1);
    position: relative;
    max-height: 90vh;
    border-radius: 3px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.np-crane-hook {
    width: 50px;
    height: 12px;
    background: linear-gradient(180deg, #888 0%, #666 100%);
    border-radius: 12px 12px 0 0;
    margin: 0 auto;
    position: relative;
    top: -6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.np-picked-ball {
    position: absolute;
    bottom: -70px;
    left: 50%;
    transform: translateX(-50%);
    width: 70px;
    height: 70px;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
    color: var(--white);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.2;
    word-wrap: break-word;
    z-index: 25;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4), 0 0 30px rgba(255, 255, 255, 0.2);
    padding: 5px;
    animation: np-picked-glow 0.5s ease-in-out infinite alternate;
}

@keyframes np-picked-glow {
    0% { box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4), 0 0 20px rgba(255, 255, 255, 0.2); }
    100% { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 40px rgba(255, 255, 255, 0.4); }
}

/* Balls container */
.np-balls-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    top: 95px;
    overflow: hidden;
}

/* Ball styles */
.np-ball {
    position: absolute;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: var(--white);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 -3px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    text-align: center;
    line-height: 1.2;
    word-wrap: break-word;
    overflow: hidden;
    z-index: 10;
    padding: 5px;
    will-change: transform;
}

.np-ball:hover {
    filter: brightness(1.1);
}

/* Ball animations - use opacity only to avoid transform conflicts */
@keyframes np-ball-create {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.np-ball-created {
    animation: np-ball-create 0.3s ease-out;
}

@keyframes np-ball-remove {
    0% { opacity: 1; }
    100% { opacity: 0; transform: scale(0); }
}

.np-ball-removing {
    animation: np-ball-remove 0.4s ease-in forwards;
}

@keyframes np-ball-pick {
    0% { opacity: 1; }
    30% { transform: scale(1.15); filter: brightness(1.2); opacity: 1; }
    100% { transform: scale(0.3); opacity: 0; }
}

.np-ball-picked {
    animation: np-ball-pick 0.6s ease-out forwards;
    z-index: 30;
}

/* Fullscreen adjustments */
.tool-page-wrapper:fullscreen .np-crane,
.tool-page-wrapper:-webkit-full-screen .np-crane,
.tool-page-wrapper:-moz-full-screen .np-crane {
    width: 85px;
}

.tool-page-wrapper:fullscreen .np-crane-head,
.tool-page-wrapper:-webkit-full-screen .np-crane-head,
.tool-page-wrapper:-moz-full-screen .np-crane-head {
    width: 85px;
    height: 20px;
    border-radius: 10px;
}

.tool-page-wrapper:fullscreen .np-crane-cable,
.tool-page-wrapper:-webkit-full-screen .np-crane-cable,
.tool-page-wrapper:-moz-full-screen .np-crane-cable {
    max-height: none;
    width: 7px;
}

.tool-page-wrapper:fullscreen .np-crane-hook,
.tool-page-wrapper:-webkit-full-screen .np-crane-hook,
.tool-page-wrapper:-moz-full-screen .np-crane-hook {
    width: 65px;
    height: 14px;
}

.tool-page-wrapper:fullscreen .np-ball,
.tool-page-wrapper:-webkit-full-screen .np-ball,
.tool-page-wrapper:-moz-full-screen .np-ball {
    width: 90px;
    height: 90px;
    font-size: 12px;
    padding: 6px;
}

.tool-page-wrapper:fullscreen .np-picked-ball,
.tool-page-wrapper:-webkit-full-screen .np-picked-ball,
.tool-page-wrapper:-moz-full-screen .np-picked-ball {
    width: 90px;
    height: 90px;
    font-size: 12px;
    bottom: -95px;
}

/* RTL support */
[dir="rtl"] .np-wrapper {
    direction: rtl;
}

/* Responsive */
@media (max-width: 600px) {
    .np-wrapper { padding: 1.5rem; }
    .np-top-overlay { padding: 0.375rem 0.5rem; gap: 0.25rem; }
    .np-top-row { gap: 0.375rem; }
    .np-result-row { gap: 0.375rem; }
    .np-result { font-size: 0.6875rem; padding: 0.25rem 0.5rem; }
    .np-btn { padding: 0.375rem 0.5rem; font-size: 0.6875rem; }
    .np-btn span:last-child { display: none; }
    .np-btn-pick span:last-child,
    .np-btn-file span:last-child { display: inline; }
    .np-name-input { width: 90px; font-size: 0.6875rem; padding: 0.375rem 0.5rem; }
    .np-stat-card { padding: 0.1875rem 0.375rem; }
    .np-stat-value { font-size: 0.6875rem; }
    .np-stat-label { font-size: 0.5rem; }
    .np-ball { width: 60px; height: 60px; font-size: 9px; }
    .np-picked-ball { width: 65px; height: 65px; font-size: 10px; bottom: -70px; }
    .np-crane { width: 60px; }
    .np-crane-head { width: 60px; height: 14px; }
    .np-crane-hook { width: 45px; height: 10px; }
    .np-crane-container { top: 80px; }
    .np-balls-container { top: 80px; }
}

@media (prefers-reduced-motion: reduce) {
    .np-ball-created,
    .np-ball-removing,
    .np-ball-picked { animation: none; }
    .np-result-picking { animation: none; }
    .np-result-winner { animation: none; }
    .np-picked-ball { animation: none; }
}
