*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Segoe UI , sans-serif;
}

body{
  background: linear-gradient(to bottom, #f7f5f5, #df9696);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 0;
  margin: 0;
}

.container {
  width: 100%;
  max-width: 700px;
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.game-box {
  background: #fff;
  border-radius: 20px;
  padding: 30px 25px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.icon{
  width: 60px;
  margin-bottom: 15px;
}
h1{
  font-size: 28px;
  color: #c44c69;
}
.subtitle {
  font-size: 14px;
  color: #6e6e6e;
  margin: 10px 0 20px;
}

label{
  display: block;
  margin-bottom: 6px;
  text-align: left;
  font-weight: bold;
  color: #555;
}
input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  margin-bottom: 25px;
  font-size: 14px;
  transition: all 0.3s ease;
}
input:focus{
  outline: none;
  border-color: #c44c69;
  box-shadow: 0 0 10px rgba(196, 76, 105, 0.1);
}

.difficulty-title{
  text-align: left;
  font-weight: bold;
  color: #555;
  margin-bottom: 10px;
}
.difficulty-options{
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.difficulty{
  background: #f1f1f1;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease;
}
.difficulty:hover{
  background: #e0e0e0;
}
.difficulty.active {
  background-color: #c44c69;
  color: white;
}
.difficulty small {
  font-weight: normal;
  font-size: 12px;
}
#start-btn {
  background-color: #eca4b5;
  color: white;
  padding: 14px;
  width: 100%;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease;
  font-size: 16px;
  margin-top: 20px;
}
#start-btn:hover{
  background-color: #c44c69;
  transform: scale(1.05);
}

.leaderboard-menu-btn {
  background-color: #6c757d;
  color: white;
  padding: 12px;
  width: 100%;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease;
  font-size: 16px;
  margin-top: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.leaderboard-menu-btn:hover {
  background-color: #5a6268;
  transform: scale(1.05);
}

/* Game board with different layouts based on difficulty */
.game-board {
  display: grid;
  gap: 16px;
  justify-content: center;
  margin: 25px auto;
  padding: 25px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  backdrop-filter: blur(15px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Easy: 2 rows × 4 columns (8 cards) */
.game-board.easy {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  max-width: 480px;
}

/* Medium: 3 rows × 4 columns (12 cards) */
.game-board.medium {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  max-width: 480px;
}

/* Hard: 4 rows × 4 columns (16 cards) */
.game-board.hard {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  max-width: 480px;
}

.card {
  background-color: #ffffff;
  width: 100px;
  height: 120px;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 24px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  cursor: pointer;
  user-select: none;
  transition: all 0.3s ease;
  position: relative;
  perspective: 1000px;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

.card.flipped {
  background-color: #ffd700;
}

.card.disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.card.matched {
  opacity: 0.8;
  transform: scale(0.95);
  cursor: default;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.4s ease;
  transform-style: preserve-3d;
}

.card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card-back {
  background: linear-gradient(135deg, #c44c69, #eca4b5);
}

.card-front {
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  transform: rotateY(180deg);
}

.hidden {
  display: none;
}

header {
  text-align: center;
  margin-bottom: 20px;
  width: 100%;
}

header h2 {
  margin: 0 0 10px 0;
  color: #333;
  font-size: 24px;
}

.info-bar {
  font-size: 16px;
  color: #444;
  margin-top: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.controls button {
  background-color: #c44c69;
  color: white;
  border: none;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}
.controls button:hover {
  background-color: #a73755;
}

.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

/* Footer Styles */
footer {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  text-align: center;
  padding: 15px;
  margin-top: auto;
  width: 100%;
  color: #555;
  font-size: 14px;
  font-weight: 500;
}

/* Leaderboard Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 0;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    background: linear-gradient(135deg, #c44c69, #eca4b5);
    color: white;
    padding: 20px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
}

.close-modal {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
}

.close-modal:hover {
    transform: scale(1.2);
}

.modal-body {
    padding: 20px;
}

.difficulty-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.tab-btn {
    background: #f1f1f1;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: #e0e0e0;
}

.tab-btn.active {
    background: #c44c69;
    color: white;
}

#leaderboard-content {
    max-height: 300px;
    overflow-y: auto;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin: 8px 0;
    background: #f8f8f8;
    border-radius: 8px;
    border-left: 4px solid #c44c69;
}

.leaderboard-entry:nth-child(1) {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    border-left-color: #ffd700;
}

.leaderboard-entry:nth-child(2) {
    background: linear-gradient(135deg, #c0c0c0, #e0e0e0);
    border-left-color: #c0c0c0;
}

.leaderboard-entry:nth-child(3) {
    background: linear-gradient(135deg, #cd7f32, #daa520);
    border-left-color: #cd7f32;
}

.player-info {
    display: flex;
    flex-direction: column;
}

.player-name {
    font-weight: bold;
    color: #333;
}

.player-date {
    font-size: 12px;
    color: #666;
}

.score-info {
    text-align: right;
}

.score-time {
    font-weight: bold;
    color: #c44c69;
    font-size: 18px;
}

.score-difficulty {
    font-size: 12px;
    color: #666;
    text-transform: capitalize;
}

.empty-leaderboard {
    text-align: center;
    color: #666;
    padding: 40px 20px;
    font-style: italic;
}

/* Win Screen Modal Styles */
.win-modal-content {
    text-align: center;
    max-width: 500px;
    animation: winModalSlideIn 0.5s ease-out;
}

@keyframes winModalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-50px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.win-header {
    margin-bottom: 30px;
}

.trophy-icon {
    font-size: 60px;
    margin-bottom: 15px;
    animation: trophyBounce 1s ease-in-out;
}

@keyframes trophyBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.win-header h2 {
    color: #c44c69;
    margin: 0 0 10px 0;
    font-size: 28px;
    font-weight: 700;
}

.win-subtitle {
    color: #666;
    margin: 0;
    font-size: 16px;
}

.win-stats {
    display: flex;
    justify-content: space-around;
    margin: 30px 0;
    flex-wrap: wrap;
    gap: 20px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    min-width: 120px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
}

.stat-item i {
    font-size: 24px;
    color: #c44c69;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.win-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

.win-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 120px;
    justify-content: center;
}

.win-btn.primary {
    background: linear-gradient(135deg, #c44c69, #a83a5a);
    color: white;
    box-shadow: 0 4px 15px rgba(196, 76, 105, 0.3);
}

.win-btn.primary:hover {
    background: linear-gradient(135deg, #a83a5a, #8a2f4a);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(196, 76, 105, 0.4);
}

.win-btn.secondary {
    background: linear-gradient(135deg, #6c757d, #5a6268);
    color: white;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.win-btn.secondary:hover {
    background: linear-gradient(135deg, #5a6268, #495057);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 117, 125, 0.4);
}

/* Enhanced Responsive Design */

/* Large tablets and small desktops */
@media (max-width: 768px) {
    .container {
        max-width: 95%;
        padding: 15px;
    }
    
    .game-board {
        gap: 14px;
        padding: 20px;
    }
    
    .game-board.easy,
    .game-board.medium,
    .game-board.hard {
        max-width: 420px;
    }
    
    .card {
        width: 90px;
        height: 110px;
    }
}

/* Mobile phones - portrait */
@media (max-width: 600px) {
    body {
        padding: 10px 0;
    }
    
    .container {
        max-width: 100%;
        padding: 10px;
    }
    
    .game-box {
        padding: 20px 15px;
        margin: 10px;
    }
    
    /* Game board mobile adjustments */
    .game-board {
        padding: 15px;
        gap: 10px;
        margin: 15px auto;
    }
    
    .game-board.easy {
        max-width: 340px;
    }
    
    .game-board.medium {
        max-width: 340px;
    }
    
    .game-board.hard {
        max-width: 340px;
    }
    
    .card {
        width: 75px;
        height: 90px;
        border-radius: 8px;
    }
    
    /* Header adjustments */
    header h2 {
        font-size: 20px;
    }
    
    .info-bar {
        font-size: 14px;
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
    }
    
    /* Controls mobile layout */
    .controls {
        flex-direction: column;
        gap: 10px;
        margin-top: 15px;
    }
    
    .controls button {
        width: 100%;
        padding: 12px;
        font-size: 14px;
    }
    
    /* Modal responsive */
    .modal-content {
        margin: 5% auto;
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .difficulty-tabs {
        flex-direction: column;
        gap: 8px;
    }
    
    .tab-btn {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    .leaderboard-entry {
        flex-direction: column;
        text-align: center;
        gap: 8px;
        padding: 15px;
    }
    
    .score-info {
        text-align: center;
    }
    
    /* Win screen mobile */
    .win-actions {
        flex-direction: column;
        gap: 12px;
    }
    
    .win-btn {
        min-width: 100%;
        padding: 15px 20px;
        font-size: 16px;
    }
    
    .win-stats {
        flex-direction: column;
        gap: 15px;
    }
    
    .stat-item {
        min-width: auto;
        width: 100%;
        padding: 20px;
    }
    
    /* Footer mobile */
    footer {
        padding: 12px;
        font-size: 12px;
    }
}

/* Very small phones */
@media (max-width: 400px) {
    .container {
        padding: 5px;
    }
    
    .game-board {
        gap: 8px;
        padding: 12px;
    }
    
    .game-board.easy,
    .game-board.medium,
    .game-board.hard {
        max-width: 300px;
    }
    
    .card {
        width: 65px;
        height: 80px;
        border-radius: 6px;
    }
    
    .game-box {
        margin: 5px;
        padding: 15px 10px;
    }
}