/* JUST PRESS RIGHT — retro chrome. */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  min-height: 100svh;
  background: #141414;
  color: #e8e8e8;
  font-family: "Press Start 2P", "Courier New", monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 18px 12px 12px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- masthead ---------- */

#masthead { text-align: center; }

#masthead h1 {
  font-size: 18px;
  color: #ffd700;
  text-shadow: 3px 3px 0 #803000;
  letter-spacing: 2px;
}

#masthead .tagline {
  margin-top: 8px;
  font-size: 8px;
  color: #909090;
  letter-spacing: 1px;
}

/* ---------- HUD ---------- */

#hud {
  width: min(960px, 100%);
  display: flex;
  align-items: center;
  font-size: 9px;
  gap: 8px;
}

#hud > * { flex: 1; }

/* a little wall-shelf of gold trophies, one per award */
#shelf {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  min-height: 16px;
  padding: 0 2px 3px;
  border-bottom: 3px solid #8c5a20;   /* the shelf board */
  transition: transform 0.35s, border-color 0.35s;
}

#shelf .mini {                         /* a tiny trophy: gold cup + base */
  position: relative;
  width: 6px;
  height: 9px;
  background: #ffd700;
  border-radius: 2px 2px 0 0;
  flex: none;
  transition: transform 0.35s;
}
#shelf .mini::after {
  content: "";
  position: absolute;
  left: 1px;
  bottom: -3px;
  width: 4px;
  height: 3px;
  background: #c89010;
}

/* SHELF COLLAPSE: the board buckles and the trophies tumble */
#shelf.collapsed { transform: rotate(2.5deg); border-bottom-color: #c83820; }
#shelf.collapsed .mini { transform: translateY(2px) rotate(14deg); }
#shelf.collapsed .mini:nth-child(3n) { transform: translateY(4px) rotate(-22deg); }
#shelf.collapsed .mini:nth-child(4n+1) { transform: translateY(3px) rotate(30deg); }

#shelf .more { font-size: 7px; color: #ffd700; align-self: center; margin-left: 2px; }

#clock { text-align: center; color: #ffd700; white-space: nowrap; }

#count { text-align: right; white-space: nowrap; }

#toolbar {
  width: min(960px, 100%);
  display: flex;
  justify-content: center;
  gap: 12px;
}

#sndbtn,
#sharebtn {
  font-family: inherit;
  font-size: 8px;
  padding: 7px 14px;
  cursor: pointer;
  letter-spacing: 1px;
  white-space: nowrap;
}

#sndbtn {
  color: #c8c8c8;
  background: #303030;
  border: 2px solid #585858;
}

#sharebtn {
  color: #10103c;
  background: #ffd700;
  border: 2px solid #fff0a0;
}

#sndbtn:active,
#sharebtn:active { transform: translateY(1px); }

/* ---------- stage ---------- */

#stage {
  position: relative;
  width: min(960px, 100%);
}

#game {
  display: block;
  width: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 4px solid #303030;
  background: #58a8f8;
}

/* scanlines */
#stage::after {
  content: "";
  position: absolute;
  inset: 4px;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 3px
  );
}

#hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18%;
  text-align: center;
  font-size: 10px;
  color: #ffffff;
  text-shadow: 2px 2px 0 #00387c;
  animation: blink 1.1s steps(1) infinite;
  pointer-events: none;
}

#hint .tri { border-width: 5px; border-left-width: 8px; }

.gone { display: none !important; }

/* ---------- triangles (retro arrows) ---------- */

.tri {
  display: inline-block;
  width: 0;
  height: 0;
  border: 7px solid transparent;
  vertical-align: middle;
}

.tri.right { border-left: 11px solid currentColor; border-right: 0; }
.tri.left  { border-right: 11px solid currentColor; border-left: 0; }
.tri.up    { border-bottom: 11px solid currentColor; border-top: 0; }
.tri.down  { border-top: 11px solid currentColor; border-bottom: 0; }

/* ---------- touch controls: the upside-down T ---------- */

#touch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

#touch .trow { display: flex; gap: 8px; }

.tbtn {
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #3a3a3a;
  color: #c8c8c8;
  border: 3px solid #585858;
  border-bottom: 6px solid #242424;
  border-radius: 4px;
  cursor: pointer;
  touch-action: none;
}

.tbtn:active {
  transform: translateY(3px);
  border-bottom-width: 3px;
}

.tbtn.red {
  background: #c81818;
  color: #ffffff;
  border-color: #e85858;
  border-bottom-color: #6c0808;
}

/* ---------- footer ---------- */

footer {
  margin-top: auto;
  font-size: 7px;
  color: #707070;
  letter-spacing: 1px;
  text-align: center;
  line-height: 1.8;
}

.gold { color: #ffd700; }

/* ---------- the award overlay (full-screen takeover) ---------- */

#overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #10103c;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
}

#overlay[hidden] { display: none; }

#confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetto {
  position: absolute;
  top: -5%;
  width: 8px;
  height: 8px;
  animation: fall linear forwards;
}

@keyframes fall {
  to { transform: translateY(115vh) rotate(720deg); }
}

#popup {
  position: relative;
  background: #181858;
  border: 4px solid #f8f8f8;
  box-shadow: 0 0 0 5px #ffd700, 8px 12px 0 5px rgba(0, 0, 0, 0.45);
  padding: 26px 26px 24px;
  text-align: center;
  max-width: 560px;
  width: 100%;
  min-width: 0;
}

.slam { animation: slam 0.18s steps(3) both; }

@keyframes slam {
  0%   { transform: scale(1.3); }
  60%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}

#aw-head {
  font-size: 9px;
  color: #ffd700;
  letter-spacing: 2px;
  animation: blink 1.4s steps(1) infinite;
}

#aw-trophy {
  width: 70px;
  height: 70px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  margin: 16px auto 6px;
  display: block;
}

.tier {
  display: inline-block;
  font-size: 8px;
  padding: 5px 12px;
  border: 2px solid currentColor;
  margin-bottom: 14px;
  letter-spacing: 1px;
}

.tier.gold   { color: #ffd700; }
.tier.silver { color: #c8c8d0; }
.tier.bronze { color: #c87832; }

.tier.participation {
  color: #ff4040;
  animation: hue 1.6s linear infinite;
}

@keyframes hue {
  to { filter: hue-rotate(360deg); }
}

#aw-title {
  font-size: 15px;
  color: #ffffff;
  line-height: 1.6;
  margin-bottom: 14px;
}

#aw-flavor {
  font-size: 8px;
  line-height: 1.9;
  color: #c8d8ff;
  max-width: min(440px, 100%);
  margin: 0 auto 16px;
}

#aw-meta {
  font-size: 7px;
  line-height: 1.9;
  color: #8898d8;
  white-space: pre-line;
  margin-bottom: 18px;
}

#okbtn {
  font-family: inherit;
  font-size: 10px;
  color: #ffffff;
  background: #d82800;
  border: 3px solid #f8f8f8;
  border-bottom: 6px solid #801800;
  padding: 12px 30px;
  cursor: pointer;
  letter-spacing: 2px;
}

#okbtn:active {
  transform: translateY(3px);
  border-bottom-width: 3px;
  padding-bottom: 15px; /* +3px to offset the 3px lost from border-bottom, so the box height (and the modal) stays fixed */
}

@keyframes blink {
  0%, 54%  { opacity: 1; }
  55%, 100% { opacity: 0; }
}

/* ---------- the share dialog ---------- */

#share-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(8, 8, 30, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#share-overlay[hidden] { display: none; }

#share-box {
  background: #181858;
  border: 4px solid #f8f8f8;
  box-shadow: 0 0 0 5px #ffd700, 8px 12px 0 5px rgba(0, 0, 0, 0.45);
  padding: 22px;
  max-width: 460px;
  width: 100%;
  text-align: center;
}

#share-head {
  font-size: 10px;
  color: #ffd700;
  letter-spacing: 2px;
  margin-bottom: 12px;
}

#share-blurb {
  font-size: 8px;
  color: #c8d8ff;
  line-height: 1.8;
  margin-bottom: 12px;
}

#share-text {
  width: 100%;
  font-family: inherit;
  font-size: 8px;
  line-height: 1.7;
  color: #ffffff;
  background: #10103c;
  border: 2px solid #4858a8;
  padding: 10px;
  resize: none;
  margin-bottom: 14px;
}

#share-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 14px;
}

.share-act {
  font-family: inherit;
  font-size: 8px;
  color: #ffffff;
  background: #2840a8;
  border: 2px solid #6878d8;
  border-bottom: 4px solid #101848;
  padding: 9px 10px;
  cursor: pointer;
  letter-spacing: 1px;
  flex: 1;
  min-width: 78px;
}

.share-act:active { transform: translateY(2px); border-bottom-width: 2px; padding-bottom: 11px; /* +2px offsets the border loss; keeps box height fixed */ }
.share-act.copied { background: #00a83c; border-color: #40d878; }

#share-close {
  font-family: inherit;
  font-size: 9px;
  color: #ffffff;
  background: #d82800;
  border: 3px solid #f8f8f8;
  border-bottom: 6px solid #801800;
  padding: 10px 26px;
  cursor: pointer;
  letter-spacing: 2px;
}

#share-close:active { transform: translateY(3px); border-bottom-width: 3px; padding-bottom: 13px; /* +3px offsets the border loss; keeps box height fixed */ }

/* ---------- small screens ---------- */

@media (max-width: 520px) {
  body { padding-top: 10px; gap: 8px; }
  #masthead h1 { font-size: 13px; }
  #masthead .tagline { font-size: 6px; }
  #hud { font-size: 7px; }
  #aw-title { font-size: 12px; }
  #popup { padding: 18px 14px 16px; }
}
