/* =====================================================
   SOLITAIRE ROYAL — style.css
   ===================================================== */

:root {
    --bg-color: #0a6e1e;
    --card-width: 70px;
    --card-height: 100px;
    --card-radius: 8px;
    --card-overlap: 22px;
    --card-red: #d32f2f;
    --card-black: #1a1a1a;
    --card-bg: #ffffff;
    --accent: #ffd700;
    --accent2: #ff6b35;
    --dark-bg: #1a1a2e;
    --panel-bg: rgba(0,0,0,0.85);
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-color);
    background-image: radial-gradient(ellipse at center, rgba(255,255,255,0.05) 0%, transparent 70%);
    color: #fff;
    min-height: 100vh;
    overflow-x: hidden;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

/* ── TOP BAR ─────────────────────────────────── */
.top-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px;
    background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0.3) 100%);
    gap: 8px; flex-wrap: wrap;
}
.top-bar-left, .top-bar-right { display: flex; align-items: center; gap: 8px; }
.top-bar-center { display: flex; align-items: center; gap: 15px; font-size: 0.85em; }

.currency {
    display: flex; align-items: center; gap: 4px;
    background: rgba(255,255,255,0.15);
    padding: 4px 10px; border-radius: 20px;
    font-weight: bold; font-size: 0.9em;
}
.currency i { color: var(--accent); }
.currency.energy i { color: #4caf50; }
.currency.gems i { color: #e040fb; }

.btn {
    background: rgba(255,255,255,0.2); border: none; color: #fff;
    padding: 8px 12px; border-radius: 8px; cursor: pointer;
    font-size: 0.9em; display: flex; align-items: center; gap: 5px;
    transition: all 0.2s; touch-action: manipulation;
}
.btn:hover, .btn:active { background: rgba(255,255,255,0.35); transform: scale(0.97); }
.btn-accent { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #1a1a1a; font-weight: bold; }
.btn-accent:hover { background: linear-gradient(135deg, var(--accent2), var(--accent)); }

/* ── LEVEL BAR ───────────────────────────────── */
.level-bar {
    display: flex; align-items: center; justify-content: center;
    padding: 5px 12px; background: rgba(0,0,0,0.25); gap: 10px; font-size: 0.8em;
}
.xp-bar-container {
    flex-grow: 1; max-width: 300px; height: 12px;
    background: rgba(255,255,255,0.15); border-radius: 10px;
    overflow: hidden; position: relative;
}
.xp-bar-fill {
    height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 10px; transition: width 0.5s ease; width: 0%;
}
.xp-bar-text {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.7em; font-weight: bold; text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.level-badge {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #1a1a1a; padding: 3px 10px; border-radius: 12px;
    font-weight: bold; font-size: 0.85em;
}
.streak-badge {
    background: linear-gradient(135deg, #ff6b35, #ff1744);
    padding: 2px 8px; border-radius: 10px; font-size: 0.75em; font-weight: bold;
}

/* ── GAME AREA ───────────────────────────────── */
#game-area {
    display: flex; flex-direction: column; align-items: center;
    padding: 8px; gap: 10px; max-width: 700px; margin: 0 auto;
}
.piles-row { display: flex; gap: 8px; width: 100%; justify-content: center; }
.pile-spacer { flex-grow: 1; max-width: 30px; }

.pile {
    width: var(--card-width); min-height: var(--card-height);
    border: 2px dashed rgba(255,255,255,0.3);
    border-radius: var(--card-radius); position: relative; flex-shrink: 0;
    transition: border-color 0.2s, background 0.2s;
}
/* Surbrillance quand on survole avec une carte valide */
.pile.drop-valid {
    border-color: #00e676;
    background: rgba(0,230,118,0.12);
    box-shadow: 0 0 0 2px rgba(0,230,118,0.4);
}
.pile.drop-invalid {
    border-color: rgba(244,67,54,0.6);
    background: rgba(244,67,54,0.07);
}

.pile.stock { cursor: pointer; }
.pile.foundation { border-color: rgba(255,215,0,0.4); background: rgba(255,215,0,0.05); }
.pile.foundation::after {
    content: attr(data-suit); position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); font-size: 1.8em; opacity: 0.25; pointer-events: none;
}

.tableau-row { display: flex; gap: 8px; width: 100%; justify-content: center; align-items: flex-start; }
.tableau-pile { min-height: calc(var(--card-height) + 80px); }

/* ── CARDS ───────────────────────────────────── */
.card {
    position: absolute; width: var(--card-width); height: var(--card-height);
    background: var(--card-bg); border: 1px solid rgba(0,0,0,0.15);
    border-radius: var(--card-radius); display: flex; flex-direction: column;
    justify-content: space-between; padding: 4px 6px; cursor: grab;
    touch-action: none; transition: box-shadow 0.15s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2); z-index: 1; left: 0; top: 0;
}
.card.face-down {
    background: linear-gradient(135deg, #1a5276, #2e86c1);
    cursor: pointer; border: 2px solid #154360;
}
.card.face-down * { display: none; }
.card .card-top { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.card .card-center { font-size: 2em; text-align: center; line-height: 1; margin: -5px 0; }
.card .card-bottom { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; transform: rotate(180deg); }
.card .rank { font-size: 0.85em; font-weight: bold; }
.card .suit-small { font-size: 0.7em; }
.card.red { color: var(--card-red); }
.card.black { color: var(--card-black); }

.card.selected { box-shadow: 0 0 0 3px var(--accent), 0 4px 15px rgba(255,215,0,0.4); z-index: 100; }
.card.drag-ghost {
    position: fixed; z-index: 10000; pointer-events: none;
    transform: rotate(3deg) scale(1.05);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); opacity: 0.92;
}
.card.hint-glow { animation: hintPulse 0.8s ease-in-out 3; }
.card.flip-anim { animation: flipCard 0.3s ease-out; }
.card.deal-anim { animation: dealIn 0.25s ease-out; }

/* ── RECYCLE ─────────────────────────────────── */
.recycle-btn {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center;
    font-size: 2em; color: rgba(255,255,255,0.5); cursor: pointer;
    transition: color 0.2s; border-radius: var(--card-radius);
}
.recycle-btn:hover, .recycle-btn:active { color: rgba(255,255,255,0.9); }

/* ── CONTROLS ────────────────────────────────── */
.controls { display: flex; gap: 10px; justify-content: center; padding: 5px; flex-wrap: wrap; }

/* ── TOAST ───────────────────────────────────── */
#toast {
    position: fixed; bottom: 40px; left: 50%;
    transform: translateX(-50%) translateY(60px);
    background: rgba(0,0,0,0.88); color: #fff;
    padding: 10px 22px; border-radius: 22px; font-size: 0.9em;
    z-index: 25000; transition: transform 0.3s, opacity 0.3s;
    opacity: 0; pointer-events: none; white-space: nowrap;
    border: 1px solid rgba(255,255,255,0.1);
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ── COPYRIGHT ───────────────────────────────── */
#copyright {
    position: fixed; bottom: 8px; right: 12px; font-size: 0.7em;
    color: rgba(255,255,255,0.5); pointer-events: none; z-index: 1;
}

/* ── OVERLAYS ────────────────────────────────── */
.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); display: flex; justify-content: center;
    align-items: center; z-index: 20000; opacity: 0; visibility: hidden;
    transition: all 0.3s;
}
.overlay.active { opacity: 1; visibility: visible; }
.overlay-panel {
    background: var(--dark-bg); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px; padding: 25px; max-width: 420px; width: 92%;
    max-height: 85vh; overflow-y: auto; transform: translateY(20px);
    transition: transform 0.3s;
}
.overlay.active .overlay-panel { transform: translateY(0); }
.overlay-panel h2 { text-align: center; margin-bottom: 15px; font-size: 1.3em; color: var(--accent); }
.overlay-panel h3 { color: var(--accent2); margin: 12px 0 6px; font-size: 1em; }

.menu-btn {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 12px 15px; margin-bottom: 8px;
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px; color: #fff; font-size: 1em; cursor: pointer;
    transition: all 0.2s; touch-action: manipulation;
}
.menu-btn:hover, .menu-btn:active { background: rgba(255,255,255,0.18); transform: scale(0.98); }
.menu-btn i { width: 20px; text-align: center; }

/* ── SETTINGS ────────────────────────────────── */
.setting-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.08); gap: 10px;
}
.setting-row label { color: #ccc; font-size: 0.9em; flex-shrink: 0; }
.setting-row input[type="color"] { width: 40px; height: 30px; border: none; border-radius: 6px; cursor: pointer; background: none; }
.setting-row input[type="text"], .setting-row select {
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
    color: #fff; padding: 6px 10px; border-radius: 6px; font-size: 0.9em;
    flex-grow: 1; max-width: 180px;
}
.toggle {
    position: relative; width: 48px; height: 26px;
    background: rgba(255,255,255,0.2); border-radius: 13px;
    cursor: pointer; transition: background 0.3s; flex-shrink: 0;
}
.toggle.on { background: #4caf50; }
.toggle::after {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 20px; height: 20px; background: #fff;
    border-radius: 50%; transition: transform 0.3s;
}
.toggle.on::after { transform: translateX(22px); }

/* ── WIN / STATS ─────────────────────────────── */
.win-stars { font-size: 3em; text-align: center; margin: 10px 0; }
.win-stats { display: flex; flex-direction: column; gap: 8px; margin: 15px 0; }
.win-stat {
    display: flex; justify-content: space-between;
    padding: 8px 12px; background: rgba(255,255,255,0.08); border-radius: 8px;
}
.win-stat .val { color: var(--accent); font-weight: bold; }
.reward-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px; background: rgba(255,215,0,0.1);
    border: 1px solid rgba(255,215,0,0.2); border-radius: 8px; margin: 4px 0;
}
.reward-item i { color: var(--accent); }

/* ── PARTICLE ────────────────────────────────── */
.particle {
    position: fixed; pointer-events: none; font-size: 1.5em;
    z-index: 30000; animation: floatUp 1.5s ease-out forwards;
}

/* ── WIN FIREWORKS CANVAS ────────────────────── */
#fireworks-canvas {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 19000;
    opacity: 0; transition: opacity 0.5s;
}
#fireworks-canvas.active { opacity: 1; }

/* ── RULES ───────────────────────────────────── */
.rules-section {
    margin-bottom: 18px; padding-bottom: 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.rules-section:last-child { border-bottom: none; }
.rules-section h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 1.05em; }
.rules-section h3 i { width: 22px; text-align: center; }
.rules-text { color: #bbb; font-size: 0.88em; line-height: 1.55; margin-bottom: 6px; }
.rules-text strong { color: #fff; }
.rules-example {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 12px; margin: 6px 0;
    background: rgba(255,255,255,0.06);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    font-size: 0.85em; color: #ccc;
}
.rules-example i { color: var(--accent); flex-shrink: 0; }
.rules-card-demo {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 42px; background: #fff;
    border-radius: 4px; font-size: 0.8em; font-weight: bold;
    margin: 0 2px; border: 1px solid rgba(0,0,0,0.15); vertical-align: middle;
}
.rules-card-demo.red { color: var(--card-red); }
.rules-card-demo.black { color: var(--card-black); }
.rules-tip {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 8px 12px; margin: 6px 0;
    background: rgba(76,175,80,0.1); border: 1px solid rgba(76,175,80,0.2);
    border-radius: 8px; font-size: 0.85em; color: #a5d6a7;
}
.rules-tip i { color: #4caf50; margin-top: 2px; flex-shrink: 0; }
.rules-warning {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 8px 12px; margin: 6px 0;
    background: rgba(255,152,0,0.1); border: 1px solid rgba(255,152,0,0.2);
    border-radius: 8px; font-size: 0.85em; color: #ffcc80;
}
.rules-warning i { color: #ff9800; margin-top: 2px; flex-shrink: 0; }
.rules-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 15px; justify-content: center; }
.rules-nav-btn {
    padding: 5px 10px; border-radius: 15px;
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
    color: #ccc; font-size: 0.75em; cursor: pointer; transition: all 0.2s; touch-action: manipulation;
}
.rules-nav-btn:hover, .rules-nav-btn.active {
    background: rgba(255,215,0,0.2); border-color: var(--accent); color: var(--accent);
}

/* ── KEYFRAMES ───────────────────────────────── */
@keyframes hintPulse {
    0%, 100% { box-shadow: 0 0 0 3px transparent; }
    50% { box-shadow: 0 0 0 4px #00e676, 0 0 15px rgba(0,230,118,0.5); }
}
@keyframes flipCard {
    0%   { transform: scaleX(0); }
    100% { transform: scaleX(1); }
}
@keyframes dealIn {
    0%   { opacity: 0; transform: translateY(-30px) scale(0.85); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes floatUp {
    0%   { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-100px) scale(0.5); }
}
@keyframes winPulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.08); }
}
.win-pulse { animation: winPulse 0.6s ease-in-out 3; }

/* ── RESPONSIVE ──────────────────────────────── */
@media (max-width: 600px) {
    :root { --card-width: 48px; --card-height: 70px; --card-overlap: 16px; }
    .card .rank { font-size: 0.7em; }
    .card .suit-small { font-size: 0.55em; }
    .card .card-center { font-size: 1.4em; }
    .top-bar { padding: 5px 8px; }
    .top-bar-center { gap: 8px; }
    .currency { padding: 3px 7px; font-size: 0.8em; }
    .btn { padding: 6px 8px; font-size: 0.8em; }
    .level-bar { padding: 3px 8px; }
    .overlay-panel { padding: 18px; }
}
@media (max-width: 400px) {
    :root { --card-width: 42px; --card-height: 62px; --card-overlap: 14px; }
}
