:root {
  --bg: #1a2744;
  --fg: #f5f7fa;
  /* Harbor accents — midway periwinkle / lavender */
  --harbor: #8a88d0;
  --harbor-half: #b6b1e2;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1.5rem 1.5rem 2.5rem;
}
/* Upper portion above login: vertically center the game tiles */
.stage {
  flex: 1 1 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.grid {
  display: grid;
  grid-template-columns: repeat(9, 8.5rem);
  gap: 1.5rem;
  align-items: start;
  justify-content: center;
}
@media (max-width: 1460px) {
  .grid { grid-template-columns: repeat(5, 8.5rem); }
}
@media (max-width: 860px) {
  .grid { grid-template-columns: repeat(4, 8.5rem); }
}
@media (max-width: 720px) {
  body { padding: 1rem 1rem 1.5rem; }
  .grid { grid-template-columns: repeat(2, 8.5rem); gap: 0.3rem 1.25rem; }
  .tile img { width: 6.25rem; height: 6.25rem; }
  .tile span { margin-top: 0; line-height: 1.05; font-size: 0.95rem; }
}
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 8.5rem;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tile:focus-visible {
  outline: 1px solid var(--harbor-half);
  outline-offset: 6px;
}
.tile img {
  width: 7rem;
  height: 7rem;
  object-fit: contain;
  display: block;
  transition: filter 0.15s ease, opacity 0.15s ease;
  pointer-events: none;
}
/* half mix */
.tile:hover img,
.tile:focus-visible img {
  filter: sepia(0.47) saturate(2.3) hue-rotate(217deg) brightness(0.98);
  opacity: 0.92;
}
/* full mix select */
.tile.is-armed img,
.tile:active img {
  filter: sepia(0.57) saturate(2.6) hue-rotate(225deg) brightness(1.02);
  opacity: 1;
}
.tile span {
  margin-top: 0.7rem;
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
  color: var(--fg);
  transition: color 0.15s ease;
  pointer-events: none;
}
.tile:hover span,
.tile:focus-visible span { color: var(--harbor-half); }
.tile.is-armed span,
.tile:active span { color: var(--harbor); }

.gate {
  flex: 0 0 auto;
  width: min(36rem, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field > span {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.8;
}
.field input {
  width: 100%;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--fg);
  border-radius: 0;
  padding: 0.7rem 0.85rem;
  font: inherit;
  outline: none;
}
.field input::placeholder { color: var(--fg); opacity: 0.35; }
.field input:focus {
  outline: 1px solid var(--harbor);
  outline-offset: 2px;
  border-color: var(--harbor-half);
}
body:not(.is-unlocked) .tile {
  opacity: 0.35;
  pointer-events: none;
  cursor: default;
}
.game-page { justify-content: center; gap: 2rem; }
.back {
  appearance: none;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--fg);
  padding: 0.75rem 1.4rem;
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
}
.back:hover { color: var(--harbor); border-color: var(--harbor); }

#leaderboard {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  text-align: center;
  font-weight: 600;
}

.gate-hint {
  margin: 0;
  grid-column: 1 / -1;
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: var(--fg);
  opacity: 0.55;
  white-space: nowrap;
}

/* Phone landscape only: denser icon rows, gate hint visible, fields raised */
@media (orientation: landscape) and (max-height: 520px) {
  body {
    padding: 0.35rem 1rem 0.5rem;
    justify-content: space-between;
    min-height: 100dvh;
  }
  .stage {
    flex: 0 1 auto;
    align-items: flex-start;
    padding-top: 10px;
  }
  .grid {
    grid-template-columns: repeat(5, 8.5rem);
    gap: 20px 1rem;
  }
  .tile img {
    width: 5.25rem;
    height: 5.25rem;
  }
  .tile span {
    margin-top: 0;
    font-size: 0.85rem;
    line-height: 1.05;
  }
  .gate-hint {
    display: block !important;
  }
  .gate {
    margin-top: auto;
    width: min(36rem, 100%);
    padding-top: 1.25rem;
    margin-bottom: 25px; /* was 40; +15px down */ /* was 70; +30px down */ /* was 20px; +50px up */
  }
}
