/* Coaster Kingdom — same storybook-heraldic system as the rest of
   George's website: parchment, ink, banner red, royal blue, gold. */

:root {
  --parchment: #fbf3df;
  --ink: #3b2e1e;
  --banner-red: #e2574c;
  --royal-blue: #3e6fb0;
  --meadow: #7dbb57;
  --gold: #f2b63c;
  --display: "Grandstander", "Comic Sans MS", cursive;
  --body: "Nunito", "Avenir Next", "Trebuchet MS", sans-serif;
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: var(--body);
  color: var(--ink);
  background: #9fd8ef;
}

#game {
  position: fixed;
  inset: 0;
  touch-action: none;
}
#game canvas {
  display: block;
}

/* ---- badges (gold pouch, guest count) ---- */

#gold-badge,
#guest-badge {
  position: fixed;
  top: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--parchment);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 8px 18px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 22px;
  box-shadow: 0 4px 0 rgb(0 0 0 / 15%);
  z-index: 5;
  pointer-events: none;
}
#gold-badge {
  left: 14px;
}
#guest-badge {
  left: 148px;
  font-size: 18px;
  padding-top: 10px;
}
#gold-badge.pulse {
  animation: pulse 0.35s ease-out;
}
@keyframes pulse {
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* ---- camera buttons ---- */

#cam-controls {
  position: fixed;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
  z-index: 5;
}
#cam-controls button {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: 3px solid var(--ink);
  background: var(--parchment);
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 0 rgb(0 0 0 / 15%);
}
#cam-controls button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgb(0 0 0 / 15%);
}
#cam-controls button:focus-visible {
  outline: 3px solid var(--gold);
}

/* ---- toolbar ---- */

#toolbar {
  position: fixed;
  bottom: 12px;
  left: 50%;
  translate: -50% 0;
  display: flex;
  gap: 8px;
  background: var(--parchment);
  border: 4px solid var(--ink);
  border-radius: 18px;
  padding: 8px;
  box-shadow: 0 6px 0 rgb(0 0 0 / 18%);
  z-index: 5;
  max-width: 96vw;
  overflow-x: auto;
}
.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 68px;
  border: 3px solid transparent;
  border-radius: 12px;
  background: transparent;
  padding: 6px 6px 4px;
  cursor: pointer;
  font-family: var(--body);
}
.tool:hover {
  background: rgb(242 182 60 / 25%);
}
.tool.active {
  border-color: var(--ink);
  background: var(--gold);
}
.tool:focus-visible {
  outline: 3px solid var(--gold);
}
.tool-emoji {
  font-size: 26px;
  line-height: 1.1;
}
.tool-label {
  font-weight: 800;
  font-size: 12px;
  color: var(--ink);
}
.tool-cost {
  font-weight: 800;
  font-size: 11px;
  color: #8a6238;
}

/* ---- coaster builder bar ---- */

#coaster-bar {
  position: fixed;
  bottom: 118px;
  left: 50%;
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--royal-blue);
  color: var(--parchment);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 10px 16px;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 4px 0 rgb(0 0 0 / 18%);
  z-index: 6;
  max-width: 94vw;
  text-align: center;
}
#coaster-bar.hidden {
  display: none;
}
.mini-btn {
  font-family: var(--display);
  font-weight: 800;
  font-size: 15px;
  color: var(--parchment);
  background: var(--banner-red);
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.mini-btn.secondary {
  background: var(--parchment);
  color: var(--ink);
}
.mini-btn:focus-visible {
  outline: 3px solid var(--gold);
}

/* ---- toast ---- */

#toast {
  position: fixed;
  top: 76px;
  left: 50%;
  translate: -50% 0;
  background: var(--parchment);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 10px 22px;
  font-weight: 800;
  font-size: 17px;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 7;
  pointer-events: none;
  max-width: 92vw;
  text-align: center;
}
#toast.show {
  opacity: 1;
}

/* ---- floating bubbles (emotes and gold) ---- */

#bubbles {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 4;
}
.bubble {
  position: absolute;
  translate: -50% -100%;
  animation: rise 1.6s ease-out forwards;
  font-size: 26px;
}
.bubble.gold-bubble {
  font-family: var(--display);
  font-weight: 800;
  font-size: 20px;
  color: var(--ink);
  background: var(--gold);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 10px;
}
@keyframes rise {
  0% { opacity: 0; transform: translateY(6px); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-60px); }
}

/* ---- overlays ---- */

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 24px;
  background: linear-gradient(#8fd0ec, #bfe6f4 55%, var(--meadow) 55.3%);
  z-index: 10;
  text-align: center;
}
.overlay.hidden {
  display: none;
}

.banner {
  background: var(--royal-blue);
  color: var(--parchment);
  padding: 26px 54px 40px;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%);
  border-left: 6px solid var(--gold);
  border-right: 6px solid var(--gold);
  box-shadow: 0 6px 0 rgb(0 0 0 / 12%);
}
.banner h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(34px, 7vw, 64px);
  line-height: 1.05;
  text-shadow: 0 4px 0 rgb(0 0 0 / 15%);
}

.story {
  font-size: clamp(16px, 2.4vw, 20px);
  font-weight: 600;
  line-height: 1.55;
  background: var(--parchment);
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 16px 26px;
  max-width: 640px;
  box-shadow: 0 4px 0 rgb(0 0 0 / 12%);
}

.sign-btn {
  font-family: var(--display);
  font-weight: 800;
  font-size: 24px;
  color: var(--parchment);
  background: var(--banner-red);
  border: 4px solid var(--ink);
  border-radius: 14px;
  padding: 14px 38px;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--ink);
  transition: transform 0.08s, box-shadow 0.08s;
}
.sign-btn:hover {
  transform: translateY(2px);
  box-shadow: 0 4px 0 var(--ink);
}
.sign-btn:active {
  transform: translateY(6px);
  box-shadow: 0 0 0 var(--ink);
}
.sign-btn:focus-visible {
  outline: 4px solid var(--gold);
  outline-offset: 2px;
}
.sign-btn.secondary {
  background: var(--parchment);
  color: var(--ink);
  font-size: 17px;
  padding: 10px 24px;
}

@media (max-width: 700px) {
  #guest-badge { display: none; }
  .tool { min-width: 58px; }
}

@media (prefers-reduced-motion: reduce) {
  #gold-badge.pulse { animation: none; }
  .bubble { animation-duration: 0.9s; }
}
