/* amaze-multiplayer Styles
 * Minimalist/Clean with 3D wall shadows
 * Mobile-first (portrait), Desktop supported
 */

:root {
    --bg: #fafafa;
    --bg-card: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --danger: #EF4444;
    --success: #10B981;
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    
    /* Player colors - will be overridden dynamically */
    --color-p1: #FF6B6B;
    --color-p2: #4ECDC4;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

#app {
    height: 100%;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

/* Screen management */
.screen {
    display: none;
    position: absolute;
    inset: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* ========== START SCREEN ========== */
.start-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 40px 24px;
    text-align: center;
}

.logo {
    font-size: 56px;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--text);
    margin-bottom: 4px;
}

.logo-highlight {
    color: var(--primary);
    position: relative;
}

.subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-weight: 500;
}

.maze-preview {
    width: 120px;
    height: 120px;
    margin-bottom: 32px;
    opacity: 0.6;
}

.maze-preview canvas {
    width: 100%;
    height: 100%;
}

.start-actions {
    width: 100%;
    max-width: 320px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 15px;
    padding: 12px 24px;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.97);
}

.btn-large {
    width: 100%;
    padding: 16px 24px;
    font-size: 17px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-primary:disabled {
    background: #c7c9d1;
    box-shadow: none;
    cursor: not-allowed;
}

.btn-secondary {
    background: white;
    color: var(--text);
    border: 1.5px solid var(--border);
}

.btn-secondary:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.btn-small {
    padding: 8px 14px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

.btn-icon {
    font-size: 18px;
}

.divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 13px;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider span {
    padding: 0 12px;
}

.join-section {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.input-code {
    flex: 1;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    letter-spacing: 8px;
    text-transform: uppercase;
    background: white;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}

.input-code:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.input-code::placeholder {
    letter-spacing: 2px;
    font-weight: 400;
    font-size: 14px;
    color: var(--text-muted);
}

.name-section {
    margin-top: 12px;
}

.input-name {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 15px;
    background: white;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}

.input-name:focus {
    border-color: var(--primary);
}

.hint {
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ========== LOBBY SCREEN ========== */
.lobby-container {
    padding: 20px 16px;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.lobby-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.lobby-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.btn-back {
    background: none;
    border: none;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px 0;
}

.room-code-display {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.code-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.code-value {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 4px;
    color: var(--primary);
}

/* Difficulty selector */
.difficulty-selector {
    margin-bottom: 20px;
}

.difficulty-selector label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.diff-options {
    display: flex;
    gap: 8px;
}

.diff-btn {
    flex: 1;
    padding: 10px 4px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.diff-btn.active {
    border-color: var(--primary);
    background: #EEF2FF;
    color: var(--primary);
}

.diff-size {
    font-size: 10px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Players list */
.players-list {
    flex: 1;
    margin-bottom: 16px;
}

.player-item {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    margin-bottom: 8px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    gap: 12px;
}

.player-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.player-name {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
}

.player-badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.player-badge.host {
    background: #EEF2FF;
    color: var(--primary);
}

.player-badge.you {
    background: #F0FDF4;
    color: var(--success);
}

.player-ready {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.player-ready.ready {
    background: var(--success);
}

.player-ready.not-ready {
    background: var(--border);
}

/* Share section */
.share-section {
    margin-bottom: 16px;
}

.share-section p {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.share-link-box {
    display: flex;
    gap: 8px;
}

.share-link-box input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 12px;
    background: var(--bg);
    color: var(--text-secondary);
}

.btn-start {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    margin-top: auto;
}

/* ========== GAME SCREEN ========== */
.game-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Progress bars (compact, top) */
.progress-bars {
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: white;
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.progress-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.progress-item .p-name {
    min-width: 50px;
    font-weight: 600;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-item .p-bar-bg {
    flex: 1;
    height: 14px;
    background: #f3f4f6;
    border-radius: 7px;
    overflow: hidden;
    position: relative;
}

.progress-item .p-bar-fill {
    height: 100%;
    border-radius: 7px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-item .p-bar-fill::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 4px;
    right: 4px;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
}

.progress-item .p-pct {
    min-width: 36px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-align: right;
}

.progress-item.you .p-name {
    color: var(--primary);
}

.progress-item.finished .p-bar-fill {
    opacity: 0.7;
}

.progress-item.finished .p-pct::after {
    content: ' ✓';
    color: var(--success);
}

/* Canvas */
.canvas-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    overflow: hidden;
}

#game-canvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
}

/* Countdown overlay */
.countdown-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    backdrop-filter: blur(4px);
}

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

.countdown-number {
    font-size: 96px;
    font-weight: 800;
    color: white;
    text-shadow: 0 4px 20px rgba(0,0,0,0.3);
    animation: countPulse 0.5s ease;
}

@keyframes countPulse {
    0% { transform: scale(1.5); opacity: 0; }
    50% { transform: scale(0.95); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Touch hint */
.touch-hint {
    text-align: center;
    padding: 8px;
    font-size: 12px;
    color: var(--text-muted);
    background: white;
    border-top: 1px solid var(--border);
}

/* Finish countdown */
.finish-countdown {
    position: absolute;
    bottom: 40px;
    left: 16px;
    right: 16px;
    background: white;
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
}

.finish-countdown.hidden {
    display: none;
}

.finish-countdown-bar {
    height: 6px;
    background: var(--danger);
    border-radius: 3px;
    transition: width 1s linear;
}

.finish-countdown-text {
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    margin-top: 6px;
    color: var(--danger);
}

/* ========== RESULTS SCREEN ========== */
.results-container {
    padding: 32px 20px;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.results-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 24px;
}

.podium {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 24px;
    height: 160px;
}

.podium-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.podium-bar {
    width: 80px;
    border-radius: 8px 8px 0 0;
    transition: height 0.5s ease;
}

.podium-rank {
    font-size: 24px;
    font-weight: 800;
}

.podium-name {
    font-size: 13px;
    font-weight: 600;
}

.podium-pct {
    font-size: 11px;
    color: var(--text-secondary);
}

.results-list {
    width: 100%;
    max-width: 300px;
    margin-bottom: 24px;
}

.result-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    margin-bottom: 6px;
    background: white;
    border-radius: var(--radius-sm);
    gap: 10px;
    font-size: 14px;
    box-shadow: var(--shadow-sm);
}

.result-rank {
    font-weight: 800;
    font-size: 16px;
    min-width: 24px;
}

.result-name {
    flex: 1;
    font-weight: 600;
}

.result-pct {
    font-weight: 700;
    color: var(--text-secondary);
}

.results-actions {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 300px;
}

.results-actions .btn {
    flex: 1;
}

/* ========== RESPONSIVE - DESKTOP ========== */
@media (min-width: 768px) {
    #app {
        max-width: 520px;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
        box-shadow: 0 0 40px rgba(0,0,0,0.05);
    }
    
    .touch-hint {
        display: none;
    }
    
    .canvas-wrapper {
        padding: 12px;
    }
}

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

.screen.active {
    animation: fadeIn 0.25s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

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