body {
    margin: 0;
    padding: 0;
    font-family: 'Roboto', sans-serif;
    background: linear-gradient(135deg, #1c1c1c, #383838);
    color: #eee;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

* {
    box-sizing: border-box;
}

header, footer {
    background-color: #2b2b2b;
    padding: 20px;
    width: 100%;
    text-align: center;
    color: #eee;
    border-bottom: 2px solid #444;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

header {
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}

footer {
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    border-top: 2px solid #444;
}

h1 {
    margin: 0;
    font-size: 2.5rem;
    letter-spacing: 2px;
}

main {
    flex: 1;
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    padding: 4px 0;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
    padding: 15px; /* Отступы для игрового контейнера */
}

.control-panel {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    max-width: 65vmin; /* Совпадает с максимальной шириной игрового поля */
    background: linear-gradient(45deg, #ff6b6b, #f09433);
    padding: 10px;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.7);
    margin-bottom: 20px;
    overflow: hidden;
    flex-wrap: nowrap;
    gap: 5px;
}

.info-block {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    color: #fff;
    transition: transform 0.3s, background-color 0.3s;
    flex: 1 1 auto;
    min-width: 0; /* Для предотвращения переполнения */
    font-size: calc(1.2rem + 0.2vw); /* Масштабируемый размер шрифта */
}

.info-block:hover {
    background-color: rgba(0, 0, 0, 0.3);
    transform: scale(1.05);
}

#reset-button {
    cursor: pointer;
    border: none;
    outline: none;
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: calc(1.5rem + 0.3vw);
}

#difficulty-select {
    padding: 5px;
    font-size: calc(0.8rem + 0.2vw);
    border-radius: 5px;
    border: none;
    outline: none;
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    transition: background-color 0.3s, color 0.3s;
}

#difficulty-select:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

#board {
    display: grid;
    gap: 5px;
    width: 65vmin;
    height: 65vmin;
    max-width: 600px;
    max-height: 600px;
    background-color: #333;
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.7);
    grid-template-columns: repeat(var(--cols), 1fr);
    grid-template-rows: repeat(var(--rows), 1fr);
}

.cell {
    background-color: #555;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
    border-radius: 5px;
    font-size: calc(1rem + 0.2vw);
    width: 100%;
    height: 100%;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.cell.revealed {
    background-color: #888;
    cursor: default;
}

.cell.flagged {
    background-color: #e74c3c;
    color: #fff;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.5);
}

.cell.mine {
    background-color: #e74c3c;
    animation: explode 0.5s ease;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.5);
}

.mine-count-1 { color: #2980b9; font-weight: bold; } /* Более яркие цвета и жирный шрифт */
.mine-count-2 { color: #27ae60; font-weight: bold; }
.mine-count-3 { color: #e67e22; font-weight: bold; }
.mine-count-4 { color: #8e44ad; font-weight: bold; }
.mine-count-5 { color: #e74c3c; font-weight: bold; }
.mine-count-6 { color: #16a085; font-weight: bold; }
.mine-count-7 { color: #2c3e50; font-weight: bold; }
.mine-count-8 { color: #bdc3c7; font-weight: bold; }

footer {
    margin-top: 20px;
    font-size: 0.9rem;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.modal-content {
    background: #333;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    color: #eee;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    animation: modalFadeIn 0.3s ease;
}

.modal-content h2 {
    margin-top: 0;
    font-size: 2rem;
}

.modal-content p {
    font-size: 1.5rem;
    margin: 20px 0;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.modal-buttons button {
    padding: 10px 20px;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: #555;
    color: #eee;
    transition: background 0.3s;
}

.modal-buttons button:hover {
    background: #777;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@media (max-width: 600px) {
    #board {
        width: 90vw;
        height: 90vw;
    }

.control-panel {
    max-width: 90vmin;
}

}

#instructions {
  background-color: #333;
  color: #eee;
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  text-align: left;
  margin: 20px auto 30px auto;
  width: 100%;
  max-width: 90vmin;
  font-size: 1.2rem;
  line-height: 1.6;
}

#instructions h2 {
  color: #ffcc00;
  border-bottom: 2px solid #ffcc00;
  padding-bottom: 6px;
  margin-top: 1.4em;
  margin-bottom: 0.8em;
  font-size: 1.8rem;
}

#instructions h3 {
  color: #f5a623;
  margin-top: 1.2em;
  margin-bottom: 0.6em;
  font-size: 1.5rem;
}

#instructions h4 {
  color: #ffdb58;
  margin-top: 1em;
  margin-bottom: 0.5em;
  font-size: 1.3rem;
}

#instructions ul {
  padding-left: 1.4em;
}

#instructions ul li {
  margin-bottom: 8px;
}

#instructions ul li::marker {
  color: #ffcc00;
}

#instructions ol {
  padding-left: 1.4em;
}

#instructions ol li {
  margin-bottom: 8px;
}

#instructions ol li::marker {
  color: #f5a623;
  font-weight: bold;
}

#instructions strong {
  color: #333;
  background-color: #ffcc00;
  padding: 2px 4px;
  border-radius: 4px;
}

#instructions h2,
#instructions h3,
#instructions h4 {
  text-transform: capitalize;
}