/* ========================================================================
   FREECELL - Green Felt Theme with Gold Accent
   ======================================================================== */

:root {
    --fc-bg: #1a4a1a;
    --fc-bg-light: #1e5a1e;
    /* Seitenverhaeltnis der Kartengrafiken: 58.60mm : 89.08mm = 0.658 */
    --fc-card-width: 92px;
    --fc-card-height: 140px;
    /* Eckenradius der Grafiken: 4.49% der Kartenbreite */
    --fc-card-radius: 4px;
    --fc-gold: #d4af37;
    --fc-gold-light: #e8c86e;
    /* Erster Schatten = Haarlinien-Kontur (kein border, damit die Kartenmasse
       im content-box-Modell exakt bleiben). */
    --fc-card-shadow: 0 0 0 1px rgba(29, 29, 30, 0.35), 0 2px 6px rgba(0, 0, 0, 0.3);
    --fc-card-shadow-hover: 0 0 0 1px rgba(29, 29, 30, 0.45), 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Background */
.fc-bg {
    background: radial-gradient(ellipse at center, var(--fc-bg-light) 0%, var(--fc-bg) 100%);
}

/* Board */
.fc-board {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 8px;
    max-width: 900px;
    margin: 0 auto;
}

/* --- Top Row --- */
.fc-top-row {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.fc-free-cells,
.fc-foundations {
    display: flex;
    gap: 10px;
}

/* Slot (empty card space) */
.fc-slot {
    width: var(--fc-card-width);
    height: var(--fc-card-height);
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.2);
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: var(--fc-card-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.fc-slot:not(.fc-slot-filled):hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.25);
}

/* Belegter Slot: eigener Rahmen und Hintergrund weichen der Karte. Sonst
   stehen zwei Konturen uebereinander - der Slot-Rahmen und die Kontur der
   Karte. Ohne Rahmen ist die Innenbreite ausserdem wieder volle Kartenbreite,
   die Karte wird also nicht mehr vom Flex-Layout schmalgedrueckt. */
.fc-slot.fc-slot-filled {
    border-color: transparent;
    background: transparent;
}

.fc-slot.fc-valid-target {
    border-color: var(--fc-gold);
    background: rgba(212, 175, 55, 0.15);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
}

.fc-slot-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.25);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.fc-foundation-suit {
    font-size: 32px;
    color: rgba(255, 255, 255, 0.15);
}

.fc-foundation-slot {
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.1);
}

/* --- Cards --- */
.fc-card {
    width: var(--fc-card-width);
    height: var(--fc-card-height);
    background: #fefefe;
    border-radius: var(--fc-card-radius);
    position: absolute;
    cursor: pointer;
    box-shadow: var(--fc-card-shadow);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
    user-select: none;
}

/* --- Kartengrafik (SVG) ---
   Die SVGs sind transparent und bringen ihre eigene Kontur mit; die
   Kartenflaeche kommt aus dem Hintergrund des .fc-card-Containers. */
.fc-card-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    border-radius: inherit;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
}

/* Hover nur fuer Karten, die ohnehin vollstaendig sichtbar sind: die unterste
   einer Tableau-Spalte sowie Karten in Freizellen und Ablagen.
   Eine teilweise verdeckte Karte darf sich NICHT hervorheben - sonst gibt der
   Hover den Blick auf ihren verdeckten Teil frei ("spieken"). Genau das ist
   nach einem Drop passiert: der Zeiger stand auf der Zielkarte, die sich per
   z-index: 100 vor die ganze Spalte geschoben hat.
   Deshalb hier auch kein z-index-Wechsel - die unterste Karte liegt bereits
   vorn und braucht keinen. */
.fc-slot .fc-card:hover,
.fc-tableau-col .fc-card:last-child:hover {
    box-shadow: var(--fc-card-shadow-hover);
    transform: translateY(-2px);
}

.fc-card.fc-selected {
    box-shadow: 0 0 0 2px var(--fc-gold), 0 4px 12px rgba(0, 0, 0, 0.35);
    transform: translateY(-4px);
    z-index: 200 !important;
}

/* Card in a slot (not in tableau) */
.fc-slot .fc-card {
    position: relative;
    flex-shrink: 0;   /* nicht vom Flex-Layout des Slots schmaldruecken lassen */
}

/* --- Tableau --- */
.fc-tableau-row {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.fc-tableau-col {
    width: var(--fc-card-width);
    position: relative;
    min-height: var(--fc-card-height);
}

.fc-empty-col {
    width: var(--fc-card-width);
    height: var(--fc-card-height);
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.12);
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: var(--fc-card-radius);
    cursor: pointer;
    transition: all 0.15s ease;
}

.fc-empty-col:hover {
    border-color: rgba(255, 255, 255, 0.25);
}

.fc-empty-col.fc-valid-target,
.fc-tableau-col.fc-valid-target .fc-empty-col {
    border-color: var(--fc-gold);
    background: rgba(212, 175, 55, 0.12);
}

/* --- Drag & Drop --- */

/* Gezogene Karten verschwinden an der Herkunftsstelle komplett - sie haengen
   ja am Zeiger. Unsichtbare Elemente werden gar nicht erst gezeichnet. */
.fc-card.fc-dragging {
    visibility: hidden;
    pointer-events: none;
}

/* Waehrend eines Drags reagiert das Board nicht auf den Zeiger. Die
   Trefferpruefung laeuft ueber die zwischengespeicherten Rechtecke in
   freecell.js, nicht ueber den DOM - :hover wird also nicht gebraucht.

   WICHTIG: den Hover hier NICHT ueber "z-index: auto" neutralisieren. Die
   Tableau-Karten tragen ein Inline-z-index von 1..n; positionierte Elemente
   mit positivem z-index werden nach denen mit auto gezeichnet. Die
   ueberfahrene Karte faellt damit hinter die gesamte Spalte und verschwindet
   hinter ihren Vorgaengern - und das staendige Umstapeln flackert. */
.fc-is-dragging .fc-card,
.fc-is-dragging .fc-slot,
.fc-is-dragging .fc-empty-col {
    pointer-events: none;
    transition: none;
}

/* Wird per transform bewegt (siehe freecell.js) und liegt dadurch auf einer
   eigenen Compositor-Ebene: Verschieben kostet weder Layout noch Repaint. */
.fc-drag-ghost {
    width: var(--fc-card-width);
    pointer-events: none;
    transform-origin: top left;
    will-change: transform;
}

.fc-drag-ghost .fc-card {
    box-shadow: 0 0 0 1px rgba(29, 29, 30, 0.45), 0 8px 24px rgba(0, 0, 0, 0.5);
    transform: none;
    transition: none;
}

.fc-drop-target-possible {
    transition: border-color 0.15s ease, background 0.15s ease;
}

.fc-drop-target-hover {
    border-color: var(--fc-gold) !important;
    background: rgba(212, 175, 55, 0.18) !important;
    box-shadow: 0 0 14px rgba(212, 175, 55, 0.35);
}

.fc-tableau-col.fc-drop-target-hover .fc-empty-col {
    border-color: var(--fc-gold);
    background: rgba(212, 175, 55, 0.15);
}

/* --- Win Overlay --- */
.fc-win-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 20000;
    animation: fcFadeIn 0.5s ease;
    backdrop-filter: blur(6px);
}

.fc-win-card {
    background: linear-gradient(135deg, var(--fc-bg-light) 0%, var(--fc-bg) 100%);
    border: 3px solid var(--fc-gold);
    border-radius: 16px;
    padding: 40px 60px;
    text-align: center;
    color: #e0ddd4;
    box-shadow: 0 0 60px rgba(212, 175, 55, 0.3);
    animation: fcScaleIn 0.5s ease 0.2s both;
}

.fc-win-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--fc-gold-light);
    margin-bottom: 16px;
    letter-spacing: 2px;
}

.fc-win-stats {
    font-size: 16px;
    margin-bottom: 24px;
    line-height: 1.8;
}

.fc-win-stats strong {
    color: var(--fc-gold-light);
}

@keyframes fcFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fcScaleIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* --- Responsive ---
   Breite immer aus der Hoehe abgeleitet, damit das Seitenverhaeltnis der
   Kartengrafiken erhalten bleibt (Hoehe x 0.658). */
@media (max-width: 900px) {
    :root {
        --fc-card-width: 74px;
        --fc-card-height: 112px;
        --fc-card-radius: 3px;
    }
    .fc-foundation-suit { font-size: 26px; }
    .fc-slot-label { font-size: 11px; }
    .fc-board { max-width: 740px; }
    .fc-top-row { gap: 8px; }
    .fc-free-cells, .fc-foundations { gap: 8px; }
    .fc-tableau-row { gap: 8px; }
    .fc-win-card { padding: 24px 32px; }
    .fc-win-title { font-size: 24px; }
}

@media (max-width: 650px) {
    :root {
        --fc-card-width: 55px;
        --fc-card-height: 84px;
        --fc-card-radius: 2px;
    }
    .fc-foundation-suit { font-size: 20px; }
    .fc-slot-label { font-size: 9px; }
    .fc-board { max-width: 560px; gap: 12px; }
    .fc-top-row { gap: 4px; }
    .fc-free-cells, .fc-foundations { gap: 4px; }
    .fc-tableau-row { gap: 4px; }
}

@media (max-width: 480px) {
    :root {
        --fc-card-width: 41px;
        --fc-card-height: 62px;
        --fc-card-radius: 2px;
    }
    .fc-board { max-width: 420px; gap: 8px; }
    .fc-top-row { gap: 3px; }
    .fc-free-cells, .fc-foundations { gap: 3px; }
    .fc-tableau-row { gap: 3px; }
}
