/* ==================================== Root and All ==================================== */

:root {
  --red: #85282b;
  --orange: #d64045ff;
  --white-green: #e9fff9ff;
  --light-blue: #9ed8dbff;
  --gray: #b0b0b0;
  --medium-blue: #467599ff;
  --dark-blue: #1d3354ff;
  --black: #151d29;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Montserrat', system-ui, -apple-system, BlinkMacSystemFont,
    'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue',
    sans-serif;
}

html,
body {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ==================================== Header ==================================== */

header {
  font-size: 2rem;
  padding: 20px;
  text-align: center;
  background-color: var(--dark-blue);
  color: var(--white-green);
  letter-spacing: 0.25rem;
  text-shadow: 1px 1px var(--black), 2px 2px 0 var(--red);
  border-bottom: 2px solid var(--medium-blue);
}

/* ==================================== Main ==================================== */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--light-blue);
  padding: 20px;
  gap: 20px;
}

h2,
h3 {
  color: var(--dark-blue);
  margin-bottom: 10px;
}

/* ==================================== Setup Section ==================================== */

.setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  background-color: var(--white-green);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.15);
}

.rotate-btn,
.start-game,
.reset {
  border: 1px solid var(--medium-blue);
  background-color: var(--white-green);
  border-radius: 20px;
  padding: 10px 20px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
  justify-self: center;
}

.rotate-btn:hover,
.start-game:hover,
.reset:hover {
  background-color: var(--orange);
  color: var(--white-green);
}

.rotate-btn:active,
.start-game:active,
.reset:active {
  background-color: var(--red);
  color: var(--white-green);
}

.rotate-btn {
  margin-bottom: 12px;
}

.grayed-out {
  opacity: 0.5;
  pointer-events: none;
}

/* ------------- Setup Layout and Ships Tray ------------- */

.player-grid-setup-section {
  display: flex;
  gap: 16px;
  align-items: baseline;
  justify-items: center;
  width: 100%;
  max-width: 720px;
}

.ships {
  width: 230px;
  min-height: 80px;
  background-color: var(--light-blue);
  border: 1px solid var(--medium-blue);
  border-radius: 8px;
  padding: 8px;
  box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
}

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

/* ==================================== Game Section ==================================== */

.playing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  background-color: var(--white-green);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.15);
}

.hit-message,
.error-messages {
  opacity: 0.75;
}

.board-container {
  display: flex;
  gap: 30px;
  justify-content: center;
  align-items: center;
}

.player-grid,
.pc-grid,
.player-grid-setup {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  width: 400px;
  height: 400px;
  background-color: var(--light-blue);
  gap: 2px;
  padding: 5px;
  border-radius: 8px;
}

.grid-piece,
.ship-piece,
.ship-segment {
  background-color: var(--white-green);
  border: 1px solid var(--medium-blue);
  border-radius: 3px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ship-piece {
  margin-right: 20px;
}
.ship-piece.vertical {
  flex-direction: column;
  margin-right: 0;
}

/* ------------- Modified Pieces and Ship Pieces ------------- */

.grid-piece.hit {
  background-color: var(--red);
}

.grid-piece.miss {
  background-color: var(--gray);
}

.grid-piece.ship,
.ship-segment {
  background-color: var(--dark-blue);
  border: 1px solid var(--medium-blue);
  border-radius: 3px;
}

.grid-piece.empty {
  background-color: var(--white-green);
}

/* Actual ship piece to be placed on board */
.ship-piece {
  display: flex;
  flex-direction: row;
  gap: 3px;
  width: fit-content;
  background-color: transparent;
  border: none;
}

.ship-segment {
  width: 34px;
  height: 34px;
}

/* ==================================== Footer ==================================== */

footer {
  padding: 12px;
  background-color: var(--dark-blue);
  color: var(--white-green);
  font-weight: 500;
}

/* ==================================== Utility ==================================== */

.hidden {
  display: none;
}

.grid-piece.highlight {
  background-color: rgba(70, 117, 153, 0.7) !important;
  border: 2px solid var(--medium-blue) !important;
}
