/* Take It Easy - Elm Frontend Styles */
/* Design glassmorphism avec thème teal/cyan */

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #fff;
}

/* ============================================================================
   GLASS CONTAINER
   ============================================================================ */

.glass-container {
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.5rem;
}

/* ============================================================================
   APP CONTAINER
   ============================================================================ */

.app-container {
    min-height: 100vh;
    padding: 2rem;
}

/* ============================================================================
   AUTH PAGE
   ============================================================================ */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-container {
    max-width: 400px;
    width: 100%;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #4ecdc4 0%, #a8edea 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
}

.auth-error {
    background: rgba(255, 107, 107, 0.2);
    border: 1px solid rgba(255, 107, 107, 0.4);
    color: #ff6b6b;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.auth-success {
    background: rgba(107, 255, 148, 0.2);
    border: 1px solid rgba(107, 255, 148, 0.4);
    color: #6bff94;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.forgot-password-link,
.back-to-login {
    text-align: center;
    margin-top: 0.5rem;
}

.link-button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: underline;
    padding: 0;
}

.link-button:hover {
    color: white;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}

.form-group input {
    padding: 0.75rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 1rem;
    transition: border-color 0.2s, background 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #4ecdc4;
    background: rgba(255, 255, 255, 0.1);
}

.form-group input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.form-group input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-submit-button {
    background: linear-gradient(135deg, #4ecdc4 0%, #45b7aa 100%);
    color: #1a1a2e;
    border: none;
    border-radius: 10px;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 0.5rem;
}

.auth-submit-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(78, 205, 196, 0.4);
}

.auth-submit-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    color: rgba(255, 255, 255, 0.7);
}

.auth-switch-button {
    background: none;
    border: none;
    color: #4ecdc4;
    cursor: pointer;
    font-size: 1rem;
    margin-left: 0.25rem;
    text-decoration: underline;
}

.auth-switch-button:hover {
    color: #a8edea;
}

.auth-skip {
    text-align: center;
    margin-top: 1rem;
}

.skip-button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.7);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.skip-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
    color: #fff;
}

/* Welcome / Landing Page */
.welcome-content {
    text-align: center;
    padding: 1rem 0;
}

.welcome-pitch {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.05rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.welcome-play-button {
    background: linear-gradient(135deg, #4ecdc4 0%, #45b7aa 100%);
    color: #1a1a2e;
    border: none;
    border-radius: 12px;
    padding: 1rem 2.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 20px rgba(78, 205, 196, 0.35);
}

.welcome-play-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(78, 205, 196, 0.5);
}

.welcome-separator {
    color: rgba(255, 255, 255, 0.4);
    margin: 1.25rem 0;
    font-size: 0.9rem;
}

.welcome-links {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

/* Welcome Tile Preview (above board during placement phase) */
.welcome-tile-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    opacity: 1;
    animation: previewFadeOut 0.5s ease-out forwards;
    animation-delay: 7.8s;
}

.preview-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.05em;
}

.preview-tile-area {
    position: relative;
    width: 72px;
    height: 63px;
}

.preview-tile {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    animation: previewShow 0.4s step-end none;
}

.preview-tile.preview-last {
    animation-duration: 0.8s;
}

.preview-arrow {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.4);
    line-height: 1;
}

@keyframes previewShow {
    from { opacity: 1; }
    to { opacity: 1; }
}

@keyframes previewFadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Welcome Hero Board Animation */
.welcome-board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1.5rem;
}

.welcome-hex-board {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    margin: 0 auto;
    overflow: visible;
}

.welcome-tile {
    opacity: 0;
    transform: translateY(-80px) scale(0.6);
    animation: tileAppear 0.6s ease-out forwards;
}

@keyframes tileAppear {
    0% {
        opacity: 0;
        transform: translateY(-80px) scale(0.6);
    }
    40% {
        opacity: 1;
        transform: translateY(-10px) scale(0.98);
    }
    70% {
        opacity: 1;
        transform: translateY(4px) scale(1.01);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Direction labels above the board */
.welcome-direction-labels {
    height: 28px;
    position: relative;
    width: 320px;
    margin-bottom: 0.25rem;
}

.direction-label {
    position: absolute;
    width: 100%;
    opacity: 0;
    animation: scoringGlow 2s ease-in-out forwards;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    letter-spacing: 0.05em;
}

.direction-label.phase-v1 { color: #f0d000; }
.direction-label.phase-v2 { color: #4ecdc4; }
.direction-label.phase-v3 { color: #ff69b4; }

/* Scoring overlay on hex cells */
.scoring-overlay {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 8px;
    pointer-events: none;
    opacity: 0;
    animation: scoringGlow 2s ease-in-out forwards;
    z-index: 10;
}

.scoring-overlay.phase-v1 {
    background: rgba(240, 208, 0, 0.12);
    box-shadow: 0 0 14px rgba(240, 208, 0, 0.6);
    border: 2px solid rgba(240, 208, 0, 0.7);
}

.scoring-overlay.phase-v2 {
    background: rgba(78, 205, 196, 0.12);
    box-shadow: 0 0 14px rgba(78, 205, 196, 0.6);
    border: 2px solid rgba(78, 205, 196, 0.7);
}

.scoring-overlay.phase-v3 {
    background: rgba(255, 105, 180, 0.12);
    box-shadow: 0 0 14px rgba(255, 105, 180, 0.6);
    border: 2px solid rgba(255, 105, 180, 0.7);
}

@keyframes scoringGlow {
    0% { opacity: 0; }
    15% { opacity: 1; }
    85% { opacity: 1; }
    100% { opacity: 0; }
}

/* Score labels near scoring lines */
.score-label {
    position: absolute;
    opacity: 0;
    animation: scoringGlow 2s ease-in-out forwards;
    font-size: 0.9rem;
    font-weight: 700;
    pointer-events: none;
    z-index: 15;
}

.score-label.phase-v1 { color: #f0d000; }
.score-label.phase-v2 { color: #4ecdc4; }
.score-label.phase-v3 { color: #ff69b4; }

/* Total score */
.welcome-score {
    opacity: 0;
    animation: scoreAppear 0.8s ease-out forwards;
    margin-top: 0.75rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: #4ecdc4;
    text-align: center;
}

@keyframes scoreAppear {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #1a1a2e;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================================
   SCORES & LEADERBOARD
   ============================================================================ */

.scores-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.scores-section-single {
    grid-template-columns: 1fr;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.scores-panel {
    padding: 1.25rem;
}

.scores-panel h3 {
    text-align: center;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: #4ecdc4;
}

.scores-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.scores-table th {
    text-align: left;
    padding: 0.4rem 0.5rem;
    color: rgba(255, 255, 255, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.scores-table td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.scores-table .score-cell {
    color: #4ecdc4;
    font-weight: 600;
}

.scores-table .rank-cell {
    color: rgba(255, 255, 255, 0.5);
    width: 2rem;
}

.scores-table .date-cell {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
}

.scores-empty {
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
    padding: 1rem 0;
}

.scores-guest {
    text-align: center;
    padding: 1.25rem 0;
}

.scores-guest-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 0.5rem;
}

.scores-guest-hint {
    font-size: 0.85rem;
    color: rgba(78, 205, 196, 0.7);
}

.scores-stats {
    text-align: center;
    font-size: 0.9rem;
    color: rgba(78, 205, 196, 0.9);
    margin-bottom: 0.75rem;
}

@media (max-width: 768px) {
    .scores-section {
        grid-template-columns: 1fr;
    }
}

/* Welcome page leaderboard */
.welcome-leaderboard {
    margin-top: 1.5rem;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    max-width: 400px;
}

.welcome-leaderboard h3 {
    text-align: center;
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.85);
}

.welcome-leaderboard .scores-table {
    font-size: 0.85rem;
}

/* ============================================================================
   MODE SELECTION
   ============================================================================ */

.game-mode-selector {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.user-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.user-info, .guest-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.user-name {
    color: rgba(255, 255, 255, 0.8);
}

.logout-button, .login-link {
    background: transparent;
    border: 1px solid rgba(78, 205, 196, 0.5);
    color: #4ecdc4;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.logout-button:hover, .login-link:hover {
    background: rgba(78, 205, 196, 0.1);
}

.header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.header h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #4ecdc4 0%, #a8edea 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
}

.modes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.mode-card {
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.mode-card:hover {
    transform: translateY(-4px);
    border-color: rgba(78, 205, 196, 0.4);
    box-shadow: 0 12px 40px rgba(78, 205, 196, 0.15);
}

.mode-card.selected {
    border-color: #4ecdc4;
    box-shadow: 0 12px 40px rgba(78, 205, 196, 0.25);
    background: rgba(78, 205, 196, 0.1);
}

.difficulty-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.difficulty-easy {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.difficulty-normal {
    background: rgba(78, 205, 196, 0.2);
    color: #4ecdc4;
    border: 1px solid rgba(78, 205, 196, 0.3);
}

.difficulty-hard {
    background: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
    border: 1px solid rgba(255, 107, 107, 0.3);
}

.mode-icon {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 0.75rem;
}

.mode-card h3 {
    font-size: 1.25rem;
    text-align: center;
    margin-bottom: 0.5rem;
}

.mode-description {
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.mode-details {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    border-radius: 8px;
    text-align: center;
}

.simulations {
    color: #4ecdc4;
    font-size: 0.85rem;
    font-weight: 500;
}

.action-panel {
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

.selected-mode-info h3 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.selected-mode-info p {
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.5rem;
}

.tech-info {
    color: #4ecdc4;
    font-weight: 500;
    margin-bottom: 1rem;
}

.start-button {
    background: linear-gradient(135deg, #4ecdc4 0%, #45b7aa 100%);
    color: #1a1a2e;
    border: none;
    border-radius: 12px;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 20px rgba(78, 205, 196, 0.35);
}

.start-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(78, 205, 196, 0.5);
}

.start-icon {
    margin-left: 0.5rem;
    transition: transform 0.3s;
}

.start-button:hover .start-icon {
    transform: translateX(4px);
}

/* ============================================================================
   GAME VIEW
   ============================================================================ */

.game-container {
    max-width: 1000px;
    margin: 0 auto;
}

.header-section {
    margin-bottom: 1.5rem;
}

.title-with-back {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.8);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

.error-message {
    background: rgba(255, 107, 107, 0.2);
    border: 1px solid rgba(255, 107, 107, 0.4);
    color: #ff6b6b;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.status-message {
    background: rgba(78, 205, 196, 0.2);
    border: 1px solid rgba(78, 205, 196, 0.4);
    color: #4ecdc4;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    transition: opacity 0.3s ease;
}

/* ============================================================================
   CONNECTION INTERFACE
   ============================================================================ */

.connection-interface {
    max-width: 500px;
    margin: 0 auto;
}

.connection-interface h2 {
    margin-bottom: 1.5rem;
    text-align: center;
}

.connection-buttons {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0;
}

.create-button, .join-button {
    background: linear-gradient(135deg, #4ecdc4 0%, #45b7aa 100%);
    color: #1a1a2e;
    border: none;
    border-radius: 10px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.create-button:hover:not(:disabled), .join-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(78, 205, 196, 0.4);
}

.create-button:disabled, .join-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.join-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.join-section h3 {
    text-align: center;
    margin-bottom: 1rem;
    color: rgba(255, 255, 255, 0.8);
}

/* ============================================================================
   GAME SESSION
   ============================================================================ */

.game-session {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.session-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.session-info h2 {
    color: #4ecdc4;
}

.leave-button {
    background: transparent;
    border: 1px solid rgba(255, 107, 107, 0.5);
    color: #ff6b6b;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.leave-button:hover {
    background: rgba(255, 107, 107, 0.1);
}

.game-state {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.players-list ul {
    list-style: none;
}

.player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.player-item.self {
    border-left: 3px solid #4ecdc4;
}

.player-item.ai {
    border-left: 3px solid #a8edea;
}

.player-score {
    color: #4ecdc4;
    font-weight: 600;
}

.ready-badge {
    color: #4ade80;
    font-weight: bold;
}

/* ============================================================================
   WAITING STATE
   ============================================================================ */

.waiting-state {
    text-align: center;
}

.ready-button {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: #1a1a2e;
    border: none;
    border-radius: 10px;
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
    transition: all 0.2s;
}

.ready-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 222, 128, 0.4);
}

/* ============================================================================
   IN PROGRESS STATE
   ============================================================================ */

.in-progress-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.turn-info {
    text-align: center;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    min-height: 160px;
}

.waiting-message {
    animation: fadeIn 0.3s ease-in;
}

.turn-info h3 {
    margin-bottom: 0.25rem;
}

.current-tile {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 0 auto;
    overflow: visible;
    transition: opacity 0.2s ease;
}

.tile-image {
    position: absolute;
    top: calc(50% + 5px);
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
}

.tile-svg-container {
    width: 120px;
    height: 104px;
    margin: 0 auto;
}

.tile-svg-container svg {
    width: 100%;
    height: 100%;
}

.start-turn-button {
    background: linear-gradient(135deg, #4ecdc4 0%, #45b7aa 100%);
    color: #1a1a2e;
    border: none;
    border-radius: 10px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
}

/* ============================================================================
   HEX BOARD
   ============================================================================ */

.game-board {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hex-board {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    margin: 1rem auto;
}

/* AI board container: reset game-board layout overrides */
.ai-board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 0 auto !important;
    position: static !important;
    margin-bottom: 0 !important;
    overflow: visible !important;
    padding: 1rem !important;
}

.hex-cell {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: transform 0.2s;
    cursor: default;
    overflow: visible;
}

.hex-cell svg polygon {
    transition: fill 0.3s ease, stroke 0.3s ease;
}

.hex-cell.available {
    cursor: pointer;
}

.hex-cell.available:hover {
    transform: scale(1.05);
    z-index: 10;
}

.hex-cell.hovered-preview {
    transform: scale(1.08);
    z-index: 11;
    filter: drop-shadow(0 4px 12px rgba(78, 205, 196, 0.4));
}

.hex-tile-preview {
    opacity: 0.8;
}

.hex-cell.filled {
    background: transparent;
}

.hex-tile-svg {
    width: 100%;
    height: 100%;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.hex-tile-svg svg {
    width: 100%;
    height: 100%;
}

.hex-tile-image {
    width: 600%;
    height: 600%;
    object-fit: contain;
    z-index: 1;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.hex-index {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 1;
    position: relative;
}

/* ============================================================================
   FINISHED STATE
   ============================================================================ */

.finished-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.finished-header {
    text-align: center;
    width: 100%;
    max-width: 600px;
}

.finished-header h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #4ecdc4 0%, #a8edea 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.winner {
    font-size: 1.3rem;
    color: #4ecdc4;
    margin: 0.5rem 0;
}

.finished-content {
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
}

.final-scores {
    min-width: 250px;
    max-width: 300px;
}

.final-scores h3 {
    text-align: center;
    margin-bottom: 1rem;
    color: rgba(255, 255, 255, 0.9);
}

.final-scores ul {
    list-style: none;
}

.final-score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.final-score-item:first-child {
    background: rgba(78, 205, 196, 0.15);
    border: 1px solid rgba(78, 205, 196, 0.3);
}

.final-score-item .rank {
    color: rgba(255, 255, 255, 0.5);
    margin-right: 0.5rem;
    min-width: 24px;
}

.final-score-item .name {
    flex: 1;
}

.final-score-item .score {
    color: #4ecdc4;
    font-weight: 600;
}

.finished-boards {
    display: flex;
    gap: 2rem;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
    width: 100%;
    margin: 0 auto;
}

.final-board {
    width: 350px;
}

.final-board h3 {
    text-align: center;
    margin-bottom: 0.5rem;
    color: rgba(255, 255, 255, 0.9);
}

.final-board.current-player-board {
    border-color: #4ecdc4;
    box-shadow: 0 0 20px rgba(78, 205, 196, 0.3);
}

.final-hex-board {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    margin: 0 auto;
}

.play-again-button {
    background: linear-gradient(135deg, #4ecdc4 0%, #45b7aa 100%);
    color: #1a1a2e;
    border: none;
    border-radius: 10px;
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
    transition: all 0.2s;
}

.play-again-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(78, 205, 196, 0.4);
}

.rematch-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.rematch-buttons .back-button {
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 0.875rem 2rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.rematch-buttons .back-button:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* ============================================================================
   REAL GAME MODE (Jeu Réel)
   ============================================================================ */

.real-game-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.real-game-boards {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    align-items: flex-start;
}

.real-game-boards .game-board {
    flex: 0 0 auto;
    padding: 1rem;
}

.real-game-boards .game-board h3 {
    text-align: center;
    margin-bottom: 0.5rem;
}

.real-game-boards .ai-board h3 {
    color: #ffa500;
}

.ai-hex-board .hex-cell {
    opacity: 0.9;
}

@media (max-width: 1000px) {
    .real-game-boards {
        flex-direction: column;
        align-items: center;
    }
}

.real-game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.real-game-info h2 {
    color: #4ecdc4;
    margin: 0;
}

.reset-button {
    background: transparent;
    border: 1px solid rgba(255, 165, 0, 0.5);
    color: #ffa500;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.reset-button:hover {
    background: rgba(255, 165, 0, 0.1);
}

/* Tile Picker - 3 lignes de 9 tuiles dans 150px */
.tile-picker {
    text-align: center;
    padding: 1rem;
}

.tile-picker h3 {
    margin-bottom: 0.5rem;
    color: #4ecdc4;
    font-size: 1rem;
}

.tiles-rows {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 600px;
    margin: 0 auto;
    height: 150px;
}

.tiles-row {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 46px;
}

.row-label {
    width: 24px;
    height: 24px;
    background: rgba(78, 205, 196, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    color: #4ecdc4;
    flex-shrink: 0;
}

.row-tiles {
    display: flex;
    gap: 4px;
    flex: 1;
    justify-content: center;
}

.picker-tile {
    width: 56px;
    height: 42px;
    cursor: pointer;
    transition: all 0.15s;
    border-radius: 6px;
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px;
    flex-shrink: 0;
}

.picker-tile:hover:not(.used) {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.5);
    z-index: 10;
}

.picker-tile.used {
    opacity: 0.25;
    cursor: not-allowed;
}

.used-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    color: #4ecdc4;
    text-shadow: 0 0 8px rgba(78, 205, 196, 0.8);
}

/* Current tile display */
.current-tile-section {
    text-align: center;
}

.current-tile-section h3 {
    margin-bottom: 1rem;
    color: #4ecdc4;
}

.selected-tile-display {
    width: 120px;
    height: 104px;
    margin: 0 auto 1rem;
}

/* Game over state */
.game-over {
    text-align: center;
    background: rgba(78, 205, 196, 0.1);
    border: 1px solid rgba(78, 205, 196, 0.3);
}

.game-over h2 {
    color: #4ecdc4;
    margin-bottom: 0.5rem;
}

/* ============================================================================
   IN-PROGRESS LAYOUT — viewport-fit, zero scroll
   ============================================================================ */

/* Container: lock to viewport */
.app-container.in-progress-layout {
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    padding: 0.5rem 1rem;
    display: flex;
    flex-direction: column;
}

/* Compact header */
.in-progress-layout .header-section { margin-bottom: 0.25rem; }
.in-progress-layout .title-with-back h1 { font-size: 1.1rem; }
.in-progress-layout .status-message {
    padding: 0.25rem 0.5rem;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

/* Compact session info */
.in-progress-layout .session-info {
    padding: 0.4rem 0.75rem;
    gap: 0.5rem;
}
.in-progress-layout .session-info h2 { font-size: 0.95rem; }

/* Reduce flex gaps */
.in-progress-layout .game-session { gap: 0.3rem; flex: 1; min-height: 0; }
.in-progress-layout .game-state { gap: 0.3rem; flex: 1; min-height: 0; }
.in-progress-layout .game-container { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.in-progress-layout .in-progress-state { gap: 0; flex: 1; min-height: 0; overflow-y: auto; }

/* Board container: positioning context for overlays */
.in-progress-layout .game-board {
    padding: 0.5rem;
    flex: 0 0 auto;
    position: relative;
}

/* Shared overlay style */
.in-progress-layout .board-overlay {
    position: absolute;
    z-index: 20;
    background: rgba(26, 26, 46, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 10px;
    border: 1px solid rgba(78, 205, 196, 0.2);
}

/* Turn info: overlay top-LEFT on board */
.in-progress-layout .turn-info {
    top: 4px;
    left: 4px;
    padding: 0.3rem 0.5rem;
    min-height: unset;
    text-align: center;
}
.in-progress-layout .turn-info h3 { margin-bottom: 0.1rem; font-size: 0.75rem; }
.in-progress-layout .current-tile { width: 60px; height: 52px; }
.in-progress-layout .tile-svg-container { width: 50px; height: 44px; }
.in-progress-layout .placement-hint {
    font-size: 0.6rem;
    color: rgba(78, 205, 196, 0.8);
    margin-top: 0.15rem;
    animation: fadeIn 0.5s ease-in;
    letter-spacing: 0.03em;
}

/* Scores: overlay top-RIGHT on board */
.in-progress-layout .board-scores {
    top: 4px;
    right: 4px;
    padding: 0.3rem 0.5rem;
}
.in-progress-layout .board-scores ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.in-progress-layout .board-scores .player-item {
    padding: 0.15rem 0.4rem;
    margin-bottom: 0;
    font-size: 0.75rem;
    background: transparent;
}
.in-progress-layout .game-board > h3 { display: none; }
.in-progress-layout .hex-board { margin: 0 auto; }

/* ---- Board scaling by viewport height (desktop/tablet) ---- */
@media (min-width: 621px) and (max-height: 900px) {
    .in-progress-layout .hex-board {
        transform: scale(0.82);
        transform-origin: top center;
        margin-bottom: -100px;
    }
}

@media (min-width: 621px) and (max-height: 750px) {
    .in-progress-layout .hex-board {
        transform: scale(0.68);
        transform-origin: top center;
        margin-bottom: -180px;
    }
}

@media (min-width: 621px) and (max-height: 600px) {
    .in-progress-layout .hex-board {
        transform: scale(0.55);
        transform-origin: top center;
        margin-bottom: -255px;
    }
}

/* ---- Width-based scaling for phones ---- */
@media (max-width: 620px) {
    .app-container.in-progress-layout {
        padding: 0.25rem;
    }
    .in-progress-layout .game-board {
        overflow: hidden;
        margin-bottom: 0;
        padding: 70px 0 0 0;
    }
    .in-progress-layout .hex-board {
        /* Center: left 50% of container, then shift back half of 600px */
        margin: 0 !important;
        left: 50% !important;
        margin-left: -300px !important;
        /* Scale to fit: fallback then dynamic */
        transform: scale(0.56);
        transform: scale(calc((100vw - 0.5rem) / 600 + 0.01));
        transform-origin: top center;
    }
}

/* ---- Phone: shrink overlays ---- */
@media (max-width: 620px) {
    .in-progress-layout .turn-info {
        padding: 0.2rem 0.35rem;
    }
    .in-progress-layout .turn-info h3 {
        font-size: 0.6rem;
    }
    .in-progress-layout .current-tile {
        width: 48px;
        height: 42px;
    }
    .in-progress-layout .tile-svg-container {
        width: 40px;
        height: 35px;
    }
    .in-progress-layout .placement-hint {
        font-size: 0.5rem;
    }
    .in-progress-layout .board-scores {
        padding: 0.2rem 0.35rem;
    }
    .in-progress-layout .board-scores .player-item {
        font-size: 0.6rem;
        padding: 0.1rem 0.25rem;
    }
    .in-progress-layout .header-section {
        margin-bottom: 0.1rem;
    }
    .in-progress-layout .title-with-back h1 {
        font-size: 0.9rem;
    }
    .in-progress-layout .status-message {
        font-size: 0.7rem;
        padding: 0.15rem 0.4rem;
    }
    .in-progress-layout .session-info {
        padding: 0.25rem 0.5rem;
    }
    .in-progress-layout .session-info h2 {
        font-size: 0.8rem;
    }
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }

    .header h1 {
        font-size: 2rem;
    }

    .modes-grid {
        grid-template-columns: 1fr;
    }

    .session-info {
        flex-direction: column;
        text-align: center;
    }

    .hex-board {
        transform: scale(0.8);
        transform-origin: top center;
    }

    .tiles-rows {
        height: 130px;
    }

    .tiles-row {
        height: 40px;
    }

    .picker-tile {
        width: 32px;
        height: 28px;
    }

    .row-label {
        width: 20px;
        height: 20px;
        font-size: 12px;
    }

    .real-game-info {
        flex-direction: column;
        text-align: center;
    }

    .welcome-hex-board {
        transform: scale(0.8);
        transform-origin: top center;
    }
}

@media (max-width: 620px) {
    /* Reduce padding so the welcome board fits on phones */
    .auth-page {
        padding: 0.5rem;
    }
    .auth-container.glass-container {
        padding: 0.75rem;
    }
    .welcome-hex-board {
        transform: scale(0.85) !important;
        transform-origin: top center;
        /* Shrink layout box to match visual: 320*(1-0.85)/2 = 24px per side */
        margin-left: -24px !important;
        margin-right: -24px !important;
        /* Reclaim vertical gap: 360*(1-0.85) = 54px */
        margin-bottom: -54px !important;
    }
    .welcome-direction-labels {
        width: 272px;
        max-width: 100%;
    }
}

/* ============================================================================
   CHALLENGE MODE
   ============================================================================ */

.section-title {
    text-align: center;
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 1rem;
}

.challenge-title {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1.5rem;
    margin-top: 0.5rem;
}

.challenge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.challenge-card {
    border-color: rgba(255, 193, 7, 0.2);
}

.challenge-card:hover {
    border-color: rgba(255, 193, 7, 0.5);
    box-shadow: 0 12px 40px rgba(255, 193, 7, 0.15);
}

/* Timer overlay */
.timer-display {
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.25rem 0.75rem;
    text-align: center;
}

.timer-text {
    font-family: 'Courier New', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: #4ecdc4;
    letter-spacing: 0.1em;
}

.timer-low .timer-text {
    color: #ff6b6b;
    animation: timer-pulse 1s infinite;
}

@keyframes timer-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* In-progress layout: compact timer */
.in-progress-layout .timer-display {
    padding: 0.15rem 0.5rem;
}

.in-progress-layout .timer-text {
    font-size: 1rem;
}

/* Series indicator badge */
.series-indicator {
    background: rgba(255, 193, 7, 0.15);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 8px;
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #ffc107;
    text-align: center;
}

/* Series intermediate screen */
.series-intermediate {
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

.series-intermediate h2 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, #ffc107 0%, #ffdb4d 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.series-last-result {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.series-cumulative {
    margin: 1.5rem 0;
}

.series-score-big {
    font-size: 2.5rem;
    font-weight: 700;
}

.series-player-score {
    color: #4ecdc4;
}

.series-vs {
    color: rgba(255, 255, 255, 0.5);
    margin: 0 0.5rem;
}

.series-ai-score {
    color: #ff6b6b;
}

.series-score-label {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.series-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.series-table th {
    text-align: center;
    padding: 0.4rem 0.5rem;
    color: rgba(255, 255, 255, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.series-table td {
    text-align: center;
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.series-table .score-cell {
    font-weight: 600;
}

.series-row-win {
    background: rgba(78, 205, 196, 0.1);
}

.series-row-loss {
    background: rgba(255, 107, 107, 0.1);
}

.series-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.series-final-result {
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffc107;
    margin-bottom: 0.5rem;
}

.abandon-button {
    background: transparent;
    border: 1px solid rgba(255, 107, 107, 0.5);
    color: #ff6b6b;
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.abandon-button:hover {
    background: rgba(255, 107, 107, 0.1);
}

@media (max-width: 620px) {
    .challenge-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
    .challenge-card .mode-icon {
        font-size: 1.5rem;
    }
    .challenge-card h3 {
        font-size: 0.9rem;
    }
    .challenge-card .mode-description {
        font-size: 0.75rem;
    }
    .in-progress-layout .timer-display {
        padding: 0.1rem 0.3rem;
    }
    .in-progress-layout .timer-text {
        font-size: 0.8rem;
    }
    .series-score-big {
        font-size: 1.8rem;
    }
}
