* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #080f1e;
  color: #e8f1ff;
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 1rem;
}

h1 {
  margin-bottom: 0.25rem;
}

.top-actions {
  margin-top: 0.35rem;
  display: flex;
  gap: 0.45rem;
}

.status-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1rem 0;
  padding: 0.75rem;
  border: 1px solid #2f4366;
  border-radius: 8px;
  background: #0f1b32;
}

.legend {
  margin-bottom: 1rem;
}

#objective-text {
  margin-top: 0.45rem;
  color: #ffd98f;
}

.grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.5rem;
}

.tile {
  border: 1px solid #2d4670;
  border-radius: 8px;
  min-height: 60px;
  padding: 0.5rem;
  font-size: 0.85rem;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  text-align: center;
  transition: transform 0.1s ease, background-color 0.2s ease;
}

.tile.hidden {
  background: #03060e;
  color: transparent;
}

.tile.revealed {
  background: #132542;
  color: #bed7ff;
  cursor: pointer;
}

.tile.explored {
  background: #1e3a64;
  color: #e8f1ff;
}

.tile.port {
  background: #385d2f;
  color: #e8ffe0;
  font-weight: bold;
}

.tile.current {
  outline: 2px solid #ffd56a;
}

.tile.revealed:hover {
  transform: translateY(-1px);
}

.controls {
  margin: 1rem 0;
}

button {
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  cursor: pointer;
  background: #2c87ff;
  color: #fff;
}

.log {
  border: 1px solid #2f4366;
  border-radius: 8px;
  padding: 0.75rem;
  background: #0f1b32;
  min-height: 90px;
  line-height: 1.4;
}

.bestiary-subtitle {
  margin: 0.35rem 0 0.75rem;
  color: #a9c6f5;
  font-size: 0.9rem;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(1, 5, 15, 0.62);
  z-index: 25;
}

.drawer-overlay.hidden {
  display: none;
}

.bestiary-drawer {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: min(430px, 95vw);
  background: #0f1b32;
  border-left: 1px solid #2f4366;
  padding: 1rem;
  overflow-y: auto;
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.drawer-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.bestiary-list {
  display: grid;
  gap: 0.45rem;
}

.bestiary-entry {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid #27436f;
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
  background: #122444;
  font-size: 0.88rem;
}

.bestiary-entry em {
  color: #a5c4f2;
  font-style: normal;
}

.bestiary-empty {
  color: #a5c4f2;
  font-size: 0.88rem;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(1, 5, 15, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(440px, calc(100vw - 2rem));
  border: 1px solid #2f4366;
  border-radius: 12px;
  background: #10203c;
  padding: 1rem 1.2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.modal-card h2 {
  margin: 0 0 0.5rem;
}

.modal-card p {
  margin: 0;
  line-height: 1.5;
}

.progress-wrap {
  margin-top: 0.9rem;
}

.progress-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #20355a;
  overflow: hidden;
  border: 1px solid #35568a;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5fb6ff, #2c87ff);
  transition: width 0.15s linear;
}

.progress-text {
  margin-top: 0.45rem;
  color: #bdd7ff;
  font-size: 0.85rem;
}

.modal-actions {
  margin-top: 0.9rem;
  display: flex;
  justify-content: flex-end;
}

.modal-close-btn.hidden {
  display: none;
}

.modal-close-btn {
  background: #3a2f5f;
  border: 1px solid #5f4d93;
}

.game-over-card {
  border-color: #7a2f4a;
  background: #1a1224;
}

#game-over-title {
  font-size: 2rem;
  letter-spacing: 0.08em;
  font-weight: 800;
  color: #ffd3df;
}

.game-over-stats {
  margin-top: 0.9rem;
  padding: 0.65rem;
  border: 1px solid #4e2a3c;
  border-radius: 8px;
  background: #23152f;
}

.game-over-stats p {
  margin: 0.2rem 0;
}

.port-card h3 {
  margin: 0.75rem 0 0.35rem;
  font-size: 1rem;
}

.port-section p {
  margin: 0.25rem 0 0.55rem;
  color: #c7ddff;
}

.port-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#armor-upgrade-btn,
#thickness-upgrade-btn {
  margin-bottom: 0.5rem;
}

.port-card button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.victory-card {
  border-color: #3a7f5c;
  background: #11261e;
}

#victory-title {
  font-size: 1.8rem;
  letter-spacing: 0.06em;
  font-weight: 800;
  color: #d5ffe8;
}
