/* ============ CATastrophic — circus-poster UI ============ */
:root {
  --ink: #3a2417;
  --cream: #fff3dc;
  --paper: #ffe7b8;
  --red: #e84a3f;
  --teal: #2da8a0;
  --gold: #f5b63f;
  --shadow: rgba(58, 36, 23, .35);
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #241a12;
  font-family: 'Baloo 2', 'Comic Sans MS', cursive;
  color: var(--ink);
}

#game-wrap {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}

canvas#game {
  background: #6db6e8;
  box-shadow: 0 0 0 6px var(--ink), 0 24px 60px rgba(0,0,0,.6);
  border-radius: 10px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  width: auto; height: auto;
  aspect-ratio: 16/9;
  cursor: crosshair;
}

.hidden { display: none !important; }

/* ============ screens ============ */
.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    repeating-linear-gradient(45deg, rgba(232,74,63,.08) 0 40px, rgba(0,0,0,0) 40px 80px),
    radial-gradient(ellipse at 50% 30%, #f8d28a 0%, #e8a85a 55%, #b3683a 100%);
  z-index: 20;
}
.screen.transparent { background: rgba(36, 26, 18, .55); }

.menu-card, .loadout-card, .pass-card, .end-card, .tut-card {
  background: var(--cream);
  border: 5px solid var(--ink);
  border-radius: 22px;
  box-shadow: 10px 12px 0 var(--shadow);
  padding: 34px 46px;
  text-align: center;
  max-width: 860px;
  animation: card-pop .35s cubic-bezier(.34,1.56,.64,1);
}
@keyframes card-pop { from { transform: scale(.85) rotate(-1.5deg); opacity: 0; } }

.game-title {
  font-family: 'Lilita One', 'Comic Sans MS', cursive;
  font-size: 84px;
  line-height: .95;
  letter-spacing: 1px;
  text-transform: none;
  margin-bottom: 4px;
  text-shadow: 4px 4px 0 var(--gold), 7px 7px 0 var(--shadow);
  transform: rotate(-2deg);
}
.t-cat { color: var(--red); }
.t-astro { color: var(--teal); }
.tagline {
  font-weight: 700; font-size: 19px; color: #8a5a33;
  margin-bottom: 26px; letter-spacing: .12em; text-transform: uppercase;
}

.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; margin: 12px 0;
}
.setting-row label { font-weight: 800; font-size: 19px; }

.seg { display: flex; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; background: #fff; }
.seg button {
  font-family: inherit; font-weight: 700; font-size: 16px;
  border: none; background: transparent; color: var(--ink);
  padding: 7px 16px; cursor: pointer;
  border-right: 3px solid var(--ink);
  transition: background .12s;
}
.seg button:last-child { border-right: none; }
.seg button:hover { background: #ffe9c0; }
.seg button.sel { background: var(--gold); }

.big-btn {
  font-family: 'Lilita One', 'Comic Sans MS', cursive;
  font-size: 30px; letter-spacing: .04em;
  color: var(--cream); background: var(--red);
  border: 4px solid var(--ink); border-radius: 16px;
  box-shadow: 0 6px 0 var(--ink);
  padding: 12px 44px; margin-top: 22px;
  cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.big-btn:hover { transform: translateY(-2px) rotate(-1deg); box-shadow: 0 8px 0 var(--ink); }
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.big-btn.alt { background: var(--teal); font-size: 22px; padding: 8px 30px; margin-left: 14px; }

.menu-foot { margin-top: 18px; font-size: 14px; color: #8a5a33; font-weight: 600; }

.howto-btn {
  display: block; margin: 12px auto 0;
  font-family: inherit; font-weight: 800; font-size: 16px;
  color: var(--ink); background: var(--paper);
  border: 3px solid var(--ink); border-radius: 999px;
  padding: 6px 24px; cursor: pointer;
  box-shadow: 0 4px 0 var(--shadow);
  transition: transform .08s, box-shadow .08s;
}
.howto-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--shadow); }
.howto-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--shadow); }

/* ============ how-to-play tutorial ============ */
.tut-card { width: 640px; }
.tut-card h2 {
  font-family: 'Lilita One', cursive; font-size: 40px;
  color: var(--red); text-shadow: 3px 3px 0 var(--gold);
  margin-bottom: 10px;
}
#tut-page {
  min-height: 220px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
#tut-icon { font-size: 60px; line-height: 1; }
#tut-page-title { font-family: 'Lilita One', cursive; font-size: 27px; color: var(--teal); }
#tut-page-body { font-size: 17px; font-weight: 600; color: #6b4a2c; line-height: 1.45; max-width: 500px; }
#tut-page-body b { color: var(--ink); }
#tut-dots { display: flex; gap: 9px; justify-content: center; margin: 6px 0 0; }
.tut-dot {
  width: 15px; height: 15px; border-radius: 50%; padding: 0;
  border: 2.5px solid var(--ink); background: #fff; cursor: pointer;
}
.tut-dot.on { background: var(--gold); }
.tut-nav { display: flex; align-items: center; justify-content: center; gap: 4px; }
.tut-nav .big-btn { font-size: 22px; padding: 8px 30px; }

/* ============ loadout ============ */
.loadout-card { max-width: 1020px; max-height: 92vh; overflow-y: auto; }
.loadout-card h2 {
  font-family: 'Lilita One', cursive; font-size: 40px;
  color: var(--red); text-shadow: 3px 3px 0 var(--gold);
}
.loadout-sub { font-weight: 600; color: #8a5a33; margin: 6px 0 10px; }
#budget-display {
  font-family: 'Lilita One', cursive; font-size: 28px;
  background: var(--ink); color: var(--gold);
  display: inline-block; padding: 4px 26px; border-radius: 999px;
  margin-bottom: 14px;
}

#loadout-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}
.w-card {
  background: #fff; border: 3px solid var(--ink); border-radius: 14px;
  padding: 8px 6px 6px; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.w-card.free { background: #eafbe7; }
.w-card .w-icon { font-size: 34px; line-height: 1; }
.w-card .w-name { font-weight: 800; font-size: 16px; line-height: 1.1; }
.w-card .w-cost { font-size: 13.5px; font-weight: 700; color: #8a5a33; }
.w-card .w-desc { font-size: 13.5px; line-height: 1.15; color: #6b4a2c; font-weight: 700; }
.w-card .w-flavor {
  font-size: 12.5px; line-height: 1.25; color: #8a6a48; font-style: italic;
  min-height: 46px; padding: 0 2px;
}
.w-card .w-stats {
  display: flex; flex-wrap: wrap; gap: 3px; justify-content: center;
  min-height: 20px;
}
.w-card .w-stats span {
  font-size: 11px; font-weight: 800; line-height: 1;
  background: #fdeec9; border: 1.5px solid #d9b269; border-radius: 999px;
  padding: 3px 7px; color: #6b4a2c; white-space: nowrap;
}
.w-qty { display: flex; align-items: center; gap: 7px; margin-top: 3px; }
.w-qty button {
  width: 24px; height: 24px; border-radius: 8px;
  border: 2.5px solid var(--ink); background: var(--gold);
  font-weight: 900; font-size: 15px; cursor: pointer; line-height: 1;
}
.w-qty button:disabled { opacity: .3; cursor: default; }
.w-qty .q { font-weight: 900; font-size: 17px; min-width: 18px; }

/* ============ pass screen ============ */
.pass-cat { font-size: 84px; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(4deg); } }
.pass-card h2 { font-family: 'Lilita One', cursive; font-size: 38px; color: var(--teal); margin: 8px 0; }

/* ============ end screen ============ */
.end-card h2 { font-family: 'Lilita One', cursive; font-size: 52px; color: var(--red); text-shadow: 3px 3px 0 var(--gold); }
#end-sub { font-weight: 700; color: #8a5a33; margin-top: 6px; }

/* ============ HUD ============ */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }

#hud-top {
  position: absolute; top: 14px; left: 0; right: 0;
  display: flex; align-items: center; justify-content: center; gap: 26px;
}
#turn-banner {
  font-family: 'Lilita One', cursive; font-size: 26px;
  background: var(--cream); border: 4px solid var(--ink); border-radius: 999px;
  box-shadow: 0 5px 0 var(--shadow);
  padding: 4px 30px;
  transform: rotate(-1deg);
}
#turn-banner.team-0 #turn-team-name { color: var(--red); }
#turn-banner.team-1 #turn-team-name { color: var(--teal); }

#wind-gauge {
  display: flex; align-items: center; gap: 8px;
  background: var(--cream); border: 4px solid var(--ink); border-radius: 999px;
  padding: 6px 16px; box-shadow: 0 5px 0 var(--shadow);
}
.wind-label { font-weight: 800; font-size: 13px; letter-spacing: .1em; }
#wind-bar {
  position: relative; width: 130px; height: 14px;
  background: #fff; border: 2.5px solid var(--ink); border-radius: 999px; overflow: hidden;
}
#wind-fill {
  position: absolute; top: 0; bottom: 0; left: 50%;
  background: var(--teal); width: 0;
}
.wind-center { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2.5px; background: var(--ink); }
#wind-arrow { font-size: 20px; font-weight: 900; }

#btn-sound, #btn-music {
  pointer-events: auto;
  position: absolute; top: 0;
  font-size: 20px; background: var(--cream);
  border: 3px solid var(--ink); border-radius: 12px;
  width: 44px; height: 44px; cursor: pointer;
  box-shadow: 0 4px 0 var(--shadow);
}
#btn-sound { right: 18px; }
#btn-music { right: 70px; }
#btn-music.off { opacity: .45; filter: grayscale(1); }

#hud-bottom {
  position: absolute; bottom: 12px; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
#weapon-info {
  max-width: 860px;
  background: rgba(255,243,220,.55); border: 3px solid rgba(58,36,23,.55); border-radius: 14px;
  box-shadow: 0 4px 0 rgba(58,36,23,.18);
  padding: 6px 16px 7px;
  text-align: center;
}
#weapon-info:empty { display: none; }
.wi-head { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.wi-icon { font-size: 24px; line-height: 1; }
.wi-name { font-family: 'Lilita One', cursive; font-size: 21px; color: var(--red); }
.wi-stats { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.wi-stats span {
  font-size: 12.5px; font-weight: 800; line-height: 1;
  background: #fdeec9; border: 1.5px solid #d9b269; border-radius: 999px;
  padding: 4px 8px; color: #6b4a2c; white-space: nowrap;
}
.wi-flavor { font-size: 14.5px; font-weight: 600; font-style: italic; color: #6b4a2c; line-height: 1.25; }

#weapon-strip {
  pointer-events: auto;
  display: flex; gap: 6px;
  background: rgba(255,243,220,.92); border: 4px solid var(--ink); border-radius: 16px;
  padding: 6px 10px; box-shadow: 0 5px 0 var(--shadow);
  max-width: 92%; flex-wrap: wrap; justify-content: center;
}
.w-slot {
  position: relative;
  width: 52px; height: 52px;
  border: 3px solid var(--ink); border-radius: 12px;
  background: #fff; cursor: pointer;
  font-size: 26px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s;
}
.w-slot:hover { transform: translateY(-3px); }
.w-slot.active { background: var(--gold); transform: translateY(-4px); box-shadow: 0 4px 0 var(--ink); }
.w-slot.out { opacity: .35; cursor: default; }
.w-slot .ammo {
  position: absolute; bottom: -8px; right: -8px;
  background: var(--ink); color: var(--gold);
  font-size: 13px; font-weight: 800; font-family: 'Baloo 2', sans-serif;
  border-radius: 999px; padding: 0 6px; min-width: 20px; text-align: center;
}
#hud-hint { font-size: 15px; font-weight: 700; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,.6); }

/* ============ toast ============ */
#toast {
  position: absolute; top: 84px; left: 50%; transform: translateX(-50%);
  font-family: 'Lilita One', cursive; font-size: 24px;
  color: var(--cream); background: rgba(58,36,23,.92);
  border-radius: 999px; padding: 6px 28px;
  opacity: 0; pointer-events: none; z-index: 15;
  transition: opacity .25s, transform .25s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(4px); }
