/*
  Powder & Chains has its own visual identity, deliberately separate from
  the rye-hub-sites-style-guide palette used by the culture-listing sites.
  See the Technical Documentation appendix for the rationale.
*/

:root {
  --pc-bg: #0b0e14;
  --pc-bg-panel: #151a24;
  --pc-wall: #3a5a9c;
  --pc-wall-edge: #6f9bff;
  --pc-gold: #e8b93f;
  --pc-gold-bright: #ffd863;
  --pc-parchment: #e9dcc0;
  --pc-blood-red: #c23b3b;
  --pc-danger: #ff5c5c;
  --pc-teal: #3fc6b0;
  --pc-purple: #8a5cff;
  --pc-muted: #8a94a8;
  --pc-border: #2a3244;
  font-family: "Courier New", ui-monospace, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--pc-bg);
  color: var(--pc-parchment);
  min-height: 100%;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 12px;
  gap: 10px;
}

#hud {
  width: min(560px, 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--pc-bg-panel);
  border: 2px solid var(--pc-border);
  border-radius: 6px;
  padding: 8px 14px;
  letter-spacing: 1px;
}

#hud > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
}

#hud span:first-child {
  font-size: 0.65rem;
  color: var(--pc-muted);
}

#hud-score, #hud-level {
  color: var(--pc-gold-bright);
  font-size: 1.1rem;
  font-weight: bold;
}

#hud-lives {
  color: var(--pc-danger);
  font-size: 1.1rem;
  letter-spacing: 3px;
}

#stage {
  position: relative;
  /* Cap width by both the viewport's width AND its height (via the
     canvas's fixed aspect ratio) so the stacked layout (HUD + canvas +
     footer) never exceeds a short window's visible height — otherwise
     the instinctive fix is to browser-zoom out, which is what we're
     avoiding here. */
  width: min(560px, 100%, calc((100dvh - 200px) * 560 / 600));
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 560 / 600;
  background: #05070b;
  border: 2px solid var(--pc-border);
  border-radius: 6px;
  image-rendering: pixelated;
}

#reload-meter {
  position: absolute;
  top: 10px;
  right: 10px;
  pointer-events: none;
}

#reload-meter.hidden {
  display: none;
}

.reload-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 4;
}

.reload-arc {
  fill: none;
  stroke: var(--pc-gold-bright);
  stroke-width: 4;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 20px 20px;
  transition: stroke-dashoffset 0.08s linear;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 11, 0.85);
  border-radius: 6px;
}

.overlay.hidden {
  display: none;
}

.overlay-panel {
  text-align: center;
  padding: 24px;
  max-width: 420px;
}

.title {
  color: var(--pc-gold-bright);
  font-size: 1.8rem;
  letter-spacing: 3px;
  text-shadow: 0 0 12px rgba(232, 185, 63, 0.5);
  margin: 0 0 4px;
}

.subtitle {
  color: var(--pc-teal);
  margin: 0 0 18px;
  letter-spacing: 1px;
}

#overlay-body p {
  color: var(--pc-muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.btn-primary, .btn-secondary {
  display: block;
  width: 100%;
  margin: 10px 0;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 0.95rem;
  letter-spacing: 1px;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid var(--pc-gold);
}

.btn-primary {
  background: var(--pc-gold);
  color: #1a1200;
  font-weight: bold;
}

.btn-primary:hover {
  background: var(--pc-gold-bright);
}

.btn-secondary {
  background: transparent;
  color: var(--pc-gold);
}

.btn-secondary:hover {
  background: rgba(232, 185, 63, 0.1);
}

.controls-hint {
  margin-top: 16px;
  font-size: 0.72rem;
  color: var(--pc-muted);
  line-height: 1.5;
}

#leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  text-align: left;
  max-height: 260px;
  overflow-y: auto;
}

#leaderboard-list li {
  display: flex;
  justify-content: space-between;
  padding: 5px 8px;
  border-bottom: 1px dashed var(--pc-border);
  font-size: 0.85rem;
}

#leaderboard-list li:first-child {
  color: var(--pc-gold-bright);
}

.name-entry {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

.name-entry input {
  flex: 1;
  background: var(--pc-bg);
  border: 2px solid var(--pc-border);
  color: var(--pc-parchment);
  padding: 8px;
  font-family: inherit;
  border-radius: 4px;
  text-transform: uppercase;
}

#touch-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(560px, 100%);
  gap: 20px;
}

#touch-controls.hidden {
  display: none;
}

.dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.dpad-mid {
  display: flex;
  gap: 4px;
}

.dpad-btn {
  width: 46px;
  height: 46px;
  border-radius: 6px;
  border: 2px solid var(--pc-border);
  background: var(--pc-bg-panel);
  color: var(--pc-parchment);
  font-size: 1.1rem;
}

.fire-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--pc-gold);
  background: var(--pc-bg-panel);
  font-size: 1.5rem;
}

#footer {
  color: var(--pc-muted);
  font-size: 0.7rem;
  margin-top: auto;
  padding: 10px;
}

#footer a {
  color: var(--pc-teal);
}

@media (max-width: 480px) {
  .title {
    font-size: 1.4rem;
  }
}
