/* ============================================
   Main Jong - Mahjong Solitaire Mobile
   Design responsive et tactile
   ============================================ */

#game-main * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

#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: stretch;
    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;
}

/* --- En-tête --- */
#game-header {
    width: 100%;
    text-align: center;
    flex-shrink: 0;
}

#game-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7, #ff6fd8);
    -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;
}

/* --- Barre d'informations --- */
#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);
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 50px;
}

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

.info-value {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}

#round-value {
    font-size: 1.3rem;
    color: #00d2ff;
}

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

#game-main .mode-btn {
    flex: 1;
    padding: 5px 4px;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    color: #ccc;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    cursor: pointer;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

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

.mode-btn.active {
    background: linear-gradient(135deg, #00d2ff, #7b2ff7);
    color: #fff;
    border-color: #00d2ff;
    box-shadow: 0 0 12px rgba(0, 210, 255, 0.5);
}

#game-main .set-btn {
    flex: 1;
    padding: 5px 4px;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    color: #ccc;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    cursor: pointer;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

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

.set-btn.active {
    background: linear-gradient(135deg, #00d2ff, #7b2ff7);
    color: #fff;
    border-color: #00d2ff;
    box-shadow: 0 0 12px rgba(0, 210, 255, 0.5);
}

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

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

#game-message.success { color: #00e676; }
#game-message.error   { color: #ff5252; }
#game-message.warn    { color: #ff9800; }
#game-message.info    { color: #00d2ff; }

/* --- ZONE PLATEAU --- */
#board-zone {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    border: 2px solid rgba(123, 47, 247, 0.4);
    border-radius: 12px;
    padding: 6px;
    box-shadow: inset 0 0 30px rgba(123, 47, 247, 0.15);
    position: relative;
    overflow: hidden;
}

#board-zone::before {
    content: "PLATEAU ADVERSE";
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.55rem;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 2px;
    pointer-events: none;
    z-index: 1;
}

#board-canvas-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 14px;
}

#board-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* --- ZONE MAIN --- */
#hand-zone {
    width: 100%;
    height: 160px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    border: 2px solid rgba(0, 210, 255, 0.4);
    border-radius: 12px;
    padding: 4px 6px;
    box-shadow: inset 0 0 30px rgba(0, 210, 255, 0.15);
    position: relative;
    overflow: hidden;
}

#hand-zone::before {
    content: "VOTRE MAIN";
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.55rem;
    color: rgba(0, 210, 255, 0.6);
    letter-spacing: 2px;
    pointer-events: none;
    z-index: 1;
}

#hand-canvas-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 12px;
}

#hand-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* --- Boutons d'action --- */
#action-container {
    width: 100%;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

#action-container .game-btn {
    flex: 1;
    padding: 9px 12px;
    font-size: 0.85rem;
}

.btn-draw {
    background: linear-gradient(135deg, #00d2ff, #3a7bd5);
    color: #fff;
    box-shadow: 0 3px 12px rgba(0, 210, 255, 0.3);
}

.btn-reset {
    background: linear-gradient(135deg, #ff6fd8, #ff5252);
    color: #fff;
    box-shadow: 0 3px 12px rgba(255, 111, 216, 0.3);
}

/* --- Boutons de contrôle --- */
#controls-container {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 4px 0;
    flex-shrink: 0;
}

#game-main .game-btn {
    padding: 10px 22px;
    font-size: 0.85rem;
    font-weight: 700;
    border: none;
    border-radius: 22px;
    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;
    color: #fff;
}

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

.btn-play {
    background: linear-gradient(135deg, #00e676, #00b248);
    box-shadow: 0 3px 12px rgba(0, 230, 118, 0.3);
}

.btn-stop {
    background: linear-gradient(135deg, #ff5252, #d50000);
    box-shadow: 0 3px 12px rgba(255, 82, 82, 0.3);
}

.btn-rules {
    background: linear-gradient(135deg, #ff6fd8, #7b2ff7);
    box-shadow: 0 3px 12px rgba(123, 47, 247, 0.3);
}

#game-main .btn-lang {
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    padding: 8px 14px;
    font-size: 0.75rem;
    min-width: 48px;
    text-align: center;
}

/* --- Bouton Rejouer (modal fin) --- */
#btn-end-replay {
    background: linear-gradient(135deg, #00d2ff, #7b2ff7);
    color: #fff;
    box-shadow: 0 4px 15px rgba(123, 47, 247, 0.4);
    padding: 12px 36px;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

#btn-end-replay:active { transform: scale(0.95); }

#btn-end-replay:hover {
    box-shadow: 0 6px 20px rgba(123, 47, 247, 0.6);
}

#btn-end-quit {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    padding: 12px 36px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 25px;
    cursor: pointer;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

#btn-end-quit:active { transform: scale(0.95); }

#btn-end-quit:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* --- Modal Fin de partie --- */
.end-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
}

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

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

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

#end-title.success {
    background: linear-gradient(90deg, #00e676, #00d2ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#end-title.error {
    background: linear-gradient(90deg, #ff5252, #ff6fd8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

#end-overlay {
    z-index: 1100;
}

.modal-overlay.hidden { display: none !important; }

.modal-content {
    background: linear-gradient(135deg, #1a1a3e, #2a2a5e);
    border: 1px solid rgba(123, 47, 247, 0.4);
    border-radius: 16px;
    padding: 22px 18px;
    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;
}

.modal-close:hover { color: #fff; }

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(90deg, #00d2ff, #7b2ff7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

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

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

.modal-body p  { margin-bottom: 6px; }
.modal-body ol,
.modal-body ul  { padding-left: 18px; margin-bottom: 6px; }
.modal-body li  { margin-bottom: 3px; }

/* --- Animations --- */
@keyframes pulse-board {
    0%   { box-shadow: 0 0 8px rgba(123, 47, 247, 0.3), inset 0 0 20px rgba(123, 47, 247, 0.1); }
    100% { box-shadow: 0 0 22px rgba(123, 47, 247, 0.6), inset 0 0 30px rgba(123, 47, 247, 0.25); }
}

#board-zone.active { animation: pulse-board 1.2s ease-in-out infinite alternate; }

@keyframes pulse-hand {
    0%   { box-shadow: 0 0 8px rgba(0, 210, 255, 0.3), inset 0 0 20px rgba(0, 210, 255, 0.1); }
    100% { box-shadow: 0 0 22px rgba(0, 210, 255, 0.6), inset 0 0 30px rgba(0, 210, 255, 0.25); }
}

#hand-zone.active { animation: pulse-hand 1.2s ease-in-out infinite alternate; }

@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; }

/* --- Utilitaires --- */
.hidden { display: none !important; }

/* --- Responsive petits écrans --- */
@media (max-height: 700px) {
    #game-container { padding: 5px 8px; gap: 4px; }
    #game-title     { font-size: 1.25rem; margin-bottom: 2px; }
    .score-number   { font-size: 1.1rem; }
    #info-bar       { padding: 3px 6px; }
    .info-value     { font-size: 0.9rem; }
    .info-label     { font-size: 0.55rem; }
    #hand-zone      { height: 150px; }
    #game-main .game-btn       { padding: 8px 18px; font-size: 0.78rem; }
    #action-container .game-btn { padding: 7px 10px; font-size: 0.78rem; }
}

@media (max-height: 580px) {
    #game-title     { font-size: 1.1rem; }
    #hand-zone      { height: 130px; }
    #game-main .set-btn { font-size: 0.62rem; padding: 3px 2px; }
    #board-zone::before,
    #hand-zone::before { font-size: 0.5rem; }
    #scores-container { gap: 18px; }
}

/* --- Tablette --- */
@media (min-width: 768px) {
    #game-container { padding: 16px; gap: 10px; }
    #game-title     { font-size: 1.9rem; }
    .score-number   { font-size: 1.6rem; }
    #hand-zone      { height: 200px; }
    #game-main .game-btn       { padding: 12px 28px; font-size: 0.95rem; }
}

/* --- Paysage mobile --- */
@media (orientation: landscape) and (max-height: 500px) {
    #game-container {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 5px 8px;
        gap: 4px;
        max-width: 100%;
        justify-content: center;
    }
    #game-header   { width: 50%; order: 1; }
    #info-bar      { width: 50%; order: 2; }
    #mode-container,
    #set-container { width: 50%; order: 3; }
    #message-container { width: 100%; order: 4; min-height: 20px; }
    #board-zone    { order: 5; flex: 1 1 60%; min-height: 200px; }
    #hand-zone     { order: 6; flex: 0 0 100%; height: 150px; }
    #action-container,
    #controls-container { order: 7; width: 100%; }
}
