@import url("https://fonts.googleapis.com/css2?family=Patrick+Hand&display=swap");

:root {
  --blue-theme-color: #87ceeb;
  --blue-border-color: #4682b4;
  --yellow-theme-color: #ffec99;
  --yellow-border-color: #e6b800;
  --bg-color: #f0f8ff;
  --text-color: #333;

  --cell-size: 35px;
}

body {
  font-family: "Patrick Hand", cursive, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  padding: 20px;

  overflow-x: hidden;
  width: 100%;
  box-sizing: border-box;
}

.main-title {
  font-size: 3rem;
  margin-bottom: 30px;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-align: center;
  line-height: 1.1;
}

.controls-container {
  background-color: white;
  padding: 15px 30px;
  border-radius: 15px;
  border: 3px solid var(--blue-border-color);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  align-items: center;
  margin-bottom: 30px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  box-sizing: border-box;
  transition: opacity 0.5s ease, transform 0.5s ease, max-height 0.5s ease;
  opacity: 1;
  transform: scale(1) translateY(0);
  max-height: 500px;
  overflow: hidden;
  width: 100%;
  max-width: 800px;
}

.controls-container.hidden-controls,
#info-giver.hidden-controls {
  opacity: 0;
  transform: scale(0.95) translateY(-20px);
  pointer-events: none;
  max-height: 0;
  margin: 0;
  padding: 0;
  border: none;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.input-group label {
  font-weight: bold;
  font-size: 1.1rem;
  color: var(--blue-border-color);
}

select {
  cursor: pointer;
}

select,
input {
  font-family: "Patrick Hand", cursive, sans-serif;
  font-size: 1em;
  padding: 8px;
  border: 2px solid #ccc;
  border-radius: 8px;
  background-color: #fafafa;
}

.vanish {
  opacity: 0;
  transform: scale(0);
  max-height: 0;
  max-width: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
  transition: all 0.5s ease-out;
}

.input-invalid {
  border-color: #ff4444 !important;
  background-color: #fff0f0 !important;
  animation: shake 0.3s;
}

.error-msg {
  color: #ff4444;
  font-size: 0.9rem;
  font-weight: bold;
  min-height: 1.2rem;
  margin-top: 5px;
  text-align: center;
}

#coord-error {
  display: none;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25%,
  75% {
    transform: translateX(-5px);
  }
  50% {
    transform: translateX(5px);
  }
}

input {
  width: 60px;
  text-align: center;
  text-transform: uppercase;
}

#place-ship-btn {
  font-family: "Patrick Hand", cursive, sans-serif;
  font-size: 1em;
  font-weight: bold;
  color: white;
  background-color: var(--blue-border-color);
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 20px;
  transition: background-color 0.2s, transform 0.1s;
}

#place-ship-btn:hover {
  background-color: #36648b;
  transform: scale(1.05);
}

#place-ship-btn:active {
  transform: scale(0.95);
}

.game-container {
  display: flex;
  gap: 50px;
  margin-bottom: 40px;
  justify-content: center;
}

.board-section {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.board-title {
  padding: 10px 30px;
  border-radius: 10px 10px 0 0;
  margin-bottom: 0;
  width: fit-content;
  border: 2px solid transparent;
  font-size: 1.5rem;
}

.blue-theme .board-title {
  background-color: var(--blue-theme-color);
  border-color: var(--blue-border-color);
}
.blue-theme .grid-container {
  border: 3px solid var(--blue-border-color);
}
.blue-theme .label-cell {
  background-color: var(--blue-theme-color);
}
.yellow-theme .board-title {
  background-color: var(--yellow-theme-color);
  border-color: var(--yellow-border-color);
}
.yellow-theme .grid-container {
  border: 3px solid var(--yellow-border-color);
}
.yellow-theme .label-cell {
  background-color: var(--yellow-theme-color);
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(11, var(--cell-size));
  grid-template-rows: repeat(11, var(--cell-size));
  background-color: white;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border: 1px solid #ccc;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: calc(var(--cell-size) * 0.5);
}

.label-cell {
  font-weight: bold;
}
.empty-cell {
  border: none;
  background-color: transparent;
}
.game-cell {
  cursor: pointer;
  background-color: white;
}
.game-cell:hover {
  background-color: #f0f0f0;
}
.ship-cell {
  background-color: #f0f0f0;
}

.legend {
  display: flex;
  gap: 40px;
  font-size: 1.2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.legend-marker {
  width: 30px;
  height: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.water-marker {
  background-color: #4169e1;
  border-radius: 50%;
  width: 25px;
  height: 25px;
}
.hit-marker {
  color: red;
  font-weight: bold;
  font-size: 2rem;
}
.boats-marker {
  font-weight: bold;
  letter-spacing: 5px;
  width: auto;
}
.miss-marker {
  background-color: #d3d3d3;
  border-radius: 50%;
  width: 25px;
  height: 25px;
}

#start-btn {
  font-family: "Patrick Hand", cursive, sans-serif;
  font-size: 1.3rem;
  font-weight: bold;
  color: white;
  background-color: #4caf50;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 20px;
  margin-left: 10px;
  transition: all 0.2s;
}

#start-btn:hover:not(:disabled) {
  background-color: #45a049;
  transform: scale(1.05);
}
#start-btn:active:not(:disabled) {
  transform: scale(0.95);
}
#start-btn:disabled {
  background-color: #ccc;
  cursor: not-allowed;
  opacity: 0.7;
  transform: none;
}

@media (max-width: 900px) {
  .game-container {
    flex-direction: column;
    gap: 40px;
  }
}

@media (max-width: 480px) {
  :root {
    --cell-size: 28px;
  }

  .controls-container {
    padding: 15px;
    flex-direction: column;
    width: 100%;
  }

  .main-title {
    font-size: 2.2rem;
  }

  #place-ship-btn,
  #start-btn {
    width: 100%;
    margin-left: 0;
  }
}

@media (max-width: 350px) {
  :root {
    --cell-size: 25px;
  }
}
