/* ========================================
   ROI EN FUITE - Styles responsive mobile
   Adapté de pulsepattern pour omesjeux
   ======================================== */

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

#game-main {
    --coeur-color: #e74c3c;
    --coeur-light: #f5b7b1;
    --carreau-color: #e67e22;
    --carreau-light: #fad7a0;
    --trefle-color: #27ae60;
    --trefle-light: #a9dfbf;
    --pique-color: #2980b9;
    --pique-light: #aed6f1;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0ff;
    --gold: #ffcf3a;
    --gold-dark: #d4ac0d;
    --danger: #ff5252;
    --success: #00e676;

    position: relative;
    width: 100%;
    max-width: 600px;
    height: 100dvh;
    margin: 0 auto;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: var(--text-primary);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

/* Screen management */
#game-main .screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#game-main .screen.active {
    display: flex;
    animation: oj-rf-fadeIn 0.3s ease-out;
}

@keyframes oj-rf-fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

#game-main .game-title {
    font-size: 2.4rem;
    font-weight: 800;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7, #ff6fd8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    letter-spacing: 2px;
    text-transform: uppercase;
    animation: oj-rf-titlePulse 3s ease-in-out infinite;
}

@keyframes oj-rf-titlePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

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

#game-main .menu-kings {
    display: flex;
    gap: 15px;
    margin: 10px 0;
}

#game-main .menu-king {
    font-size: 2rem;
    animation: oj-rf-kingBounce 2s ease-in-out infinite;
}

#game-main .menu-king:nth-child(1) { animation-delay: 0s; }
#game-main .menu-king:nth-child(2) { animation-delay: 0.5s; }
#game-main .menu-king:nth-child(3) { animation-delay: 1s; }
#game-main .menu-king:nth-child(4) { animation-delay: 1.5s; }

@keyframes oj-rf-kingBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

#game-main .style-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

#game-main .btn-style {
    padding: 6px 16px;
    border: 2px solid rgba(255,255,255,0.25);
    border-radius: 20px;
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s;
}

#game-main .btn-style.active {
    background: linear-gradient(135deg, #00d2ff, #7b2ff7);
    color: #fff;
    border-color: transparent;
    font-weight: 700;
    box-shadow: 0 2px 10px rgba(123,47,247,0.4);
}

/* ========================================
   BUTTONS
   ======================================== */
#game-main .btn {
    padding: 12px 36px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.3s ease;
    min-width: 180px;
    min-height: 46px;
    -webkit-tap-highlight-color: transparent;
}

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

#game-main .btn-primary {
    background: linear-gradient(135deg, #00d2ff, #7b2ff7);
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
}

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

#game-main .btn-secondary {
    background: linear-gradient(135deg, #ff6fd8, #7b2ff7);
    color: #fff;
    box-shadow: 0 4px 15px rgba(123, 47, 247, 0.3);
}

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

#game-main .btn-small {
    padding: 9px 18px;
    font-size: 0.8rem;
    min-width: 80px;
    min-height: 36px;
    letter-spacing: 0.5px;
}

#game-main .btn-danger {
    background: linear-gradient(135deg, #ff5252, #d50000);
    color: #fff;
    box-shadow: 0 4px 15px rgba(255, 82, 82, 0.3);
}

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

/* ========================================
   KING SELECTION
   ======================================== */
#game-main .select-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 20px;
    gap: 15px;
}

#game-main .select-content h2 {
    font-size: 1.6rem;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

#game-main .select-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
}

#game-main .king-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    max-width: 400px;
    margin: 10px 0;
}

#game-main .king-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px 10px;
    border-radius: 15px;
    border: 2px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.04);
    cursor: pointer;
    transition: all 0.3s;
    min-height: 140px;
}

#game-main .king-card[data-suit="coeur"]    { border-color: rgba(231,76,60,0.4); }
#game-main .king-card[data-suit="carreau"]  { border-color: rgba(230,126,34,0.4); }
#game-main .king-card[data-suit="trefle"]   { border-color: rgba(39,174,96,0.4); }
#game-main .king-card[data-suit="pique"]    { border-color: rgba(41,128,185,0.4); }

#game-main .king-card:active,
#game-main .king-card.selected {
    transform: scale(0.95);
}

#game-main .king-card[data-suit="coeur"]:active,
#game-main .king-card[data-suit="coeur"].selected {
    border-color: var(--coeur-color);
    box-shadow: 0 0 20px rgba(231,76,60,0.5);
}
#game-main .king-card[data-suit="carreau"]:active,
#game-main .king-card[data-suit="carreau"].selected {
    border-color: var(--carreau-color);
    box-shadow: 0 0 20px rgba(230,126,34,0.5);
}
#game-main .king-card[data-suit="trefle"]:active,
#game-main .king-card[data-suit="trefle"].selected {
    border-color: var(--trefle-color);
    box-shadow: 0 0 20px rgba(39,174,96,0.5);
}
#game-main .king-card[data-suit="pique"]:active,
#game-main .king-card[data-suit="pique"].selected {
    border-color: var(--pique-color);
    box-shadow: 0 0 20px rgba(41,128,185,0.5);
}

#game-main .king-card-img {
    width: 70px;
    height: 100px;
    background-color: #fff;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    margin: 0 auto 8px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

#game-main .king-card-label {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 4px;
    color: #fff;
}

#game-main .king-card-track {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ========================================
   GAME SCREEN
   ======================================== */
#game-main #game-screen {
    justify-content: flex-start;
}

#game-main #game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 8px 15px;
    background: rgba(255,255,255,0.05);
    border-radius: 0 0 10px 10px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    flex-shrink: 0;
    border-bottom: 1px solid rgba(123,47,247,0.4);
}

#game-main .header-left,
#game-main .header-center,
#game-main .header-right {
    display: flex;
    align-items: center;
}

#game-main #game-canvas {
    width: 100%;
    flex-shrink: 0;
    touch-action: none;
}

#game-main #message-area {
    width: 100%;
    text-align: center;
    padding: 4px 10px;
    min-height: 28px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: opacity 0.3s ease;
}

#game-main #message-area.info    { color: var(--text-secondary); }
#game-main #message-area.success { color: var(--success); }
#game-main #message-area.danger  { color: var(--danger); }

#game-main #message-area.combo {
    color: #ffcf3a;
    font-size: 1.05rem;
    animation: oj-rf-comboPulse 0.5s ease-out;
}

@keyframes oj-rf-comboPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

#game-main #hand-area {
    width: 100%;
    padding: 8px 5px;
    flex-shrink: 0;
}

#game-main .hand-cards {
    display: flex;
    justify-content: center;
    gap: 6px;
    overflow-x: auto;
    padding: 5px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

#game-main .hand-card {
    width: 58px;
    height: 82px;
    border-radius: 8px;
    background-color: #fff;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    border: 2px solid transparent;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    position: relative;
}

#game-main .hand-card:active {
    transform: scale(0.93);
}

#game-main .hand-card.selected {
    transform: translateY(-12px);
    border-color: #ffcf3a;
    box-shadow: 0 6px 20px rgba(255, 207, 58, 0.55);
}

#game-main .hand-card.disabled {
    opacity: 0.4;
    pointer-events: none;
}

#game-main .hand-card.playable {
    border-color: rgba(255,255,255,0.3);
}

#game-main .hand-card .card-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.6rem;
    color: #1a1a2e;
    white-space: nowrap;
    font-weight: 700;
    pointer-events: none;
    text-align: center;
    line-height: 1.2;
    opacity: 0;
    transition: opacity 0.3s;
}

#game-main .hand-card.card-loaded .card-label {
    opacity: 0;
}

#game-main .hand-card.card-error .card-label {
    opacity: 1;
    font-size: 0.55rem;
}

#game-main .hand-card.card-error {
    background-color: #f0f0f0;
}

#game-main #game-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 5px 15px 10px;
    width: 100%;
    flex-shrink: 0;
}

#game-main .style-toggle-game {
    margin-left: auto;
}

#game-main #btn-style-game {
    font-size: 0.7rem;
    padding: 6px 12px;
    min-width: 70px;
    min-height: 30px;
}

/* ========================================
   RULES SCREEN
   ======================================== */
#game-main .rules-content {
    padding: 20px;
    max-width: 500px;
    margin: 0 auto;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

#game-main .rules-content h2 {
    text-align: center;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.4rem;
    margin-bottom: 15px;
    font-weight: 700;
}

#game-main .rules-content h3 {
    color: #b0b0ff;
    font-size: 1rem;
    margin: 15px 0 8px;
    font-weight: 600;
}

#game-main .rules-content p {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #ccc;
    margin-bottom: 8px;
}

#game-main .rules-table {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(123,47,247,0.25);
    border-radius: 10px;
    padding: 8px;
    margin: 8px 0;
}

#game-main .rule-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 8px;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

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

#game-main .rule-row span:first-child {
    font-weight: 600;
    color: #fff;
}

#game-main .rule-row span:last-child {
    color: var(--text-secondary);
}

/* ========================================
   GAME OVER SCREEN
   ======================================== */
#game-main .gameover-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 20px;
    gap: 15px;
}

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

#game-main #gameover-result {
    font-size: 1.1rem;
    text-align: center;
    line-height: 1.6;
    color: #ddd;
}

#game-main .final-scores {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(123,47,247,0.3);
    border-radius: 15px;
    padding: 15px;
    width: 100%;
    max-width: 350px;
}

#game-main .final-score-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 5px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 0.95rem;
}

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

#game-main .final-score-row .king-name {
    font-weight: 600;
}

#game-main .final-score-row .king-pos {
    color: var(--text-secondary);
}

#game-main .final-score-row.winner {
    color: #ffcf3a;
    font-weight: 700;
    font-size: 1.05rem;
}

#game-main .total-score {
    font-size: 1.3rem;
    font-weight: 800;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

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

#game-main .gameover-buttons .btn {
    width: 100%;
}

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

#game-main .scores-content h2 {
    background: linear-gradient(90deg, #00d2ff, #7b2ff7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.4rem;
    margin-bottom: 15px;
    font-weight: 700;
}

#game-main .scores-list {
    width: 100%;
    max-width: 400px;
    margin-bottom: 15px;
}

#game-main .score-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(123,47,247,0.25);
    border-radius: 10px;
    margin-bottom: 8px;
}

#game-main .score-rank {
    font-weight: 800;
    color: #ffcf3a;
    font-size: 1.2rem;
    min-width: 30px;
}

#game-main .score-info {
    flex: 1;
    margin-left: 10px;
}

#game-main .score-level {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

#game-main .score-value {
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
}

#game-main .score-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ========================================
   POPUP
   ======================================== */
#game-main .popup {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#game-main .popup.hidden {
    display: none;
}

#game-main .popup-content {
    background: linear-gradient(135deg, #1a1a3e, #2a2a5e);
    border: 1px solid rgba(123,47,247,0.4);
    border-radius: 16px;
    padding: 20px;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

/* ========================================
   TOAST
   ======================================== */
#game-main .toast {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(123,47,247,0.85);
    color: #fff;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 2000;
    transition: opacity 0.3s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

#game-main .toast.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ========================================
   SCROLLBAR
   ======================================== */
#game-main .screen::-webkit-scrollbar { width: 4px; }
#game-main .screen::-webkit-scrollbar-track { background: transparent; }
#game-main .screen::-webkit-scrollbar-thumb {
    background: rgba(123,47,247,0.5);
    border-radius: 2px;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 360px) {
    #game-main .game-title { font-size: 1.9rem; }
    #game-main .btn { padding: 10px 28px; font-size: 0.9rem; min-width: 150px; }
    #game-main .king-card { padding: 10px 8px; min-height: 110px; }
    #game-main .king-card-img { width: 50px; height: 72px; }
    #game-main .hand-card { width: 50px; height: 72px; }
}

@media (min-width: 768px) {
    #game-main .game-title { font-size: 2.8rem; }
    #game-main .king-options { max-width: 500px; }
    #game-main .king-card { min-height: 170px; padding: 20px 15px; }
    #game-main .king-card-img { width: 80px; height: 115px; }
    #game-main .hand-card { width: 68px; height: 97px; }
    #game-main #game-header { font-size: 1.05rem; }
}

@media (orientation: landscape) and (max-height: 500px) {
    #game-main .game-title { font-size: 1.4rem; }
    #game-main .game-subtitle { display: none; }
    #game-main .menu-kings { margin: 5px 0; }
    #game-main .menu-content { gap: 8px; padding: 10px; }
    #game-main .btn { padding: 8px 22px; min-height: 34px; font-size: 0.85rem; }
    #game-main .select-content { padding: 10px; }
    #game-main .king-options { display: flex; gap: 8px; }
    #game-main .king-card { min-height: 90px; padding: 8px; }
}
