@import url('../shared/theme.css');

:root {
  --night: var(--game-bg);
  --night-deep: var(--game-surface);
  --cream: var(--game-text);
  --orange: var(--game-warning);
  --mint: var(--game-accent);
  --muted: var(--game-muted);
  --line: var(--game-divider);
}

* {
  box-sizing: border-box;
}

body {
  display: grid;
  min-width: 280px;
  min-height: 100svh;
  margin: 0;
  place-items: stretch center;
  color: var(--cream);
  background:
    radial-gradient(circle at 28% 18%, var(--game-accent-soft), transparent 12rem),
    linear-gradient(145deg, var(--night), var(--night-deep));
  font-family: var(--game-font);
}

button {
  font: inherit;
}

.game {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  width: min(100%, 420px);
  min-height: 100svh;
  padding: 1rem;
}

.topline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 1rem;
}

.topline p {
  margin: 0 0 0.2rem;
  color: var(--mint);
  font-family: var(--game-mono);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

h1 {
  margin: 0;
  font-family: var(--game-font);
  font-size: 1.25rem;
  font-weight: 500;
}

output {
  padding: 0.45rem 0.65rem;
  color: var(--muted);
  background: var(--game-surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--game-radius);
  font-family: var(--game-mono);
  font-size: 0.7rem;
  white-space: nowrap;
}

.status-actions {
  display: flex;
  min-width: 0;
  gap: 0.4rem;
  align-items: center;
  justify-content: flex-end;
}

.assist {
  width: auto;
  min-height: 44px;
  padding: 0.4rem 0.6rem;
  color: var(--mint);
  background: var(--game-surface);
  border: 1px solid var(--line);
  border-radius: var(--game-radius);
  cursor: pointer;
  font-size: 0.66rem;
  font-weight: 750;
}

.assist[aria-pressed='true'] {
  color: var(--game-on-accent);
  background: var(--mint);
}

.orbit-field {
  position: relative;
  display: grid;
  min-height: 190px;
  place-items: center;
}

.orbit-ring {
  position: absolute;
  inset: 0;
  width: 152px;
  height: 152px;
  margin: auto;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.planet {
  width: 68px;
  height: 68px;
  background:
    radial-gradient(circle at 35% 32%, rgba(255, 255, 255, 0.18) 0 5%, transparent 6%),
    radial-gradient(circle at 62% 60%, rgba(0, 0, 0, 0.18) 0 10%, transparent 11%),
    linear-gradient(145deg, #f2ad79, var(--orange));
  border-radius: 50%;
  box-shadow: 0 0 55px rgba(255, 135, 101, 0.23);
}

.target-zone {
  --target-start: 18deg;
  --target-span: 32deg;

  position: absolute;
  inset: 0;
  width: 176px;
  height: 176px;
  margin: auto;
  background: conic-gradient(
    from var(--target-start),
    var(--mint) 0deg var(--target-span),
    transparent var(--target-span) 360deg
  );
  border-radius: 50%;
  filter: drop-shadow(0 0 5px var(--mint));
  mask: radial-gradient(circle, transparent 0 66px, #000 67px 86px, transparent 87px);
  pointer-events: none;
  -webkit-mask: radial-gradient(circle, transparent 0 66px, #000 67px 86px, transparent 87px);
}

.orbit-field[data-assist-state='target'] .target-zone {
  animation: assist-target-pulse 480ms ease-in-out infinite alternate;
}

@keyframes assist-target-pulse {
  from {
    opacity: 0.72;
    filter: drop-shadow(0 0 5px var(--mint));
  }

  to {
    opacity: 1;
    filter: drop-shadow(0 0 14px var(--mint));
  }
}

.satellite {
  position: absolute;
  inset: 0;
  width: 152px;
  height: 152px;
  margin: auto;
  border-radius: 50%;
  transform: rotate(0deg);
  will-change: transform;
}

.satellite span {
  position: absolute;
  top: -7px;
  left: calc(50% - 8px);
  width: 16px;
  height: 16px;
  background: var(--cream);
  border-radius: 50%;
  box-shadow: 0 0 14px rgba(246, 238, 220, 0.82);
}

button {
  width: 100%;
  min-height: 48px;
  color: var(--game-on-accent);
  background: var(--mint);
  border: 0;
  border-radius: var(--game-radius);
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  background: var(--game-accent-strong);
}

.assist:hover {
  background: var(--game-accent-soft);
}

.assist[aria-pressed='true']:hover {
  background: var(--mint);
}

button:focus-visible {
  outline: 3px solid var(--mint);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hint {
  display: grid;
  min-height: 2.1rem;
  margin: 0.65rem 0 0;
  align-content: center;
  color: var(--muted);
  font-size: 0.7rem;
  text-align: center;
  transition:
    color 160ms ease,
    text-shadow 160ms ease;
}

.hint[data-assist-state] {
  color: var(--cream);
  font-weight: 750;
}

.hint[data-assist-state='toggle-on'],
.hint[data-assist-state='target'] {
  color: var(--mint);
}

.hint[data-assist-state='close'] {
  color: var(--orange);
}

.hint[data-assist-state='target'] {
  text-shadow: 0 0 12px var(--mint);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --game-surface: #212529;
    --game-surface-strong: #2c3237;
    --game-accent-strong: #2dd4bf;
    --game-accent-soft: #134e4a;
    --game-on-accent: #10201e;
    --night: #1c1c1d;
    --night-deep: #212529;
    --cream: #e0e0e0;
    --orange: #fbbf24;
    --mint: #5eead4;
    --muted: #9e9e9e;
    --line: #424246;
  }
}

@media (max-width: 340px) {
  .game {
    padding: 0.75rem;
  }

  .topline {
    gap: 0.5rem;
  }

  .orbit-field {
    min-height: 176px;
  }

  .status-actions {
    gap: 0.25rem;
  }

  .assist {
    width: auto;
    min-width: 0;
    padding-inline: 0.35rem;
    font-size: 0.58rem;
  }

  .status-actions output {
    padding-inline: 0.45rem;
    font-size: 0.62rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hint {
    transition: none;
  }

  .orbit-field[data-assist-state='target'] .target-zone {
    animation: none;
    filter: drop-shadow(0 0 10px var(--mint));
  }
}
