:root {
  --bg-1: #f2f7fb;
  --bg-2: #d8e6f3;
  --ink: #102436;
  --accent: #1c4f8c;
  --board: #f8fbff;
  --line: #5e6e7c;
  --guide: var(--line);
  --shadow: rgba(20, 28, 34, 0.2);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(60% 80% at 10% 10%, #f7fbff 0%, transparent 60%),
    radial-gradient(60% 80% at 90% 10%, #dbe9f6 0%, transparent 55%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
}

.app {
  display: block;
  min-height: 100vh;
}

.app__eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 0.72rem;
  color: rgba(30, 42, 50, 0.6);
}

h1 {
  margin: 6px 0 0;
  font-size: clamp(1.8rem, 2.8vw, 2.8rem);
  line-height: 1.05;
}

.app__status {
  font-weight: 600;
}

.status-row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-weight: 600;
}

.app__timer {
  font-variant-numeric: tabular-nums;
  color: rgba(16, 36, 54, 0.7);
}

.app__actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 0.95rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 20px -12px var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
}

.btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px -10px var(--shadow);
}

.btn--ghost {
  background: transparent;
  border: 2px solid var(--ink);
  color: var(--ink);
}

.board {
  position: relative;
  width: 100%;
  height: 100vh;
  padding: 0;
  border-radius: 0;
  background: var(--board);
  box-shadow: none;
  overflow: hidden;
  user-select: none;
}

.board::before,
.board::after {
  content: "";
  position: absolute;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(28, 79, 140, 0.18), transparent 65%);
  z-index: 0;
}

.board::before {
  top: -140px;
  left: -120px;
}

.board::after {
  bottom: -160px;
  right: -120px;
}

#map {
  width: 100%;
  height: 100%;
  display: block;
  position: relative;
  z-index: 1;
  border-radius: 0;
  background: radial-gradient(circle at 20% 20%, #fff 0%, transparent 50%),
    repeating-linear-gradient(
      140deg,
      rgba(30, 42, 50, 0.04),
      rgba(30, 42, 50, 0.04) 2px,
      transparent 2px,
      transparent 14px
    );
  touch-action: none;
}

.board__overlay {
  position: absolute;
  top: clamp(12px, 2vw, 20px);
  left: clamp(12px, 2vw, 20px);
  right: clamp(12px, 2vw, 20px);
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  z-index: 2;
  pointer-events: none;
}

.overlay-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.overlay-card--actions {
  display: grid;
  gap: 12px;
  align-items: center;
  justify-items: end;
}

.overlay-card--actions .app__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.overlay-card,
.overlay-card .btn {
  pointer-events: auto;
}

.guide-fill {
  fill: #fff;
  stroke: none;
}

.guide-border,
.coastline {
  fill: none;
  stroke: var(--line);
  stroke-width: 0.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.inset rect {
  fill: rgba(248, 251, 255, 0.92);
  stroke: rgba(94, 110, 124, 0.6);
  stroke-width: 1.2;
  stroke-dasharray: 6 4;
}

.inset text {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  fill: rgba(30, 42, 50, 0.55);
}

.guide-borders.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.piece {
  fill: var(--piece-color, #f0c27b);
  stroke: var(--line);
  stroke-width: 0.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  cursor: grab;
  transition: filter 0.2s ease;
  touch-action: none;
}

.piece.dragging {
  cursor: grabbing;
  filter: drop-shadow(0 8px 10px rgba(30, 42, 50, 0.25));
}

.piece.placed {
  cursor: default;
  filter: none;
  opacity: 0.95;
}

.board__message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(9, 34, 62, 0.92);
  color: #fff;
  padding: 16px 22px;
  border-radius: 16px;
  font-weight: 600;
  font-size: 1.05rem;
  z-index: 2;
  animation: pop 0.4s ease;
}

.zoom-controls {
  position: absolute;
  right: clamp(12px, 3vw, 24px);
  bottom: clamp(12px, 3vw, 24px);
  display: grid;
  gap: 8px;
  z-index: 3;
  pointer-events: auto;
}

.zoom-controls .btn {
  width: 64px;
  padding: 8px 0;
  font-size: 0.95rem;
}

.ranking-panel {
  position: absolute;
  right: clamp(12px, 3vw, 24px);
  top: clamp(80px, 8vw, 140px);
  width: min(220px, 40vw);
  padding: 10px 12px 12px;
  border-radius: 14px;
  background: rgba(248, 251, 255, 0.92);
  border: 1px solid rgba(94, 110, 124, 0.2);
  backdrop-filter: blur(6px);
  z-index: 2;
  pointer-events: auto;
}

.ranking-panel h2 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ranking-list {
  list-style: decimal;
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
}

.ranking-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.ranking-empty {
  list-style: none;
  color: rgba(16, 36, 54, 0.55);
}

.rank-modal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(9, 24, 38, 0.45);
  z-index: 4;
}

.rank-modal[hidden] {
  display: none;
}

.rank-modal__card {
  width: min(320px, 90vw);
  background: #fff;
  border-radius: 18px;
  padding: 18px 20px;
  display: grid;
  gap: 12px;
  box-shadow: 0 24px 60px -32px rgba(9, 24, 38, 0.6);
}

.rank-modal__card h2 {
  margin: 0;
  font-size: 1.2rem;
}

.rank-modal__time {
  margin: 0;
  font-weight: 600;
  color: rgba(16, 36, 54, 0.8);
}

.rank-modal__label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(16, 36, 54, 0.6);
}

.rank-modal__input {
  border: 1px solid rgba(16, 36, 54, 0.2);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
}

.rank-modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

@keyframes pop {
  from {
    transform: translate(-50%, -50%) scale(0.96);
    opacity: 0;
  }
  to {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

@media (max-width: 720px) {
  .board__overlay {
    flex-direction: column;
    align-items: flex-start;
  }

  .overlay-card--actions {
    justify-items: start;
  }

  .overlay-card--actions .app__actions {
    justify-content: flex-start;
  }

  .ranking-panel {
    left: clamp(12px, 4vw, 20px);
    right: auto;
    top: auto;
    bottom: clamp(120px, 20vw, 180px);
    width: min(200px, 70vw);
  }
}
