/* ============================================
   Majhong - Mahjong Solitaire 3 plans
   Design responsive - palette MajhongLink
   ============================================ */

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

#game-main {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100dvh;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

#game-container {
    width: 100%;
    max-width: 500px;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 10px;
    gap: 6px;
}

#game-header {
    width: 100%;
    text-align: center;
    flex-shrink: 0;
}

#game-title {
    font-size: 1.6rem;
    font-weight: 700;
    background: linear-gradient(90deg, #ff4d6d, #ffd93d, #6bd968);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

#scores-container {
    display: flex;
    justify-content: center;
    gap: 28px;
}

.score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
}

.score-number {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
}

#info-bar {
    width: 100%;
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 5px 8px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    gap: 4px;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.info-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
}

.info-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
}

#message-container {
    width: 100%;
    text-align: center;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#game-message {
    font-size: 0.95rem;
    font-weight: 500;
    color: #b0b0ff;
    transition: opacity 0.3s ease, color 0.2s ease;
}

#game-message.success { color: #00e676; }
#game-message.error { color: #ff5252; }
#game-message.warning { color: #ffd93d; }

#timer-container {
    width: 100%;
    flex-shrink: 0;
    min-height: 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

#timer-bar {
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#timer-bar.visible { opacity: 1; }

#timer-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #6bd968, #ffd93d);
    border-radius: 3px;
    transition: width 0.2s linear, background 0.3s ease;
    transform-origin: left;
}

#timer-fill.warning { background: linear-gradient(90deg, #ff9800, #ff5252); }

#timer-text {
    font-size: 0.75rem;
    color: #aaa;
    min-height: 14px;
}

/* --- Mode & Set selectors --- */
#mode-container,
#set-container {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.selector-btn {
    padding: 6px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.06);
    color: #ccc;
    cursor: pointer;
    transition: all 0.18s ease;
    -webkit-tap-highlight-color: transparent;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 50px;
}

.selector-btn:active { transform: scale(0.94); }

.selector-btn.active {
    background: linear-gradient(135deg, #7b2ff7, #00d2ff);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 2px 10px rgba(123, 47, 247, 0.4);
}

.selector-btn.set-1.active { background: linear-gradient(135deg, #ff6fd8, #ff4d6d); }
.selector-btn.set-2.active { background: linear-gradient(135deg, #00d2ff, #7b2ff7); }
.selector-btn.set-3.active { background: linear-gradient(135deg, #ffd93d, #ff9800); }
.selector-btn.set-4.active { background: linear-gradient(135deg, #6bd968, #00b894); }
.selector-btn.set-5.active { background: linear-gradient(135deg, #a29bfe, #6c5ce7); }

#set-container {
    margin-top: -2px;
}

#set-container .selector-btn {
    padding: 4px 10px;
    font-size: 0.72rem;
    min-width: 44px;
}

/* --- Zone canvas --- */
#canvas-wrapper {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 300px;
    position: relative;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

#game-canvas {
    display: block;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 8px;
    box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.6);
    touch-action: pan-y;
    max-width: 100%;
    cursor: pointer;
}

#controls-container {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 6px 0;
    flex-shrink: 0;
}

.game-btn {
    padding: 10px 28px;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

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

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

.btn-stop {
    background: linear-gradient(135deg, #ff5252, #d50000);
    color: #fff;
    box-shadow: 0 4px 15px rgba(255, 82, 82, 0.3);
}
.btn-stop:hover { box-shadow: 0 6px 20px rgba(255, 82, 82, 0.5); }

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

.btn-lang {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 2px;
    min-width: 52px;
    text-align: center;
}
.btn-lang:hover { background: rgba(255, 255, 255, 0.2); }

.hidden { display: none !important; }

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    animation: fadeIn 0.25s ease;
}

.modal-content {
    background: linear-gradient(135deg, #1a1a3e, #2a2a5e);
    border: 1px solid rgba(123, 47, 247, 0.4);
    border-radius: 16px;
    padding: 24px 20px;
    max-width: 440px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-close {
    position: absolute;
    top: 10px; right: 14px;
    background: none; border: none;
    color: #aaa;
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.modal-close:hover { color: #fff; }

.modal-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 14px;
    background: linear-gradient(90deg, #ff4d6d, #ffd93d, #6bd968);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

.modal-body {
    font-size: 0.88rem;
    line-height: 1.6;
    color: #ccc;
}

.modal-body h3 {
    font-size: 0.95rem;
    color: #b0b0ff;
    margin: 14px 0 6px;
    font-weight: 600;
}

.modal-body p { margin-bottom: 8px; }
.modal-body ol, .modal-body ul { padding-left: 20px; margin-bottom: 8px; }
.modal-body li { margin-bottom: 4px; }

.modal-body .legend {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 700;
    margin: 0 2px;
}

.modal-body .legend.red { background: rgba(255, 77, 109, 0.25); color: #ff6b87; border: 1px solid #ff4d6d; }
.modal-body .legend.yellow { background: rgba(255, 217, 61, 0.20); color: #ffd93d; border: 1px solid #ffd93d; }
.modal-body .legend.green { background: rgba(107, 217, 104, 0.20); color: #6bd968; border: 1px solid #6bd968; }

/* --- Game over modal --- */
#end-overlay .modal-content { text-align: center; }

.end-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 80px;
}

.end-stat-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
}

.end-stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
}

#end-stats {
    margin: 14px 0;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 8px;
}

.end-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 16px;
    flex-wrap: wrap;
}

.btn-quit {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: #fff;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

/* --- Animations jeu --- */
@keyframes combo-pop {
    0% { transform: scale(1); color: #fff; }
    50% { transform: scale(1.4); color: #ffd93d; }
    100% { transform: scale(1); color: #fff; }
}
.combo-pop { animation: combo-pop 0.35s ease; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}
.shake { animation: shake 0.4s ease; }

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 rgba(255, 217, 61, 0); }
    50% { box-shadow: 0 0 12px rgba(255, 217, 61, 0.5); }
}

/* --- Petits écrans --- */
@media (max-height: 640px) {
    #game-container { padding: 4px 8px; gap: 3px; }
    #game-title { font-size: 1.2rem; margin-bottom: 2px; }
    .score-number { font-size: 1.1rem; }
    #info-bar { padding: 4px 6px; }
    .info-label { font-size: 0.55rem; }
    .info-value { font-size: 0.85rem; }
    #game-message { font-size: 0.85rem; }
    #message-container { min-height: 22px; }
    .game-btn { padding: 8px 22px; font-size: 0.85rem; }
    .selector-btn { padding: 4px 10px; font-size: 0.72rem; }
    #set-container .selector-btn { padding: 3px 8px; font-size: 0.68rem; }
}

/* --- Tablettes / grands écrans --- */
@media (min-width: 768px) {
    #game-container { padding: 16px 20px; gap: 10px; }
    #game-title { font-size: 2rem; }
    .score-number { font-size: 1.6rem; }
}

/* --- Paysage mobile --- */
@media (orientation: landscape) and (max-height: 500px) {
    #game-container {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 4px 8px;
        gap: 4px;
        max-width: 100%;
        justify-content: center;
    }
    #game-header { width: 30%; order: 1; }
    #game-title { font-size: 1rem; margin-bottom: 2px; letter-spacing: 2px; }
    .score-number { font-size: 1rem; }
    #info-bar { width: 30%; order: 2; padding: 3px 6px; }
    #mode-container { width: 35%; order: 3; }
    #set-container { width: 35%; order: 4; }
    #message-container { width: 100%; order: 5; min-height: 20px; }
    #game-message { font-size: 0.8rem; }
    #timer-container { width: 100%; order: 6; }
    #canvas-wrapper { order: 7; flex: 1; }
    #controls-container { order: 8; width: auto; flex-direction: column; padding: 0 6px; }
    .game-btn { padding: 8px 18px; font-size: 0.8rem; }
    .selector-btn { padding: 4px 8px; font-size: 0.7rem; min-width: 40px; }
}
