#games[hidden],
#games [hidden] {
  display: none !important;
}
#games {
  --cream: #fff6e4;
  position: absolute;
  inset: 0;
  z-index: 1;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) clamp(66px, 11vh, 86px);
  justify-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(15px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom)) max(15px, env(safe-area-inset-left));
  background: linear-gradient(
    180deg,
    #1b2a23ee 0%,
    #29392fa6 17%,
    #3c453119 39%,
    transparent 62%,
    #312c2180 81%,
    #1f2b22ef 100%
  );
  color: var(--cream);
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
}
#chamber.fallback #games[data-game='wind'] {
  background: linear-gradient(180deg, #344538, #938971 45%, #be9870 49%, #785b42 76%, #26342a);
}
#games[data-game='ball'] {
  background:
    linear-gradient(180deg, #19251ee3, #1a271d0a 37%, transparent 64%, #1e281eeb),
    #655641 url('assets/dirigivel.webp') center / cover no-repeat;
}
.game-header,
.game-footer {
  position: relative;
  z-index: 1;
  width: min(100%, 730px);
}
#game-title {
  font:
    500 clamp(2.6rem, 7.3vmin, 4.6rem) / 1.05 'Cormorant Garamond',
    Georgia,
    serif;
  letter-spacing: -0.04em;
  margin: 0.1rem 40px 0.35rem;
  text-shadow: 0 2px 12px #18221b70;
}
#game-title:focus {
  outline: none;
}
#game-goal {
  max-width: 48ch;
  text-wrap: balance;
  margin: 0 auto;
  font-size: clamp(0.95rem, 1.8vmin, 1.1rem);
  line-height: 1.4;
  text-shadow: 0 1px 4px #2c3225;
}
#games button {
  font: inherit;
  touch-action: manipulation;
  cursor: pointer;
}
#game-exit {
  position: absolute;
  top: -5px;
  right: 0;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--cream);
  font: 400 1.7rem/1 Georgia !important;
}
#games :focus-visible {
  outline: 2px solid #f7d799;
  outline-offset: 2px;
}
#game-title:focus-visible {
  outline: none;
}
#arena {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  container-type: size;
  touch-action: none;
}
#arena:focus:not(:focus-visible) {
  outline: none;
}
.game-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-shadow: 0 1px 6px #1d271e;
}
#game-next {
  min-height: 42px;
  border: 1px solid #f3dbb1;
  border-radius: 5px;
  padding: 6px 22px;
  background: #f1dfba;
  color: #273629;
  font-weight: 600 !important;
}
#game-next:hover {
  background: #fff0d1;
}
#games[data-phase='active'] .game-footer {
  pointer-events: none;
}
#games[data-game='ball'][data-phase='active'] {
  cursor: crosshair;
  touch-action: none;
}
.wind-table {
  position: relative;
  width: min(99cqw, 760px);
  height: min(96cqh, 460px);
  touch-action: none;
  cursor: grab;
}
.wind-table:active {
  cursor: grabbing;
}
.wind-lanes,
.gusts {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.gusts {
  width: 100%;
  height: 100%;
}
.wind-lane {
  /* A shallow, burnished saucer resting in the same plane as the candle foot. */
  position: absolute;
  bottom: 5.15%;
  width: clamp(72px, 24%, 150px);
  aspect-ratio: 4.7;
  transform: translateX(-50%);
  border-radius: 50%;
  background:
    radial-gradient(ellipse closest-side, transparent 69%, #6d5133 72%, #ad9063 76%, transparent 81%),
    radial-gradient(
      ellipse closest-side,
      transparent 87%,
      #6a5039 88.5%,
      #e6c992 92%,
      #a3865b 96%,
      #694d34 99%
    ),
    linear-gradient(165deg, #bfa478, #947248 32%, #ae9165 64%, #c5a979 83%, #8e714c);
  box-shadow:
    inset 0 -1px 1px #60472f,
    0 2px 0 #644c34,
    1px 4px 4px -1px #51382268;
}
.wind-lane::before,
.wind-lane::after {
  content: '';
  position: absolute;
  border-radius: 50%;
}
.wind-lane::before {
  inset: 12% 10%;
  background:
    radial-gradient(ellipse closest-side, transparent 86%, #54463060 89%, #d5bb8d7d 93%, transparent 96%),
    repeating-linear-gradient(174deg, transparent 0 3px, #6b583915 4px, transparent 5px),
    linear-gradient(135deg, #766246, #9b845d 52%, #a28c65);
  box-shadow: inset 0 1px 2px #513d2d7a;
}
.wind-lane::after {
  inset: 11% 8%;
  opacity: 0;
  background: radial-gradient(
    ellipse closest-side,
    #99a89450 8%,
    #9ea68e22 65%,
    #dfe8cc 87%,
    transparent 96%
  );
  transition: opacity 180ms ease;
}
.wind-lane.in-draft::after {
  opacity: 1;
}
.wind-wisp,
.wind-wisp::after {
  position: absolute;
  width: 8%;
  height: 26%;
  border: solid #e9f2dcbb;
  border-width: 0 2px 0 0;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-60%, -100%) rotate(-23deg);
}
.wind-wisp::after {
  content: '';
  width: 72%;
  height: 76%;
  left: 32%;
  top: 11%;
  transform: rotate(8deg);
}
.candle {
  position: absolute;
  left: 50%;
  bottom: 7%;
  width: clamp(54px, 16cqw, 112px);
  height: 34%;
  transform: translateX(-50%);
  pointer-events: none;
}
.candle span,
.candle i {
  display: block;
  position: absolute;
}
.candle-shadow {
  left: 2%;
  bottom: 0;
  width: 140%;
  height: 10%;
  background: radial-gradient(ellipse at 42% center, #372d20a0, transparent 68%);
  border-radius: 50%;
}
.brass-foot,
.brass-dish,
.brass-neck {
  background: linear-gradient(
    98deg,
    #705236,
    #b68d55 15%,
    #efd39b 29%,
    #bb934e 45%,
    #876540 78%,
    #b28a53 93%,
    #5b4931
  );
  box-shadow: inset 0 -2px 2px #493a2677;
}
.brass-foot {
  left: 10%;
  width: 80%;
  height: 12%;
  bottom: 2%;
  border-radius: 50%;
  border-top: 2px solid #e0c995;
}
.brass-neck {
  left: 35%;
  width: 30%;
  bottom: 9%;
  height: 19%;
  clip-path: polygon(20% 0, 80% 0, 67% 35%, 74% 70%, 100% 90%, 85% 100%, 15% 100%, 0 90%, 26% 70%, 33% 35%);
}
.brass-dish {
  left: 6%;
  width: 88%;
  bottom: 23%;
  height: 11%;
  border-radius: 50%;
  border-top: 2px solid #ead3a5;
}
.wax {
  left: 28%;
  width: 44%;
  height: 55%;
  bottom: 29%;
  border-radius: 44% 44% 20% 20% / 4px 4px 3px 3px;
  background: linear-gradient(90deg, #ac966c, #f3dfad 17%, #ffeec4 35%, #e4cda0 65%, #b7a177);
}
.wax::before {
  content: '';
  position: absolute;
  inset: -2px 0 auto;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(ellipse, #ab8e60 4%, #dec79d 29%, #fff1c9 72%);
}
.drip {
  left: 14%;
  top: 0;
  width: 16%;
  height: 20%;
  border-radius: 0 0 9px 8px;
  background: #fff1ccab;
  box-shadow: 8px -5px 0 -1px #f8e5bd;
}
.wick {
  left: 48%;
  bottom: 98%;
  width: 3px;
  height: 7px;
  background: linear-gradient(#b66d44, #302c23);
  transform: rotate(5deg);
}
.flame {
  left: 50%;
  bottom: calc(100% + 4px);
  width: 38%;
  height: 32%;
  border-radius: 73% 27% 58% 42% / 85% 49% 51% 15%;
  background: radial-gradient(ellipse at 48% 78%, #fffde9 12%, #ffeb9c 42%, #ffba4a 71%, #ef8e35 91%);
  box-shadow: 0 0 14px 4px #ffbb5a70;
  transform-origin: 50% 100%;
  animation: flame-dance 0.8s ease-in-out alternate infinite;
}
@keyframes flame-dance {
  from {
    transform: translateX(-50%) rotate(-5deg);
  }
  to {
    transform: translateX(-50%) rotate(7deg) scale(0.96, 1.05);
  }
}
.smoke {
  opacity: 0;
  bottom: 100%;
  left: 40%;
  width: 30%;
  height: 44%;
  border-radius: 50%;
  border-left: 3px solid #dedaceaa;
  transform: rotate(9deg);
}
.out .flame {
  visibility: hidden;
}
.out .smoke {
  opacity: 1;
}
.dojo {
  position: relative;
  width: min(97cqw, 78cqh, 490px);
  aspect-ratio: 557 / 680;
  pointer-events: none;
}
.dojo::before {
  content: '';
  position: absolute;
  inset: 94% 2% -1%;
  background: radial-gradient(ellipse, #332b209e, transparent 68%);
  border-radius: 50%;
}
.netero {
  width: 100%;
  height: 100%;
  display: block;
  position: absolute;
  inset: 0;
  object-fit: contain;
  filter: drop-shadow(2px 4px 3px #322d234d);
}
.nen-ball {
  position: absolute;
  width: max(14.5%, 37px);
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  overflow: hidden;
  background: radial-gradient(ellipse at 28% 26%, #fff5cf 2%, #edd49b 23%, #dca564 55%, #ad7040 82%, #714b32);
  box-shadow:
    inset -3px -4px 6px #67431950,
    0 3px 4px #2b271d75;
}
.nen-ball::before,
.nen-ball::after,
.nen-ball b {
  content: '';
  position: absolute;
  inset: -21% 17%;
  border-radius: 50%;
  border: 2px solid #946b45b3;
  transform: rotate(var(--spin, 20deg));
}
.nen-ball::after {
  inset: 25% -22%;
}
.nen-ball b {
  inset: 0;
  border: 1px solid #f3ddb8;
  transform: none;
}
.catch-feedback {
  position: fixed;
  z-index: 2;
  width: clamp(46px, 8vmin, 74px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: catch-fade 480ms ease-out both;
}
.catch-feedback::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid #ffe5a2;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #865b2c, inset 0 0 6px #ffe6a9;
  animation: catch-ripple 480ms ease-out both;
}
.catch-feedback[data-result='miss']::before {
  border-color: #ff655e;
  box-shadow: 0 0 0 1px #732b2b, inset 0 0 6px #ff7972;
}
.catch-feedback[data-result='hit']::after {
  content: '✓';
  position: absolute;
  top: -0.7rem;
  right: -0.35rem;
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border: 1px solid #906b3b;
  border-radius: 50%;
  background: #ffe7aa;
  color: #45311e;
  font: bold 1rem/1 system-ui, sans-serif;
}
#chamber[data-state='idle'] .catch-feedback { visibility: hidden; }
@keyframes catch-fade {
  0%, 60% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes catch-ripple {
  from { transform: scale(0.72); }
  to { transform: scale(1.24); }
}
@media (max-height: 520px) and (orientation: landscape) {
  #games {
    grid-template-columns: minmax(178px, 0.84fr) minmax(0, 1.45fr);
    grid-template-rows: 1fr 1fr;
    gap: 0 12px;
    padding: 10px 15px;
  }
  .game-header {
    align-self: end;
    padding-bottom: 8px;
  }
  .game-footer {
    align-self: start;
    padding-top: 8px;
  }
  #arena {
    grid-column: 2;
    grid-row: 1/3;
  }
  #game-title {
    font-size: clamp(1.9rem, 7vh, 2.45rem);
    margin-inline: 0;
  }
  #game-goal {
    font-size: 0.85rem;
  }
  #game-exit {
    top: auto;
    bottom: 100%;
    right: -5px;
  }
  #games[data-game='wind'] {
    background: linear-gradient(90deg, #223029ed, #2e3b2ddc 26%, #34443026 62%, transparent);
  }
  #games[data-game='ball'] {
    background-image:
      linear-gradient(90deg, #1c2b22e8, #1d261e88 40%, transparent 72%), url('assets/dirigivel.webp');
  }
}
@media (prefers-reduced-motion: reduce) {
  .catch-feedback::before { animation: none; }
  .flame {
    animation: none;
    transform: translateX(-50%);
  }
}
