/* =====================
   ROOT VARIABLES
===================== */
:root {
  --orange-bg: #ff8c1a;
  --orange-dark: #ff7a00;
  --card-bg: #ffffff;
  --tile-bg: #fff7ee;
  --primary: #4a2cff;
  --text-dark: #2b2b2b;
  --success: #1e9e5c;
  --danger: #e63946;
}

/* =====================
   RESET & BASE
===================== */
* {
  box-sizing: border-box;
}

body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
              /*overflow: hidden;*/
            height: 100vh;
            width: 100vw;
            background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
        }

.hidden {
  display: none !important;
}

/* =====================
   SPLASH SCREEN
===================== */
 /* Reset and base styles */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        #splash {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
            z-index: 1000;
            overflow-y: auto;
        }

.splash-logo {
  width: 120px; 
  height: auto;
  margin: 0 auto;
}

@keyframes logoFloat {
  0% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}

.splash-card {
            width: 100%;
            max-width: 400px;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(20px);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 25px;
            padding: 25px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
            text-align: center;
        }

.splash-card button {
  display: block;
  width: 100%;
  margin: 10px auto;
}

@keyframes splashPop {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.splash-card h1 {
  font-size: 36px;
  font-weight: 900;
  margin-bottom: 12px;
  color: #ffffff;
  letter-spacing: 1px;
  text-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

.game-title {
  font-size: 1.5rem;
  margin: 0;
  line-height: 1;
}

.tagline {
  font-size: 0.75rem;
  margin: 0 0 5px 0;
  opacity: 0.9;
  color: #ffffff;
}

.input-row {
  display: flex;
  gap: 5px;
}

#monthly-info {
            background: linear-gradient(135deg, #ff4757, #ff9f43);
            color: white;
            padding: 12px;
            border-radius: 15px;
            margin: 15px 0;
            text-align: center;
            box-shadow: 0 6px 12px rgba(255, 71, 87, 0.3);
        }
        
        #current-month {
            margin: 0;
            font-size: 1.1rem;
        }

        /* Remember me checkbox */
        .remember-container {
            margin: 15px 0;
            display: flex;
            align-items: center;
            gap: 10px;
            justify-content: center;
        }
        
        .remember-container input[type="checkbox"] {
            width: 20px;
            height: 20px;
            accent-color: #ff4757;
        }
        
        .remember-container label {
            color: white;
            font-size: 0.9rem;
            cursor: pointer;
        }

/* =====================
   BUTTONS
===================== */
button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 14px 26px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  margin: 0;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.2);
}

button.secondary {
  background: #ffffff;
  color: #333;
}

/* =====================
   GAME CONTAINER
===================== */
 .top-bar {
            background: rgba(26, 26, 46, 0.95);
            backdrop-filter: blur(10px);
            padding: 0px opx;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 8px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            min-height: 30px;
            flex-shrink: 0;
        }
        
        #level-indicator {
            font-size: 0.9rem;
            font-weight: bold;
            color: #ff9f43;
            text-shadow: 0 2px 4px rgba(0,0,0,0.3);
        }
        
        .top-bar > div {
            font-size: 0.9rem;
            color: white;
            display: flex;
            align-items: center;
            gap: 4px;
        }

#game {
    /* Layout & Scrolling */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 900px;
    margin: auto;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;

    /* Spacing */
    padding: 10px 14px 80px 14px; /* Top, Right, Bottom, Left */
}

.total-score-box {
  background: #ffeb3b;
  color: #000;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: bold;
  box-shadow: 0 0 6px rgba(0,0,0,0.3);
}

.progress-section {
            padding: 8px 15px;
            flex-shrink: 0;
        }
        
        .progress-3d {
            height: 16px;
            background: linear-gradient(145deg, #2c3e50, #34495e);
            border-radius: 8px;
            overflow: hidden;
            box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
            border: 1px solid rgba(255, 255, 255, 0.05);
        }
        
        .progress-fill-3d {
            height: 100%;
            background: linear-gradient(90deg, #ff9f43, #ff4757, #ff6b6b);
            border-radius: 8px;
            transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
        }
        
/* =====================
   CARDS CONTAINER
===================== */

 /* Cards section - SINGLE CARD FOR ALL DEVICES */
        .cards-section {
            flex: 1;
            min-height: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 0px 0px;
              /* overflow: hidden;*/
            overflow: visible;
        }
        
        .cards-container {
            display: flex;
            justify-content: center;
            align-items: center;
            width: 100%;
            max-width: 800px;
            height: 100%;
        }
        
        /* Desktop: One big card with all letters */
        .single-card {
            width: 100%;
            max-width: 700px;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 25px;
            background: linear-gradient(135deg, #2c3e50, #34495e);
            border-radius: 25px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
            min-height: 220px;
            max-height: 280px;
            overflow-y: auto;
            border: 3px solid rgba(255, 255, 255, 0.15);
        }
        
        .card-row {
            display: flex;
            justify-content: center;
            gap: 15px;
            margin-bottom: 15px;
            width: 100%;
            flex-wrap: wrap;
        }

        /* Tiles - BIGGER for better visibility */
        .tile-3d {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 90px;
            height: 100px;
            background: linear-gradient(145deg, #ff6b6b, #ff4757);
            color: white;
            font-weight: 900;
            font-size: 30px;
            border-radius: 15px;
            cursor: pointer;
            user-select: none;
            transition: all 0.2s ease;
            position: relative;
            box-shadow: 
                0 10px 20px rgba(255, 71, 87, 0.5),
                0 5px 10px rgba(0, 0, 0, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
            border: 2px solid rgba(255, 255, 255, 0.2);
            flex-shrink: 0;
        }
        
        .tile-3d:active {
            transform: translateY(-4px) scale(0.97);
            box-shadow: 
                0 8px 16px rgba(255, 71, 87, 0.4),
                0 4px 8px rgba(0, 0, 0, 0.2);
        }
        
        .tile-points {
            position: absolute;
            bottom: 8px;
            right: 8px;
            font-size: 12px;
            font-weight: bold;
            background: rgba(0, 0, 0, 0.6);
            color: #FFD700;
            width: 22px;
            height: 22px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            border: 1px solid rgba(255, 215, 0, 0.5);
            box-shadow: 0 2px 4px rgba(0,0,0,0.3);
        }

        /* Complete mobile tile redesign */
@media (max-width: 768px) {
    .tile-3d {
        width: 60px !important;
        height: 70px !important;
        padding: 6px 2px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        background: linear-gradient(145deg, #ff6b6b, #ff4757);
        border-radius: 12px !important;
        box-shadow: 0 6px 0 #1e4b6e, 0 8px 12px rgba(0,0,0,0.3) !important;
    }
    
    /* Bigger, bolder letter */
    .tile-3d > div:first-child {
        font-size: 36px !important;
        font-weight: 900 !important;
        color: white !important;
        text-shadow: 0 3px 6px rgba(0,0,0,0.5) !important;
        line-height: 1 !important;
        margin-bottom: 2px !important;
    }
    
    /* Point badge below letter */
    .tile-points {
        position: static !important;
        width: 30px !important;
        height: 30px !important;
        font-size: 14px !important;
        font-weight: bold !important;
        background: rgba(0, 0, 0, 0.7) !important;
        color: #FFD700 !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin-top: 2px !important;
        border: 2px solid #FFD700 !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.3) !important;
    }
}

/* Even smaller screens */
@media (max-width: 480px) {
    .tile-3d {
        width: 50px !important;
        height: 60px !important;
    }
    
    .tile-3d > div:first-child {
        font-size: 30px !important;
    }
    
    .tile-points {
        width: 24px !important;
        height: 24px !important;
        font-size: 12px !important;
    }
}
        
        /* Input boxes - VISIBLE and PROMINENT */
        .input-section {
            padding: 15px 10px;
            flex-shrink: 0;
            background: rgba(0, 0, 0, 0.2);
            border-radius: 15px;
            margin: 0 10px;
        }
        
        .input-boxes-container {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 10px;
            padding: 12px;
            background: rgba(255, 255, 255, 0.05);
            border-radius: 15px;
            margin: 0 auto;
            max-width: 100%;
            overflow-x: auto;
            scrollbar-width: none;
            -ms-overflow-style: none;
            border: 2px solid rgba(52, 152, 219, 0.4);
        }
        
        .input-boxes-container::-webkit-scrollbar {
            display: none;
        }
        
        .input-box-3d {
            flex: 0 0 auto;
            width: 60px;
            height: 70px;
            border: 3px solid #3498db;
            border-radius: 15px;
            background: linear-gradient(145deg, #1a1a2e, #16213e);
            box-shadow: 
                inset 0 3px 6px rgba(255, 255, 255, 0.1),
                inset 0 -3px 6px rgba(0, 0, 0, 0.4),
                0 5px 10px rgba(52, 152, 219, 0.4);
            display: flex;
            align-items: center;
            justify-content: center;
        }

            .btn-3d {
                padding: 18px 35px;
                font-size: 16px;
            }
        
        .input-box-3d.filled {
            border-color: #2ecc71;
            background: linear-gradient(145deg, #1a2e1a, #162e16);
            box-shadow: 
                inset 0 3px 6px rgba(255, 255, 255, 0.1),
                inset 0 -3px 6px rgba(0, 0, 0, 0.4),
                0 5px 10px rgba(46, 204, 113, 0.4);
        }
        
        /* Controls */
        .controls {
            display: flex;
            justify-content: center;
            gap: 25px;
            padding: 20px;
            flex-shrink: 0;
        }
        
        .btn-3d {
            padding: 20px 40px;
            font-size: 18px;
            font-weight: bold;
            border: none;
            border-radius: 18px;
            cursor: pointer;
            transition: all 0.2s ease;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: white;
            box-shadow: 
                0 10px 20px rgba(0, 0, 0, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
        }
        
        .btn-submit {
            background: linear-gradient(145deg, #2ecc71, #27ae60);
        }
        
        .btn-clear {
            background: linear-gradient(145deg, #e74c3c, #c0392b);
        }
        
        .btn-3d:active {
            transform: translateY(6px);
            box-shadow: 
                0 5px 10px rgba(0, 0, 0, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
        }
        
        /* Player bar - COMPACT */
        .player-bar {
            padding: 12px 15px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 10px;
            background: rgba(255,255,255,0.05);
            border-top: 1px solid rgba(255,255,255,0.1);
            flex-shrink: 0;
        }
        
        #player-name-display {
            font-size: 1.1rem;
            font-weight: bold;
            color: #ff9f43;
            text-shadow: 0 2px 4px rgba(0,0,0,0.3);
            max-width: 150px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        
        #sync-status {
            font-size: 1rem;
        }
        
        .share-group {
            display: flex;
            gap: 10px;
        }
        
        .share-group button {
            padding: 10px 15px;
            border: none;
            border-radius: 15px;
            font-size: 0.9rem;
            font-weight: bold;
            color: white;
        }
        
        /* Word history - FIXED SCROLLABLE */
        .word-history-section {
            flex: 0 0 120px;
            min-height: 120px;
            max-height: 120px;
            display: flex;
            flex-direction: column;
            padding: 12px 15px;
            background: rgba(0, 0, 0, 0.2);
            border-radius: 15px;
            margin: 0 10px 10px;
            overflow: hidden;
        }
        
        .word-history-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
            flex-shrink: 0;
        }
        
        .word-history-title {
            color: #dfe6e9;
            font-size: 1rem;
            text-shadow: 0 2px 4px rgba(0,0,0,0.3);
        }
        
        .toggle-history-btn {
            background: rgba(255,255,255,0.1);
            border: none;
            color: #ff9f43;
            width: 30px;
            height: 30px;
            border-radius: 50%;
            font-size: 1.1rem;
            cursor: pointer;
            z-index: 10;
        }
        
        #memory {
            flex: 1;
            overflow-y: auto !important;
            overflow-x: hidden;
            background: rgba(255, 255, 255, 0.05);
            border-radius: 10px;
            padding: 8px;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: thin;
            scrollbar-color: #ff9f43 rgba(255, 255, 255, 0.1);
            max-height: 80px;
            min-height: 80px;
            height: 80px;
            overscroll-behavior: contain;
        }
        
        /* Force scrollbar to always be visible */
        #memory::-webkit-scrollbar {
            width: 8px !important;
            display: block !important;
            visibility: visible !important;
        }
        
        #memory::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 4px;
        }
        
        #memory::-webkit-scrollbar-thumb {
            background: #ff9f43;
            border-radius: 4px;
        }
        
        #memory::-webkit-scrollbar-thumb:hover {
            background: #ff7f00;
        }
        
        /* Ensure word entries are visible */
        .word-entry {
            padding: 8px;
            margin: 4px 0;
            background: rgba(255, 255, 255, 0.08);
            border-radius: 8px;
            font-size: 14px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-shrink: 0;
            min-height: 36px;
        }
        
        /* Footer - MINIMAL */
        .game-footer {
            padding: 12px 15px;
            text-align: center;
            background: rgba(0,0,0,0.3);
            border-top: 1px solid rgba(255,255,255,0.1);
            flex-shrink: 0;
            display: flex;
            justify-content: center;
            gap: 20px;
        }
        
        .game-footer a {
            color: #ff9f43;
            text-decoration: none;
            font-size: 0.9rem;
            font-weight: bold;
        }
        
        /* Hidden class */
        .hidden {
            display: none !important;
        }
        
        
        /* Landscape orientation */
        @media (max-height: 600px) and (orientation: landscape) {
            .top-bar {
                min-height: 40px;
                padding: 5px 12px;
            }
            .progress-section {
                padding: 5px 12px;
            }
            .progress-3d {
                height: 12px;
            }
            .single-card {
                min-height: 160px;
                max-height: 180px;
                padding: 12px;
            }
            .tile-3d {
                width: 45px;
                height: 55px;
                font-size: 22px;
            }
            .word-history-section {
                flex: 0 0 80px;
                min-height: 80px;
                max-height: 80px;
            }
            #memory {
                max-height: 40px;
                min-height: 40px;
                height: 40px;
            }
        }
        
        /* Touch scrolling improvements */
        @media (hover: none) and (pointer: coarse) {
            #memory {
                padding-right: 4px;
            }
        }

/* =====================
   TILES - CLEAN SQUARE TILES
===================== */
.tile {
    width: 48px;
    height: 48px;
    background: linear-gradient(145deg, #ffffff, #ffbe63);
    border-radius: 10px;

    box-shadow:
        0 4px 0 #b5b5b5,
        0 8px 15px rgba(0,0,0,0.35);

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 1.2rem;
    font-weight: 800;
    color: #111;

    cursor: pointer;
    user-select: none;

    transform-style: preserve-3d;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.tile small {
    position: absolute;
    bottom: 4px;
    right: 6px;
    font-size: 0.55rem;
    opacity: 0.6;
}

/* Hover lift */
.tile:hover {
    transform: translateY(-2px);
}

/* Pressed effect */
.tile:active {
    transform: translateY(4px);
    box-shadow:
        0 1px 0 #b5b5b5,
        0 4px 8px rgba(0,0,0,0.25);
}

/* =====================
   LETTER BOXES
===================== */
.letter-boxes {
  display: flex;
  justify-content: center;
  margin: 16px 0;

}

.box {
  /* Layout & Size */
  width: 56px;
  height: 56px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 4px;
  perspective: 600px; /* Keeps your 3D effect capability */

  /* Look & Feel */
  background: rgba(250, 146, 11, 0.35);
  border: 2px dashed rgba(255, 255, 255, 0.6);
  border-radius: 10px;
  
  /* Text Styling */
  font-weight: 800;
  font-size: 18px;
  color: white;
}

/* Tile inside a box */
.box .tile {
  width: 44px;
  height: 44px;
  font-size: 18px;
  padding: 0;
  transform: translateZ(6px);
}

/* =====================
   WORD MEMORY
===================== */
.word-list {
  display: flex;
  flex-wrap: wrap;        /* allows wrapping */
  gap: 8px 12px;          /* row gap | column gap */
  align-content: flex-start;
}

.word-list > div {
  background: rgb(255, 254, 254);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;   /* keeps word on one line */
}

/* =====================
   MODAL
===================== */
#modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  top: 0;
  padding: 20px;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000 !important; /* One higher than the menu overlay */
}

#modal button {
    margin-top: 20px; /* Pushes the button down away from the score */
    padding: 12px 24px;
    cursor: pointer;
}

.modal-card {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  padding: 30px;
  border-radius: 16px;
  max-width: 450px;
  width: 100%;
  text-align: center;
  box-shadow: 0 25px 50px rgba(0,0,0,0.6);
  border: 2px solid rgba(255,255,255,0.2);
  max-height: 80vh;
  overflow-y: auto;
}

/* =====================
   OTHERS
===================== */
.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-bottom: 20px;
}

.player-name {
    text-align: center;
    font-weight: 700;
    color: #2b2b2b;
    font-size: 18px;
    margin: 0; /* Keeps it tight for space management */
}

.name-input {
  width: 100%;
  padding: 10px 10px;
  margin: 8px 0;
  border-radius: 14px;
  border: none;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
  margin-bottom: 0 !important; /* Remove bottom margin */
}

.name-input::placeholder {
  color: rgba(0,0,0,0.5);
}

.player-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
    flex-wrap: nowrap; /* Prevents the cloud from jumping to a new line */
}

.share-btn {
  background: #25d366;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.share-btn:hover {
  opacity: 0.9;
}

.share-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.share-group button {
  border: none;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.share-group button:nth-child(1) { background:#25D366; color:#fff; } /* WhatsApp */
.share-group button:nth-child(2) { background:#1877F2; color:#fff; } /* Facebook */
.share-group button:nth-child(3) { background:#555; color:#fff; }    /* Email */
.share-group button:nth-child(4) { background:#E1306C; color:#fff; } /* Instagram */

/* =========================
   TABLET & DESKTOP (≥ 768px) — MERGED VERSION
========================= */
@media (min-width: 768px) {
  .cards {
    display: flex;
    flex-wrap: nowrap;
    gap: 16px;
  }

  #card1,
  #card2 {
    width: 50%;
    grid-template-columns: repeat(3, 1fr);
  }

  .tile {
    width: 72px;
    height: 72px;
    font-size: 18px;
  }
}

/* Styling for the new audio button location */
.audio-toggle {
    background: var(--primary);
    border: none;
    border-radius: 50%; /* Makes it a circle */
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Ensure the player bar stays centered and aligned */
.player-bar {
    display: flex;
    justify-content: center;
    align-items: center; /* Aligns icon vertically with the name */
    gap: 15px;
    margin: 0px 0;
    flex-wrap: wrap;
}

/* Logo styling above top bar */
.game-logo-container {
    display: flex;
    justify-content: center;
    padding-bottom: 0px;
}

.game-mini-logo {
    height: 50px; /* Adjust height as needed */
    width: auto;
}

/* Footer Menu Styling */
.game-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(7, 5, 29, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: space-around;
    padding: 12px 0;
    z-index: 100;
}

.game-footer a {
    color: white;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: color 0.3s;
}

.game-footer a:hover {
    color: var(--orange-bg);
}

#sync-status {
    font-size: 1.2rem;
    transition: opacity 0.3s;
    /* Remove large margins */
    margin: 0; 
    display: flex;
    align-items: center;
}

.sync-active {
    animation: spin 1s linear infinite;
    opacity: 1;
    color: #4a2cff; /* Optional: Makes it turn blue when working */
}

.sync-idle {
    opacity: 0.3;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}
/* =====================
   LEADERBOARD
===================== */
.leaderboard-container {
    width: 100% !important;
    max-height: 140px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 8px 12px;
    margin: 5px 0 15px 0;
    box-sizing: border-box;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

#leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    width: 100%;
}

.leaderboard-name {
    flex: 1;
    font-size: 0.75rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
    margin-right: 15px;
}

.leaderboard-score {
    font-size: 0.85rem;
    font-weight: 700;
    color: #ffd700;
    white-space: nowrap;
}

#splash img {
    max-width: 150px;  /* Adjust this number (e.g., 100px for even smaller) */
    height: auto;      /* Keeps the image from looking squished */
    margin-bottom: 5px; /* Reduces space below the image */
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Desktop View (Side by Side) */
#game-container {
    display: flex;
    justify-content: center;
    gap: 20px;
}

/* Mobile View (The "Merge" Trick) */
@media (max-width: 600px) {
    #game-container {
        display: flex;
        flex-direction: column; /* Stack them vertically */
        align-items: center;
        gap: 0px; /* REMOVE the gap so they touch */
    }

    .card {
        width: 90%;
        max-width: 350px;
        margin-bottom: 0px; /* Remove bottom spacing */
        border-radius: 0px; /* Optional: square the corners where they meet */
    }

    /* Round only the TOP of the first card */
    #card1 {
        border-bottom: none;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        padding-bottom: 5px;
    }

    /* Round only the BOTTOM of the second card */
    #card2 {
        border-top: none;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
        padding-top: 5px;
    }
}

/* Container for the progress bar to give it spacing */
.progress-container {
    width: 95%;
    margin: 15px auto;
    background: #1a1a1a; /* Darker background for better contrast */
    height: 26px; /* Slightly taller for better text visibility */
    border-radius: 13px;
    border: 2px solid #444;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

/* The actual moving bar */
#progress-bar {
    width: 0%;
    height: 100%;
    background: #ff4757;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* High-visibility text inside the bar */
#progress-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff !important; /* Forces white text */
    font-weight: 900;
    font-size: 0.9rem;
    /* This shadow is the secret to making text clear over any color */
    text-shadow: 2px 2px 4px #000000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    letter-spacing: 1.5px;
    pointer-events: none; /* Allows clicks to pass through to tiles below if needed */
}

/* Ensure the top bar items are spaced out */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    padding: 5px;
}

/* =====================
   ANIMATIONS
===================== */
@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-8px); }
  100% { transform: translateX(0); }
}

@keyframes flash-red {
  0% { background-color: #ff4757; }
  50% { background-color: #ff0000; box-shadow: 0 0 15px #ff0000; }
  100% { background-color: #ff4757; }
}

.shake-anim {
  animation: shake 0.3s ease-in-out;
}

.flash-anim {
  animation: flash-red 0.5s infinite;
}

.button-group {
    display: flex;
    gap: 10px;
    width: 100%;
    margin-top: 1px;
}

.button-group button {
    flex: 1;
    padding: 14px 5px;
    font-size: 14px;
    white-space: nowrap;
    cursor: pointer;
}

/* Optional: Make the MUST READ button a different color to stand out */
.how-to-btn {
    background-color: #ff4757 !important;
}

/* Color for duplicate words */
.duplicate-word {
    background-color: #ffa502 !important; /* Warning Orange */
    border-color: #ff7b00 !important;
    transition: background-color 0.3s ease;
}

/* The Shake Animation (Ensure this is in your file) */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-8px); }
}

.shake-anim { 
    animation: shake 0.3s ease-in-out; 
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.stats-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.eff-stat {
    font-size: 0.75rem;
    color: #ff9f43; /* Orange/Gold color for efficiency */
    font-weight: bold;
    background: rgba(255, 159, 67, 0.1);
    padding: 2px 6px;
    border-radius: 5px;
}

.score-stat {
    font-weight: 800;
    color: #2b2b2b;
}

@media (max-width: 600px) {
    #game .top-bar {
        padding-top: 5px; /* Adds space so the timer drops below the button */
    }
    
    #menu-trigger {
        z-index: 100; /* Ensures it stays reachable but doesn't overlap text */
    }
}

/* ===== MOBILE INPUT BOX FIX - ALL 8 BOXES FIT ===== */
@media (max-width: 768px) {
    /* Make the card adjust height automatically */
    .single-card {
        max-height: none !important; /* Remove fixed max-height */
        min-height: auto !important;
        height: auto !important;
        padding: 15px 10px !important;
        overflow-y: visible !important; /* Remove scrollbar */
    }
    
    /* Make rows wrap properly */
    .card-row {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 18px !important;
        margin-bottom: 8px !important;
        width: 100% !important;
    }
    
    /* Adjust tile size for 10 letters */
    .tile-3d {
        width: 55px !important;
        height: 65px !important;
        font-size: 24px !important;
    }
    
    /* Even smaller for very small screens */
    @media (max-width: 480px) {
        .tile-3d {
            width: 48px !important;
            height: 58px !important;
            font-size: 22px !important;
        }
        
        .card-row {
            gap: 5px !important;
        }
    }
}

@media (max-width: 768px) {
    .input-section {
        padding: 10px 5px !important;
        margin: 0 5px !important;
        width: calc(100% - 10px) !important;
        box-sizing: border-box !important;
    }
    
    /* Make container use full width */
    .input-boxes-container {
        display: flex !important;
        justify-content: space-between !important;
        gap: 5px !important;
        padding: 8px 5px !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        overflow-x: visible !important;
    }
    
    /* Make boxes flexible and responsive */
    .input-box-3d {
        width: 100% !important; /* Take available space */
        max-width: 70px; /* Don't get too big */
        height: 55px !important; /* Fixed height for consistency */
        flex: 1 1 0 !important; /* Equal distribution */
        min-width: 0 !important; /* Allow shrinking */
        margin: 0 !important;
    }
    
    /* Even smaller screens */
    @media (max-width: 480px) {
        .input-boxes-container {
            gap: 3px !important;
            padding: 6px 3px !important;
        }
        
        .input-box-3d {
            height: 48px !important;
            border-width: 1.5px !important;
            border-radius: 8px !important;
        }
    }
}

/* =========================
   MOBILE (< 768px) - Optimized for Space
========================= */
@media (max-width: 767px) {
  .cards {
    display: flex;
    flex-direction: column; 
    align-items: center;
    gap: 0px; /* Removes space between card 1 and 2 */
  }

  .card {
    width: 95%;
    max-width: 380px;
    padding: 10px;
    min-height: auto; /* Important: removes the 200px height */
    
    /* We use Flexbox here to center the 8 letters nicely */
    display: flex;
    flex-wrap: wrap;
    justify-content: center; 
    gap: 8px;
  }

  /* Fusion effect for the two cards */
  #card1 {
    border-bottom: none;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }
  #card2 {
    display: flex !important; /* Ensures card 2 isn't hidden */
    border-top: none;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
  }

  .tile {
    width: 55px;  /* Smaller size to fit 8 letters comfortably */
    height: 55px;
    font-size: 16px;
    border-radius: 8px;
  }

  .word-list {
    max-height: 100px; /* Keeps the memory section from pushing everything down */
    overflow-y: auto;
  }
}

/* Add this after your existing word-entry styles */
.word-entry.penalty {
    animation: shake 0.3s ease-in-out;
    background: linear-gradient(145deg, #e74c3c, #c0392b) !important;
    color: white !important;
    border-left: 4px solid #ffd700;
}

.word-entry.penalty span:last-child {
    color: #ffd700 !important;
    font-weight: 900;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Success animation */
.word-entry.success {
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: linear-gradient(145deg, #2ecc71, #27ae60) !important;
    color: white !important;
}

@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Make tiles inside input boxes smaller */
.input-box-3d .tile-3d {
    width: 80px !important;
    height: 80px !important;
    font-size: 20px !important;
    background: linear-gradient(145deg, #3498db, #2980b9) !important;
    box-shadow: 0 4px 0 #1e4b6e, 0 4px 8px rgba(0,0,0,0.3) !important;
}

/* Even smaller on mobile */
@media (max-width: 768px) {
    .input-box-3d .tile-3d {
        width: 40px !important;
        height: 40px !important;
        font-size: 16px !important;
    }
    
    .input-box-3d .tile-points {
        width: 5px !important;
        height: 5px !important;
        font-size: 5px !important;
        bottom: 2px !important;
        right: 2px !important;
    }
}

@media (max-width: 480px) {
    .input-box-3d .tile-3d {
        width: 30px !important;
        height: 30px !important;
        font-size: 14px !important;
    }
    
    .input-box-3d .tile-points {
        width: 14px !important;
        height: 14px !important;
        font-size: 8px !important;
    }
}