/* fartle Container */
.fartle-container {
    position: relative;
    background-position: center;
    text-align: center;
    overflow: hidden;
    min-height: 300px;
    transition: background-image 0.3s ease-in-out;
}

.fartle-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

.fartle-container * {
    position: relative;
    z-index: 2;
}

.fartle-instructions {
    font-family: 'Original Surfer', 'Arial', sans-serif;
    font-size: 18px;
    border-left: 5px solid #bada55;
    background: #0b74bfaa;
    margin-top: 15px;
    padding: 10px;
    border-top-right-radius: 15px;
    border-bottom-right-radius: 15px;
}

.fartle-instructions p,
.fartle-instructions h2 {
    color: #ffffff;
}

/* fartle Grid */
.fartle-grid {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 5px;
    margin: 0 auto;
    justify-content: center;
    padding-bottom: 15px;
}

/* fartle Rows */
.fartle-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
}

/* fartle Tiles */
.fartle-tile {
    width: 75px;
    height: 75px;
    border: 2px solid #555;
    font-size: 30px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
    box-shadow: 2px 2px 5px rgba(2, 32, 75, 0.4);
    background-color: #0b74bf;
    color: #EAEAEA;
}
html.dark-mode .fartle-tile {
    border: 2px solid #bada55;
    background-color: #0b5285;
}
@media (max-width: 768px) {
    .fartle-tile {
        width: 65px;
        height: 65px;
    }
}

/* Tile Colors for Correct, Present, and Absent States */
.fartle-tile.correct {
    background-color: #4ad71c !important;
    color: #181818;
}

.fartle-tile.present {
    background-color: #F05454 !important;
    color: #181818;
}

.fartle-tile.absent {
    background-color: #0a5388aa;
    color: #EAEAEA;
    text-decoration: line-through;
}

.fartle-tile.flip {
    animation: flip 0.6s;
}

.fartle-tile.shake {
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    15%       { transform: translateX(-7px); }
    35%       { transform: translateX(7px); }
    55%       { transform: translateX(-5px); }
    75%       { transform: translateX(5px); }
    90%       { transform: translateX(-2px); }
}

@keyframes flip {
    0% {
        transform: rotateX(0deg);
    }
    50% {
        transform: rotateX(90deg);
    }
    100% {
        transform: rotateX(0deg);
    }
}

/* Game Popup */
#game-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.popup-content {
    background: #2E2E2E;
    color: #EAEAEA;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    max-width: 300px;
    width: 80%;
}

.popup-content p {
    font-size: 18px;
    margin-bottom: 20px;
}

/* Popup Button */
#popup-ok-btn {
    padding: 10px 20px;
    background-color: #5BC0BE;
    color: #181818;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
}

#popup-ok-btn:hover {
    background-color: #3A3A3A;
    color: #EAEAEA;
}

/* Virtual Keyboard */
.virtual-keyboard {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.keyboard-row {
    display: flex;
    gap: 1px;
    justify-content: center;
}

/* Virtual Keyboard Keys */
.virtual-key {
    padding: 7px;
    font-size: 18px;
    font-weight: bold;
    box-shadow: 2px 2px 5px rgba(2, 32, 75, 0.4);
    background-color: #0b74bfaa;
    color: #EAEAEA;
    border: 2px solid #555;
    border-radius: 5px;
    cursor: pointer;
    margin: 2px;
    transition: background-color 0.3s ease;
}

.virtual-key:active {
    background-color: #5BC0BE !important;
    color: #181818 !important;
}

.virtual-key.correct {
    background-color: #4ad71c !important;
    color: #181818 !important;
    border-color: #4ad71c !important;
}

.virtual-key.present {
    background-color: #F05454 !important;
    color: #181818 !important;
    border-color: #F05454 !important;
}

.virtual-key.absent {
    background-color: #0a5388aa !important;
    color: #EAEAEA !important;
    text-decoration: line-through;
}

/* Visual if word has multiple of the same letter */
.fartle-tile[data-dup] {
  position: relative;
}

.fartle-tile[data-dup]::after {
  content: "\00d7" attr(data-dup);
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.6em;
  opacity: 0.7;
  pointer-events: none;
}

/* =============================================
   WIDE LAYOUT (1100px+)
   ============================================= */
#fartle-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#fartle-sidebar {
    display: contents;
}

.full-width-section-header { order: 0; }
#unlimited-hud    { order: 1; }
#fartle-main      { order: 2; }
.virtual-keyboard { order: 3; }

#fartle-main {
    display: flex;
    flex-direction: column;
    align-items: center;
}

@media (min-width: 1100px) {
    #fartle-layout {
        flex-direction: row;
        align-items: flex-start;
        justify-content: center;
        gap: 24px;
    }

    /* Grid goes left */
    #fartle-main {
        order: 1;
    }

    #fartle-sidebar {
        display: flex;
        order: 2;
        flex-direction: column;
        align-items: center;
        gap: 16px;
        position: sticky;
        align-self: flex-start;
    }

    .full-width-section-header { order: unset; }
    #unlimited-hud    { order: unset; width: 100%; }
    .virtual-keyboard { order: unset; }

    /* Shrink the title to fit the sidebar column */
    #fartle-sidebar .full-width-section-header h1 {
        font-size: 1.5rem;
    }

    #fartle-sidebar .full-width-section-header img {
        width: 48px;
        height: 48px;
    }

    /* HUD */
    #unlimited-hud {
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        width: 200px;
        gap: 14px;
        padding: 16px;
        margin: 0;
        border-radius: 10px;
    }

    #hud-word-count {
        font-size: 15px;
        border-bottom: 1px solid rgba(255,255,255,0.2);
        padding-bottom: 12px;
        width: 100%;
    }

    #hud-score {
        font-size: 26px;
        letter-spacing: 1px;
    }

    #hud-streak {
        font-size: 16px;
    }

    #hud-lives {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }

    .hud-life {
        width: 36px;
        height: 36px;
    }

    #fartle-sidebar .virtual-key {
        padding: 5px 4px;
        font-size: 14px;
        margin: 1px;
    }
}

/* =============================================
   UNLIMITED HUD
   ============================================= */
#unlimited-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    margin: 8px 0 10px;
    background: #0b74bfcc;
    border-radius: 10px;
    flex-wrap: wrap;
}

#hud-word-count {
    font-weight: bold;
    font-size: 16px;
    color: #fff;
}

#hud-streak {
    font-weight: bold;
    font-size: 15px;
    color: #bada55;
    visibility: hidden;
}

#hud-lives {
    display: flex;
    align-items: center;
    gap: 4px;
}

.hud-life {
    width: 32px;
    height: 32px;
    transition: transform 0.2s;
}

.hud-life.lost {
    opacity: 0.35;
    transform: scale(0.85);
}

#hud-score {
    font-weight: bold;
    font-size: 18px;
    color: #bada55;
    letter-spacing: 1px;
}

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */
.fartle-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-12px);
    padding: 12px 22px;
    border-radius: 10px;
    font-size: 17px;
    font-weight: bold;
    color: #fff;
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    text-align: center;
}

.fartle-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.fartle-toast--success {
    background: #2a9e0a;
    border: 2px solid #bada55;
}

.fartle-toast--error {
    background: #b52020;
    border: 2px solid #ff6b6b;
}

.fartle-toast--info {
    background: #0b74bf;
    border: 2px solid #5bb8f5;
}

.fartle-toast--warning {
    background: #9e6e0a;
    border: 2px solid #f0c040;
}

/* =============================================
   STATS PANEL
   ============================================= */
#fartle-stats {
    margin-top: 16px;
    padding: 20px;
    border-left: 5px solid #bada55;
    background: #0b74bfc7;
    border-top-right-radius: 15px;
    border-bottom-right-radius: 15px;
    font-family: 'Original Surfer', 'Arial', sans-serif;
    color: #fff;
}

.fstats-title {
    margin: 0 0 14px;
    color: #bada55;
    font-size: 22px;
}

/* Stat Cards Grid */
.fstats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.fstat-card {
    background: rgba(0,0,0,0.3);
    border: 2px solid #bada55;
    border-radius: 10px;
    padding: 10px 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.4);
}

.fstat-val {
    font-size: 22px;
    font-weight: bold;
    color: #bada55;
    line-height: 1.1;
}

.fstat-lbl {
    font-size: 11px;
    color: #cceeff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Guess Distribution */
.fstats-dist {
    margin-bottom: 14px;
}

.fdist-heading {
    margin: 0 0 8px;
    font-size: 15px;
    color: #cceeff;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.fdist-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.fdist-label {
    font-size: 14px;
    font-weight: bold;
    color: #bada55;
    width: 14px;
    text-align: right;
    flex-shrink: 0;
}

.fdist-bar-wrap {
    flex: 1;
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
    height: 20px;
    overflow: hidden;
}

.fdist-bar {
    height: 100%;
    background: #bada55;
    border-radius: 4px;
    transition: width 0.4s ease;
    min-width: 0;
}

.fdist-count {
    font-size: 13px;
    color: #fff;
    width: 24px;
    text-align: left;
    flex-shrink: 0;
}

/* Meta / footer lines */
.fstats-meta,
.fstats-disclaimer {
    font-size: 12px;
    color: #ffffff;
    margin: 6px 0 0;
}

.fstats-disclaimer {
    color: #ffffff;
    font-style: italic;
}

/* Reset Button */
.fstats-reset-btn {
    margin-top: 14px;
    padding: 6px 16px;
    background: transparent;
    color: #ff8888;
    border: 2px solid #ff8888;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.fstats-reset-btn:hover {
    background: #ff4444;
    color: #fff;
    border-color: #ff4444;
}
