/* === Harmonie des cartes - Styles (scoped) === */
/* Inspiré de pulsepattern : palette #0f0c29 / #302b63 / #24243e, accents cyan/violet/rose */

#game-main {
    --bg-dark1: #0f0c29;
    --bg-dark2: #302b63;
    --bg-dark3: #24243e;
    --text-primary: #e0e0e0;
    --text-secondary: #888;
    --text-bright: #fff;
    --accent-cyan: #00d2ff;
    --accent-purple: #7b2ff7;
    --accent-pink: #ff6fd8;
    --accent-gold: #f0d060;
    --accent-green: #00e676;
    --accent-red: #ff5252;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.15);
    --hdc-btn-radius: 25px;

    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark1), var(--bg-dark2), var(--bg-dark3));
    color: var(--text-primary);
    width: 100%;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: stretch;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

#game-main *,
#game-main *::before,
#game-main *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

#game-main #game-container {
    width: 100%;
    max-width: 500px;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
}

#game-main #hdc-app {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* === Screens === */
#game-main .screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    flex-direction: column;
    background: linear-gradient(135deg, var(--bg-dark1), var(--bg-dark2), var(--bg-dark3));
    overflow-y: auto;
    z-index: 1;
}

#game-main .screen.active {
    display: flex;
    animation: hdc-fadeIn 0.25s ease-out;
}

/* === Menu Screen === */
#game-main .menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 20px;
    gap: 16px;
}

#game-main .game-title {
    font-size: 2.4rem;
    font-weight: 800;
    text-align: center;
    line-height: 1.15;
    letter-spacing: 2px;
    text-transform: uppercase;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

#game-main .game-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-align: center;
}

#game-main .menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 280px;
}

#game-main .style-toggle,
#game-main .level-select {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

#game-main .level-name {
    font-weight: 600;
    min-width: 90px;
    text-align: center;
    color: var(--text-bright);
}

/* === Buttons === */
#game-main .hdc-btn {
    border: none;
    border-radius: var(--hdc-btn-radius);
    font-size: 1rem;
    font-weight: 600;
    padding: 14px 24px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.3s ease;
    outline: none;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
    line-height: 1.2;
}

#game-main .hdc-btn:active {
    transform: scale(0.95);
}

#game-main .hdc-btn-primary {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    color: var(--text-bright);
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
}

#game-main .hdc-btn-primary:hover {
    box-shadow: 0 6px 20px rgba(0, 210, 255, 0.5);
}

#game-main .hdc-btn-secondary {
    background: linear-gradient(135deg, var(--accent-pink), var(--accent-purple));
    color: var(--text-bright);
    box-shadow: 0 4px 15px rgba(123, 47, 247, 0.3);
}

#game-main .hdc-btn-secondary:hover {
    box-shadow: 0 6px 20px rgba(123, 47, 247, 0.5);
}

#game-main .hdc-btn-outline {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 2px solid var(--border-light);
}

#game-main .hdc-btn-small {
    font-size: 0.8rem;
    padding: 8px 16px;
    border-radius: 18px;
}

#game-main .hdc-btn-tiny {
    font-size: 0.8rem;
    padding: 6px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

#game-main .hdc-btn-danger {
    background: linear-gradient(135deg, var(--accent-red), #d50000) !important;
    color: var(--text-bright) !important;
}

#game-main .hdc-btn-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 2px solid var(--border-light);
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    min-width: 62px;
    text-transform: none;
    letter-spacing: 0;
}

#game-main .hdc-btn-action:active {
    background: rgba(255, 255, 255, 0.18);
}

#game-main .hdc-btn-action .hdc-btn-icon {
    font-size: 1.3rem;
    line-height: 1;
}

#game-main .hdc-btn-action .hdc-btn-text {
    font-size: 0.6rem;
    letter-spacing: 0.5px;
}

#game-main .hdc-btn:disabled,
#game-main .hdc-btn-action:disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* === Game Screen === */
#game-main #game-screen {
    height: 100%;
}

#game-main #game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-subtle);
}

#game-main .header-left,
#game-main .header-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
}

#game-main .header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#game-main .label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

#game-main .value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-bright);
}

#game-main .value-small {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-cyan);
}

#game-main #game-canvas {
    flex: 1;
    width: 100%;
    display: block;
    touch-action: none;
}

#game-main #game-actions {
    display: flex;
    justify-content: space-around;
    padding: 8px 10px 14px;
    background: rgba(0, 0, 0, 0.25);
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
    gap: 6px;
}

/* === Score Popups (canvas-based, container kept for compatibility) === */
#game-main #score-popup-container {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* === Rules Screen === */
#game-main .rules-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

#game-main .rules-content h2,
#game-main .scores-content h2 {
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
    font-size: 1.5rem;
    font-weight: 700;
}

#game-main .rules-text {
    text-align: left;
    width: 100%;
    max-width: 400px;
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
    margin-bottom: 16px;
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text-primary);
}

#game-main .rules-text h3 {
    color: var(--accent-cyan);
    margin-top: 14px;
    margin-bottom: 6px;
    font-size: 1rem;
}

#game-main .rules-text ul {
    padding-left: 20px;
    margin-bottom: 8px;
}

#game-main .rules-text li {
    margin-bottom: 4px;
}

#game-main .rules-text p {
    margin-bottom: 6px;
}

/* === Scores Screen === */
#game-main .scores-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

#game-main #scores-table-container {
    flex: 1;
    width: 100%;
    max-width: 400px;
    overflow-y: auto;
    margin-bottom: 16px;
}

#game-main #scores-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

#game-main #scores-table th {
    background: rgba(0, 210, 255, 0.15);
    color: var(--accent-cyan);
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-size: 0.7rem;
}

#game-main #scores-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

#game-main #scores-table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

/* === Game Over Screen === */
#game-main .gameover-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 20px;
    gap: 16px;
}

#game-main .gameover-content h2 {
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.8rem;
    font-weight: 800;
}

#game-main #gameover-stats {
    width: 100%;
    max-width: 300px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 16px;
}

#game-main .stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-subtle);
}

#game-main .stat-row:last-child {
    border-bottom: none;
}

#game-main .stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

#game-main .stat-value {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--accent-gold);
}

#game-main .level-up {
    background: linear-gradient(135deg, var(--accent-green), #1b8a3d);
    color: white;
    padding: 10px;
    border-radius: 10px;
    text-align: center;
    font-weight: 700;
    margin-top: 8px;
    animation: hdc-levelPulse 1s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(0, 230, 118, 0.3);
}

#game-main .gameover-buttons {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 280px;
}

#game-main .gameover-buttons .hdc-btn {
    flex: 1;
}

#game-main .enter-name {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
    max-width: 300px;
}

#game-main .enter-name input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--border-light);
    border-radius: var(--hdc-btn-radius);
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-bright);
    outline: none;
    font-family: inherit;
}

#game-main .enter-name input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.2);
}

#game-main .enter-name input::placeholder {
    color: var(--text-secondary);
}

/* === Animations === */
@keyframes hdc-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes hdc-levelPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Scrollbar */
#game-main .rules-text::-webkit-scrollbar,
#game-main #scores-table-container::-webkit-scrollbar {
    width: 6px;
}

#game-main .rules-text::-webkit-scrollbar-thumb,
#game-main #scores-table-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

#game-main .rules-text::-webkit-scrollbar-track,
#game-main #scores-table-container::-webkit-scrollbar-track {
    background: transparent;
}

/* === Responsive === */
@media (max-height: 600px) {
    #game-main .game-title { font-size: 1.6rem; }
    #game-main .game-subtitle { font-size: 0.75rem; margin-bottom: 2px; }
    #game-main .hdc-btn { padding: 10px 20px; font-size: 0.85rem; }
    #game-main .hdc-btn-action { padding: 6px 8px; }
    #game-main .hdc-btn-action .hdc-btn-icon { font-size: 1.1rem; }
    #game-main #game-header { padding: 4px 10px; }
    #game-main .value { font-size: 1.1rem; }
}
