/* ============================================
   Lucky Wheel Picker - Stylesheet
   ============================================ */

:root {
    --bg-dark: #0a0a1a;
    --bg-panel: #1a1a2e;
    --bg-card: #16213e;
    --neon-pink: #ff00ff;
    --neon-cyan: #00ffff;
    --neon-purple: #8b00ff;
    --neon-magenta: #ff0080;
    --text-primary: #ffffff;
    --text-secondary: #b0b0cc;
    --accent: #ff00ff;
    --accent-glow: rgba(255, 0, 255, 0.4);
    --rim-color: #ff69b4;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        radial-gradient(ellipse at 50% 50%, rgba(139, 0, 255, 0.08) 0%, transparent 70%);
}

/* ============================================
   Winner Banner
   ============================================ */
.winner-banner {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-200%);
    z-index: 1000;
    text-align: center;
    padding: clamp(12px, 1.5vw, 24px) clamp(30px, 5vw, 80px);
    width: clamp(400px, 50vw, 800px);
    max-width: 92vw;
    background: linear-gradient(135deg, rgba(255, 0, 128, 0.92), rgba(139, 0, 255, 0.92));
    backdrop-filter: blur(10px);
    border-radius: 60px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.5), 0 0 60px rgba(139, 0, 255, 0.3);
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.winner-banner.show {
    transform: translateX(-50%) translateY(0);
}

.winner-text {
    font-size: clamp(1.4rem, 2.5vw, 2.8rem);
    font-weight: 900;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.8), 0 0 40px var(--neon-pink);
    letter-spacing: 2px;
    animation: winnerPulse 0.5s ease-in-out infinite alternate;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@keyframes winnerPulse {
    from { text-shadow: 0 0 20px rgba(255, 255, 255, 0.8), 0 0 40px var(--neon-pink); }
    to { text-shadow: 0 0 30px rgba(255, 255, 255, 1), 0 0 60px var(--neon-pink), 0 0 80px var(--neon-cyan); }
}

/* ============================================
   Current Name Display (during spin)
   ============================================ */
.current-name-display {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    background: rgba(10, 10, 26, 0.85);
    border: 2px solid var(--neon-pink);
    border-radius: 50px;
    padding: clamp(8px, 1vw, 16px) clamp(25px, 4vw, 65px);
    font-size: clamp(1.2rem, 2.2vw, 2.5rem);
    font-weight: 700;
    text-align: center;
    width: clamp(360px, 45vw, 720px);
    max-width: 92vw;
    box-shadow: 0 0 20px var(--accent-glow), inset 0 0 20px rgba(255, 0, 255, 0.1);
    transition: opacity 0.3s ease;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.current-name-display.hidden {
    display: none;
}

/* ============================================
   Main Container
   ============================================ */
.main-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px 10px;
}

/* ============================================
   Input Panel
   ============================================ */
.input-panel {
    width: 480px;
    max-width: 95vw;
    background: var(--bg-panel);
    border-radius: 20px;
    padding: 40px 30px;
    border: 1px solid rgba(255, 0, 255, 0.2);
    box-shadow: 0 0 40px rgba(139, 0, 255, 0.15);
    overflow: hidden;
}

.title {
    font-size: 2rem;
    text-align: center;
    background: linear-gradient(90deg, var(--neon-pink), var(--neon-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 0.95rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 0, 255, 0.3);
}

.tab {
    flex: 1;
    padding: 12px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.tab.active {
    background: linear-gradient(135deg, var(--neon-magenta), var(--neon-purple));
    color: white;
}

.tab:hover:not(.active) {
    background: rgba(255, 0, 255, 0.1);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed rgba(255, 0, 255, 0.4);
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 0, 255, 0.03);
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--neon-pink);
    background: rgba(255, 0, 255, 0.08);
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.15);
}

.drop-zone-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.drop-zone p {
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.drop-zone-hint {
    font-size: 0.85rem;
    opacity: 0.6;
}

.file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(0, 255, 255, 0.08);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 10px;
    margin-top: 12px;
}

.file-info.hidden {
    display: none;
}

.btn-small {
    padding: 4px 12px;
    background: rgba(255, 0, 128, 0.2);
    border: 1px solid var(--neon-magenta);
    color: var(--neon-magenta);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-small:hover {
    background: rgba(255, 0, 128, 0.4);
}

.format-hint {
    margin-top: 16px;
    padding: 12px;
    background: rgba(139, 0, 255, 0.08);
    border-radius: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Manual Form */
.manual-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-row {
    display: flex;
    gap: 10px;
    width: 100%;
    align-items: center;
}

.form-input {
    flex: 1;
    min-width: 0;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 0, 255, 0.2);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.3s;
}

.form-input:focus {
    border-color: var(--neon-pink);
    box-shadow: 0 0 10px rgba(255, 0, 255, 0.2);
}

.form-input-small {
    flex: 0.6;
}

.form-input::placeholder {
    color: rgba(176, 176, 204, 0.5);
}

select.form-input {
    cursor: pointer;
}

select.form-input option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-add {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--neon-magenta), var(--neon-purple));
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-add:hover {
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-1px);
}

/* Student List */
.student-list-container {
    margin-top: 20px;
}

.student-list-container.hidden {
    display: none;
}

.student-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.student-list-container h3 {
    font-size: 1rem;
    color: var(--text-secondary);
}

.btn-clear-all {
    padding: 4px 14px;
    background: rgba(255, 68, 68, 0.12);
    border: 1px solid rgba(255, 68, 68, 0.4);
    color: #ff6666;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-clear-all:hover {
    background: rgba(255, 68, 68, 0.25);
    border-color: #ff6666;
}

.student-list {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 4px;
}

.student-list::-webkit-scrollbar {
    width: 6px;
}

.student-list::-webkit-scrollbar-thumb {
    background: rgba(255, 0, 255, 0.3);
    border-radius: 3px;
}

.student-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid rgba(255, 0, 255, 0.1);
    font-size: 0.9rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.student-item-info {
    display: flex;
    gap: 12px;
    align-items: center;
    min-width: 0;
    overflow: hidden;
    flex: 1;
}

.student-item-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.student-item-id {
    color: var(--neon-cyan);
    font-size: 0.85rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.student-item-gender {
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(139, 0, 255, 0.2);
    white-space: nowrap;
    flex-shrink: 0;
}

.student-item-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}

.btn-edit {
    background: rgba(68, 204, 255, 0.1);
    border: 1px solid rgba(68, 204, 255, 0.4);
    color: #66ccff;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 6px;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-edit:hover {
    color: #44ccff;
    background: rgba(68, 204, 255, 0.25);
    border-color: #44ccff;
}

.btn-delete {
    background: none;
    border: none;
    color: rgba(255, 100, 100, 0.7);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 3px 6px;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-delete:hover {
    color: #ff4444;
    background: rgba(255, 68, 68, 0.15);
}

.btn-cancel-edit {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-cancel-edit:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.btn-cancel-edit.hidden {
    display: none;
}

.btn-add.editing {
    background: linear-gradient(135deg, #00ccaa, #0088ff);
}

.student-item.editing {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.15);
}

/* Order Toggle */
.order-toggle {
    display: flex;
    gap: 0;
    margin-top: 16px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 0, 255, 0.3);
}

.order-toggle.hidden {
    display: none;
}

.order-option {
    flex: 1;
    padding: 10px 8px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.order-option.active {
    background: linear-gradient(135deg, var(--neon-magenta), var(--neon-purple));
    color: white;
}

.order-option:hover:not(.active) {
    background: rgba(255, 0, 255, 0.1);
}

/* Load Button */
.btn-load {
    display: block;
    width: 100%;
    margin-top: 20px;
    padding: 16px;
    background: linear-gradient(135deg, var(--neon-magenta), var(--neon-purple));
    border: none;
    border-radius: 14px;
    color: white;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    letter-spacing: 1px;
    transition: all 0.3s;
    box-shadow: 0 4px 20px rgba(255, 0, 128, 0.3);
}

.btn-load:hover {
    box-shadow: 0 4px 30px rgba(255, 0, 128, 0.5);
    transform: translateY(-2px);
}

.btn-load.hidden {
    display: none;
}

/* ============================================
   Wheel Container
   ============================================ */
.wheel-container {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    height: 100vh;
    padding: 100px 10px 10px;
    overflow: hidden;
}

.wheel-container.hidden {
    display: none;
}

/* Wheel Stage: wheel + sidebar side by side */
.wheel-stage {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 16px;
    width: 100%;
    height: 100%;
}

/* Wheel Frame: fill remaining space after sidebar */
.wheel-frame {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    aspect-ratio: 1 / 1;
    max-height: 100%;
    align-self: center;
}

/* Right Sidebar: controls + history stacked vertically */
.wheel-sidebar {
    display: flex;
    flex-direction: column;
    gap: clamp(4px, 0.5vw, 8px);
    width: clamp(180px, 16vw, 320px);
    flex-shrink: 0;
    max-height: 100%;
    overflow: hidden;
    font-size: clamp(0.7rem, 0.9vw, 1rem);
}

.btn-back {
    background: var(--bg-panel);
    border: 1px solid rgba(255, 0, 255, 0.3);
    color: var(--text-secondary);
    padding: clamp(6px, 0.6vw, 12px) 0;
    border-radius: 8px;
    cursor: pointer;
    font-size: clamp(0.72rem, 0.9vw, 1rem);
    font-weight: 600;
    transition: all 0.3s;
    text-align: center;
    width: 100%;
}

.btn-back:hover {
    border-color: var(--neon-pink);
    color: white;
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.2);
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    gap: 6px;
    width: 100%;
}

.btn-mode {
    flex: 1;
    min-width: 0;
    background: rgba(139, 0, 255, 0.2);
    border: 1px solid var(--neon-purple);
    color: var(--neon-cyan);
    padding: clamp(6px, 0.6vw, 12px) clamp(2px, 0.3vw, 6px);
    border-radius: 8px;
    cursor: pointer;
    font-size: clamp(0.68rem, 0.85vw, 0.95rem);
    font-weight: 700;
    transition: all 0.3s;
    text-align: center;
}

.btn-mode:hover {
    background: rgba(139, 0, 255, 0.4);
    box-shadow: 0 0 12px rgba(139, 0, 255, 0.3);
}

.btn-mode.no-repeat {
    border-color: var(--neon-cyan);
    background: rgba(0, 255, 255, 0.15);
}

.btn-clear-memory {
    flex: 1;
    min-width: 0;
    background: rgba(255, 68, 68, 0.15);
    border: 1px solid rgba(255, 68, 68, 0.5);
    color: #ff6666;
    padding: clamp(6px, 0.6vw, 12px) clamp(2px, 0.3vw, 6px);
    border-radius: 8px;
    cursor: pointer;
    font-size: clamp(0.68rem, 0.85vw, 0.95rem);
    font-weight: 600;
    transition: all 0.3s;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-clear-memory:hover {
    background: rgba(255, 68, 68, 0.3);
}

.btn-clear-memory.hidden {
    display: none;
}

/* Full-window glow projection canvas */
.glow-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

@media (max-width: 700px) {
    .wheel-stage {
        flex-direction: column;
        align-items: center;
    }
    .wheel-frame {
        width: 90vw;
        max-height: none;
        flex: none;
    }
    .wheel-sidebar {
        width: 90vw;
    }
}

/* ============================================
   History Panel
   ============================================ */
.history-panel {
    width: 100%;
    min-height: 0;
    background: var(--bg-panel);
    border: 1px solid rgba(255, 0, 255, 0.15);
    border-radius: 16px;
    padding: clamp(10px, 1vw, 18px);
    overflow-y: auto;
    flex: 1 1 0;
}

.history-title {
    font-size: clamp(0.8rem, 1vw, 1.15rem);
    color: var(--text-secondary);
    margin-bottom: clamp(8px, 0.8vw, 14px);
    text-align: center;
    letter-spacing: 1px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: clamp(6px, 0.6vw, 12px) clamp(8px, 0.7vw, 14px);
    background: var(--bg-card);
    border-radius: 8px;
    border-left: 3px solid var(--neon-pink);
    font-size: clamp(0.7rem, 0.85vw, 1rem);
    animation: slideIn 0.3s ease;
}

.history-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.history-item-number {
    color: var(--neon-cyan);
    font-weight: 700;
    font-size: clamp(0.65rem, 0.8vw, 0.92rem);
    flex-shrink: 0;
}

.history-item-name {
    font-weight: 600;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-id {
    color: var(--text-secondary);
    font-size: clamp(0.65rem, 0.8vw, 0.92rem);
    font-weight: 400;
}

.history-item-time {
    color: var(--text-secondary);
    font-size: clamp(0.55rem, 0.7vw, 0.8rem);
    opacity: 0.7;
}

.history-panel::-webkit-scrollbar {
    width: 4px;
}

.history-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 0, 255, 0.3);
    border-radius: 2px;
}

@media (max-width: 900px) {
    .history-panel {
        max-height: 40vh;
    }
}

/* Indicator Arrow */
.indicator-arrow {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    transform-origin: 50% 0%;  /* pivot from the top edge */
    z-index: 20;
    width: 0;
    height: 0;
    border-left: clamp(12px, 1.6vmin, 22px) solid transparent;
    border-right: clamp(12px, 1.6vmin, 22px) solid transparent;
    border-top: clamp(26px, 3.6vmin, 48px) solid #ffffff;
    transition: transform 0.05s ease-out;
}

.indicator-arrow.tick-left {
    transform: translateX(-50%) rotate(-12deg);
}

.indicator-arrow.tick-right {
    transform: translateX(-50%) rotate(12deg);
}

@keyframes ticker-wiggle {
    0%   { transform: translateX(-50%) rotate(0deg); }
    15%  { transform: translateX(-50%) rotate(-10deg); }
    35%  { transform: translateX(-50%) rotate(7deg); }
    55%  { transform: translateX(-50%) rotate(-4deg); }
    75%  { transform: translateX(-50%) rotate(2deg); }
    100% { transform: translateX(-50%) rotate(0deg); }
}

.indicator-arrow.tick {
    animation: ticker-wiggle 0.25s ease-out;
}

/* Canvas */
#wheel-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    border-radius: 50%;
}

/* Spin Button */
.btn-spin {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    width: clamp(70px, 10vmin, 130px);
    height: clamp(70px, 10vmin, 130px);
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    background: radial-gradient(circle at 40% 35%, #ff69b4, #8b00ff, #4a0080);
    color: white;
    font-size: clamp(0.9rem, 1.3vmin, 1.5rem);
    font-weight: 900;
    letter-spacing: 2px;
    cursor: pointer;
    box-shadow:
        0 0 20px rgba(255, 0, 255, 0.5),
        0 0 40px rgba(139, 0, 255, 0.3),
        inset 0 -4px 10px rgba(0, 0, 0, 0.3),
        inset 0 4px 10px rgba(255, 255, 255, 0.2);
    transition: all 0.3s;
    animation: spinButtonPulse 2s ease-in-out infinite;
}

@keyframes spinButtonPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 0, 255, 0.5), 0 0 40px rgba(139, 0, 255, 0.3), inset 0 -4px 10px rgba(0, 0, 0, 0.3), inset 0 4px 10px rgba(255, 255, 255, 0.2); }
    50% { box-shadow: 0 0 30px rgba(255, 0, 255, 0.7), 0 0 60px rgba(139, 0, 255, 0.5), inset 0 -4px 10px rgba(0, 0, 0, 0.3), inset 0 4px 10px rgba(255, 255, 255, 0.2); }
}

.btn-spin:hover {
    transform: translate(-50%, -50%) scale(1.08);
    box-shadow:
        0 0 30px rgba(255, 0, 255, 0.8),
        0 0 60px rgba(139, 0, 255, 0.5),
        inset 0 -4px 10px rgba(0, 0, 0, 0.3),
        inset 0 4px 10px rgba(255, 255, 255, 0.2);
}

.btn-spin:active {
    /* Overridden by JS charging animation */
}

.btn-spin.spinning {
    cursor: default;
    animation: none;
}

.spin-text {
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

/* ============================================
   Confetti Canvas
   ============================================ */
.confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 900;
}

/* ============================================
   Hidden utility
   ============================================ */
.hidden {
    display: none !important;
}

/* ============================================
   Animations
   ============================================ */
@keyframes neonFlicker {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
        opacity: 1;
    }
    20%, 24%, 55% {
        opacity: 0.6;
    }
}

/* Smooth transition for panel switching */
.input-panel, .wheel-container {
    transition: opacity 0.4s ease;
}

/* Scrollbar styles */
body::-webkit-scrollbar {
    width: 8px;
}

body::-webkit-scrollbar-thumb {
    background: rgba(255, 0, 255, 0.3);
    border-radius: 4px;
}

body::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
