body {
    background: #f2f2f2;
    font-family: 'Segoe UI', Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
}
.container {
    background: url('images/background.jpg') no-repeat center center fixed;
    background-size: cover;
    position: relative;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    margin-top: 40px;
    text-align: center;
    width: 932px;  /* 832px (board) + 2 * 2rem (padding) */
    height: 600px; /* 440px (board) + padding + title + margins */
    transition: transform 0.5s cubic-bezier(.4,2,.6,1);
}



.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: nowrap;
}

.header h1 {
    margin: 0;
    font-size: 2rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#reset-btn {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    background: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}

#reset-btn:hover {
    background: #f0f0f0;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}
.board-wrapper {
    position: relative;
    display: inline-block;
    margin: 20px auto;
    /* Fixed size based on grid: (48px * 15) + (8px * 14) = 832px width, (48px * 8) + (8px * 7) = 440px height */
    width: 832px;
    height: 440px;
}

#game-board {
    display: grid;
    grid-template-columns: repeat(15, 48px);
    grid-template-rows: repeat(8, 48px);
    grid-gap: 8px;
    row-gap: 8px;
    margin: 0;
    position: relative;
    z-index: 1;
    width: 832px;  /* (48px * 15) + (8px * 14) */
    height: 440px; /* (48px * 8) + (8px * 7) */
}

@media (max-width: 600px), (max-height: 600px) {
  html, body {
    width: 100vw;
    min-width: 0;
    margin: 0;
    padding: 0;
  }
  .container {
    width: 100vw;
    min-width: 0;
    height: auto;
    padding: 0;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    display: block;
    box-sizing: border-box;
    overflow-x: auto;
  }
  #game-board {
    display: grid;
    grid-template-columns: repeat(15, 22px);
    grid-template-rows: repeat(8, 22px);
    grid-gap: 3px;
    row-gap: 3px;
    width: 355px; /* (22px * 15) + (3px * 14) */
    height: 197px; /* (22px * 8) + (3px * 7) */
    max-height: 100vh;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    justify-items: center;
  }
  .tile {
    font-size: 1.1rem;
    min-width: 20px;
    min-height: 20px;
    padding: 0;
  }
  .header h1 {
    font-size: 1.1rem;
  }
}






#connection-svg {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 2;
    overflow: visible;
    /* Ensure exact alignment */
    width: 100%;
    height: 100%;
}

.tile {
    width: 48px;
    height: 48px;
    font-size: 2rem;
    background: white;
    border: 2px solid #b6bec9;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border 0.2s;
    user-select: none;
}
.tile.selected {
    background: #ffe066;
    border-color: #ffd700;
}
.tile.removed {
    visibility: hidden;
}
.controls {
    margin-bottom: 12px;
}
#message {
    margin-top: 10px;
    font-weight: bold;
    color: #0b8457;
}

.header-right {
    display: flex;
    gap: 20px;
    align-items: center;
}

.score-display, .timer-display {
    background: transparent;
    padding: 6px 12px;
    font-weight: bold;
    font-size: 1.1rem;
    white-space: nowrap;
    min-width: 100px;
    text-align: left;
    display: flex;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

.score-display .label, .timer-display .label {
    width: 50px;
    display: inline-block;
    text-align: right;
    margin-right: 5px;
}

#score, #timer {
    display: inline-block;
    min-width: 20px;
    text-align: left;
}

.timer-low {
    color: #ff6b6b !important;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9) !important;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}
