/* Reset and base styles */
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

body {
  width: 100%;
  min-width: 100%;
  background: linear-gradient(135deg, #0c1445 0%, #1e3c72 50%, #2a5298 100%);
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: #ffffff;
  overflow-x: auto;
}

/* Error handling */
.errorMsg {
  color: #ff4757;
  background: linear-gradient(
    135deg,
    rgba(255, 71, 87, 0.1),
    rgba(255, 71, 87, 0.2)
  );
  border: 1px solid rgba(255, 71, 87, 0.3);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 8px 0;
  font-weight: 500;
  backdrop-filter: blur(10px);
}

.error {
  border: 2px solid #ff4757 !important;
  background-color: rgba(255, 71, 87, 0.1) !important;
  animation: shake 0.3s ease-in-out;
}

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

/* Form styles */
fieldset {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 20px;
  margin: 16px 0;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
}

fieldset legend {
  color: #74b9ff;
  font-weight: 600;
  padding: 0 12px;
}

input[type="text"] {
  width: 100%;
  max-width: 300px;
  border-radius: 8px;
  padding: 12px 16px;
  margin: 8px 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 16px;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

input[type="text"]:focus {
  outline: none;
  border-color: #74b9ff;
  box-shadow: 0 0 20px rgba(116, 185, 255, 0.3);
  background: rgba(255, 255, 255, 0.15);
}

input[type="text"]::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

*:disabled {
  background-color: rgba(108, 117, 125, 0.3) !important;
  color: rgba(255, 255, 255, 0.5) !important;
  cursor: not-allowed;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 32px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Container layouts */
form,
.sunkenShips,
.placeShips {
  backdrop-filter: blur(20px);
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.1) 0%,
    rgba(255, 255, 255, 0.05) 100%
  );
  border-radius: 16px;
  padding: 24px;
  margin: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

form {
  display: flex;
  flex-direction: column;
}

.mainContainer {
  display: flex;
  min-height: calc(100vh - 140px);
}

main {
  flex: 1;
  padding: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.container {
  display: flex;
  justify-content: space-around;
  width: 100%;
  max-width: 1000px;
  gap: 40px;
  margin: 20px 0;
}

/* Board sections */
.board-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.board-label {
  color: #74b9ff;
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  text-shadow: 0 2px 10px rgba(116, 185, 255, 0.3);
}

.board {
  display: grid;
  grid-template-columns: repeat(10, 40px);
  grid-template-rows: repeat(10, 40px);
  gap: 2px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Cell styles */
.cell {
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  font-size: 18px;
}

/* Water cells */
.cell.water {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  opacity: 0.7;
}

/* Enemy cells */
.cell.enemy-cell {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  opacity: 0.8;
}

.cell.enemy-cell:hover:not(.miss):not(.hit) {
  background: linear-gradient(135deg, #ff6b6b 0%, #feca57 100%);
  transform: scale(1.1);
  box-shadow: 0 4px 16px rgba(255, 107, 107, 0.4);
}

/* Ship cells */
.cell.ship {
  border: 2px solid rgba(255, 255, 255, 0.4);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.cell.ship-cruiser {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}
.cell.ship-destroyer {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}
.cell.ship-battleship {
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}
.cell.ship-carrier {
  background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}
.cell.ship-submarine {
  background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

.ship-icon {
  font-size: 20px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Attack markers */
.attack-marker {
  font-size: 24px;
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  animation: attackPulse 0.5s ease-in-out;
}

.miss-marker {
  color: #74b9ff;
}

.hit-marker {
  color: #ff4757;
}

.cell.miss {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  animation: missEffect 0.5s ease-in-out;
}

.cell.hit {
  background: linear-gradient(135deg, #ff4757 0%, #ff3838 100%);
  animation: hitEffect 0.8s ease-in-out;
}

.damage-indicator {
  color: #ff4757;
  font-size: 24px;
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
}

@keyframes attackPulse {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.3);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes missEffect {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes hitEffect {
  0% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.2) rotate(5deg);
  }
  75% {
    transform: scale(1.1) rotate(-5deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

/* Sidebar */
aside {
  width: 400px;
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Status displays */
#title,
#playing {
  font-size: 18px;
  color: #d3dee9;
  text-align: center;
  font-weight: 600;
}

#playing {
  font-size: 24px;
  font-weight: 700;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(
    135deg,
    rgba(116, 185, 255, 0.9) 0%,
    rgba(116, 185, 255, 0.7) 100%
  );
  padding: 20px 32px;
  border-radius: 12px;
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 1000;
}

.player-status {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
}

.status-icon {
  font-size: 24px;
}

/* Ship placement */
.placement-header,
.sunken-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.placement-header h4,
.sunken-header h4 {
  color: #74b9ff;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon {
  font-size: 20px;
}

/* Direction fieldset */
.direction-fieldset {
  margin-bottom: 24px;
}

.direction-legend {
  color: #74b9ff !important;
  font-size: 16px;
  font-weight: 600;
}

.direction-options {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-top: 12px;

  flex-direction: column;
}

.direction-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 0.3s ease;
}

.direction-option:hover {
  background: rgba(116, 185, 255, 0.1);
  border-color: rgba(116, 185, 255, 0.3);
}

.direction-option input[type="radio"] {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.direction-option input[type="radio"]:checked {
  background: #74b9ff;
  border-color: #74b9ff;
  box-shadow: 0 0 10px rgba(116, 185, 255, 0.4);
}

.direction-icon {
  font-size: 18px;
}

/* Ship options */
.ships-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ship-option {
  display: flex;
  align-items: center;
  padding: 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 0.3s ease;
}

.ship-option:hover {
  background: rgba(116, 185, 255, 0.1);
  border-color: rgba(116, 185, 255, 0.3);
  transform: translateX(5px);
}

.ship-option input[type="radio"] {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  margin-right: 16px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}

.ship-option input[type="radio"]:checked {
  background: #74b9ff;
  border-color: #74b9ff;
  box-shadow: 0 0 10px rgba(116, 185, 255, 0.4);
}

.ship-option input[type="radio"]:checked ~ .ship-display {
  border-color: rgba(116, 185, 255, 0.5);
  background: rgba(116, 185, 255, 0.1);
}

.ship-display {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: all 0.3s ease;
}

.ship-main-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.ship-cells {
  display: flex;
  gap: 2px;
}

.ship-cell {
  width: 16px;
  height: 16px;
  background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.ship-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ship-name {
  font-weight: 600;
  color: #74b9ff;
  font-size: 14px;
}

.ship-size {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

/* Sunken ships display */
.sunkenShips {
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
}

.sunken-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sunken-ship {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  background: rgba(255, 71, 87, 0.1);
  border: 1px solid rgba(255, 71, 87, 0.2);
  border-radius: 8px;
  animation: sinkAnimation 0.8s ease-in-out;
}

.sunken-icon {
  font-size: 24px;
  opacity: 0.7;
}

.sunken-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ship-status {
  font-size: 12px;
  color: #ff4757;
  font-weight: 500;
}

@keyframes sinkAnimation {
  0% {
    opacity: 0;
    transform: translateY(-20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Buttons */
button {
  background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
  color: white;
  padding: 12px 24px;
  margin: 8px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 16px rgba(116, 185, 255, 0.3);
}

button:hover {
  background: linear-gradient(135deg, #0984e3 0%, #74b9ff 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(116, 185, 255, 0.4);
}

button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(116, 185, 255, 0.3);
}

.btn-icon {
  font-size: 16px;
}

/* Click animation */
.clicked {
  animation: clickedCell 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes clickedCell {
  0% {
    transform: scale(1) rotate(0deg);
  }
  25% {
    transform: scale(1.2) rotate(90deg);
  }
  50% {
    transform: scale(0.9) rotate(180deg);
  }
  75% {
    transform: scale(1.1) rotate(270deg);
  }
  100% {
    transform: scale(1) rotate(360deg);
  }
}

/* Utility classes */
.hidden {
  display: none !important;
  visibility: hidden !important;
}

/* Bombshell animation */
#bombshell {
  width: 24px;
  height: 24px;
  background: radial-gradient(circle, #ff4757 0%, #ff3838 50%, #c44569 100%);
  border-radius: 50%;
  position: absolute;
  display: none;
  box-shadow: 0 0 20px rgba(255, 71, 87, 0.6);
  z-index: 1000;
}

@keyframes bombshell-animation {
  0% {
    transform: translateX(-400px) translateY(0) scale(0.5);
    opacity: 0.8;
  }
  20% {
    transform: translateX(-320px) translateY(-120px) scale(0.7);
    opacity: 0.9;
  }
  40% {
    transform: translateX(-240px) translateY(-180px) scale(0.9);
    opacity: 1;
  }
  60% {
    transform: translateX(-160px) translateY(-160px) scale(1.1);
    opacity: 1;
  }
  80% {
    transform: translateX(-80px) translateY(-80px) scale(1.2);
    opacity: 1;
  }
  100% {
    transform: translateX(0) translateY(0) scale(1.5);
    opacity: 0;
  }
}

.animate-bombshell {
  animation: bombshell-animation 1s cubic-bezier(0.25, 0.46, 0.45, 0.94)
    forwards;
}

/* Game end effects */
.gameEnd {
  filter: blur(15px) brightness(0.3);
  pointer-events: none;
  transition: all 0.5s ease-in-out;
}

.gameRestart {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10000;
  animation: victoryAppear 1s ease-in-out;
}

.victory-announcement {
  text-align: center;
  padding: 40px;
  background: linear-gradient(
    135deg,
    rgba(116, 185, 255, 0.95) 0%,
    rgba(9, 132, 227, 0.95) 100%
  );
  border-radius: 20px;
  backdrop-filter: blur(20px);
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  max-width: 400px;
}

.victory-icon {
  font-size: 64px;
  margin-bottom: 16px;
  animation: bounce 2s infinite;
}

.victory-title {
  font-size: 32px;
  font-weight: 700;
  color: white;
  margin-bottom: 16px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.victory-text {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 24px;
}

.restart-btn {
  background: linear-gradient(135deg, #00b894 0%, #00a085 100%);
  font-size: 16px;
  padding: 16px 32px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 184, 148, 0.4);
}

.restart-btn:hover {
  background: linear-gradient(135deg, #00a085 0%, #00b894 100%);
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0, 184, 148, 0.5);
}

@keyframes victoryAppear {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3) rotate(-180deg);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
}

@keyframes bounce {
  0%,
  20%,
  53%,
  80%,
  100% {
    transform: translateY(0);
  }
  40%,
  43% {
    transform: translateY(-20px);
  }
  70% {
    transform: translateY(-10px);
  }
  90% {
    transform: translateY(-4px);
  }
}

/* Game states */
.gameStarted {
  pointer-events: none;
  opacity: 0.6;
}

/* Responsive design */
@media (max-width: 1200px) {
  .mainContainer {
    flex-direction: column;
  }

  aside {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
  }

  .container {
    flex-direction: column;
    align-items: center;
    gap: 20px;
  }
}

@media (max-width: 768px) {
  .board {
    grid-template-columns: repeat(10, 32px);
    grid-template-rows: repeat(10, 32px);
    gap: 1px;
  }

  .cell {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  header {
    padding: 16px;
  }

  main {
    padding: 16px;
  }

  .victory-announcement {
    padding: 24px;
    margin: 16px;
  }

  .victory-title {
    font-size: 24px;
  }

  .victory-text {
    font-size: 16px;
  }
}

/* Smooth scrollbar */
.sunkenShips::-webkit-scrollbar {
  width: 6px;
}

.sunkenShips::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.sunkenShips::-webkit-scrollbar-thumb {
  background: rgba(116, 185, 255, 0.5);
  border-radius: 3px;
}

.sunkenShips::-webkit-scrollbar-thumb:hover {
  background: rgba(116, 185, 255, 0.7);
}
