/* The arcade occupies the usable viewport, including iPhone safe areas. */
dialog.arcade {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: #e9edda;
  color: #254f43;
}
dialog.arcade[open] {
  display: flex;
  flex-direction: column;
}
.arcade::backdrop {
  background: #254b40;
}
.arcade-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right)) 13px
    max(20px, env(safe-area-inset-left));
  background: #faf8ed;
  border-bottom: 1px solid #45644420;
  z-index: 3;
}
.arcade-header > div {
  text-align: center;
}
.arcade-header small {
  font:
    600 9px/1.5 "DM Sans",
    sans-serif;
  letter-spacing: 0.19em;
  color: #8a9279;
}
.arcade-header h1 {
  font:
    500 clamp(18px, 2.4vw, 28px)/1.1 Fraunces,
    Georgia,
    serif;
  margin: 3px 0 0;
  letter-spacing: -0.6px;
}
.arcade-header button {
  background: #e9edda;
  color: #345949;
  min-width: 44px;
  min-height: 44px;
  border-radius: 16px;
  font-size: 20px;
  padding: 8px 13px;
}
.arcade-header .arcade-exit {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
}
.arcade-exit span {
  font-size: 12px;
}
.arcade-content {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}
.game-hud {
  display: flex;
  justify-content: center;
  gap: clamp(35px, 10vw, 140px);
  padding: 10px 18px;
  background: #e9edda;
  z-index: 1;
  flex-shrink: 0;
}
.game-hud div {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.game-hud small {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.13em;
  color: #74826a;
}
.game-hud b {
  font:
    600 20px Fraunces,
    Georgia,
    serif;
  letter-spacing: 0.02em;
}
.arcade-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #729b83;
}
.arcade-stage > canvas {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
  touch-action: none;
}
.game-footer {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 12px max(24px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: #faf8ed;
}
.arcade .game-footer p {
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
  color: #607960;
  max-width: 330px;
}
.hop-controls {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(2, 42px);
  gap: 4px;
}
.hop-controls button {
  padding: 0;
  background: #e6ebd5;
  color: #355d48;
  border-radius: 12px;
  font-size: 25px;
  touch-action: manipulation;
  box-shadow: 0 3px 0 #cdd8bc;
}
.hop-controls button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #cdd8bc;
}
.hop-controls button:first-child {
  grid-column: 2;
}
.hop-controls button:nth-child(2) {
  grid-column: 1;
}
.keyboard-tip {
  max-width: 200px;
  justify-self: end;
  font-size: 9px;
  letter-spacing: 0.08em;
  line-height: 1.8;
  color: #8a9279;
}
.game-overlay,
.arcade-pause-screen {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #254b4040;
  backdrop-filter: blur(5px);
  overflow: auto;
}
.game-overlay {
  position: fixed;
  top: calc(79px + env(safe-area-inset-top));
}
.arcade-card {
  width: min(460px, 100%);
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid #fff9;
  border-radius: 28px;
  background: #fbf8eefa;
  box-shadow: 0 20px 70px #254b402b;
  text-align: center;
  margin: auto;
}
.arcade-card .eyebrow {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: #859070;
}
.arcade-card h2 {
  font:
    500 clamp(29px, 4vw, 42px)/1.1 Fraunces,
    Georgia,
    serif;
  letter-spacing: -1.4px;
  margin: 10px 0 16px;
}
.arcade-card p {
  font-size: 14px;
  line-height: 1.6;
  color: #6e7e65;
  margin: 0 0 17px;
}
.arcade-card > small {
  display: block;
  font-size: 10px;
  line-height: 1.5;
  margin: 12px 0 0;
  color: #90967e;
}
.arcade-card .primary {
  font-size: 15px;
  padding: 16px 20px;
}
.beaver-badge {
  font-size: 40px;
  line-height: 1.3;
  margin: 12px 0;
}
.balloon-badge {
  background: #edd99c;
  border-radius: 50% 50% 45% 45%;
  width: 44px;
  height: 53px;
  margin: 14px auto;
  font-size: 30px;
  line-height: 53px;
  color: #8e7747;
}
.game-instructions {
  display: grid;
  gap: 8px;
  margin: 18px 0 24px;
  text-align: left;
  font-size: 12px;
  color: #516e56;
}
.result-stars {
  font-size: 38px;
  letter-spacing: 7px;
  color: #d1a842;
  margin: 20px 0 10px;
}
.result-numbers {
  display: flex;
  justify-content: space-around;
  margin: 20px 0 26px;
}
.result-numbers span {
  font-size: 11px;
  color: #849074;
}
.result-numbers b {
  display: block;
  font:
    600 30px Fraunces,
    Georgia,
    serif;
  color: #355b49;
  margin-bottom: 5px;
}
.arcade-pause-screen {
  z-index: 10;
  background: #24483c80;
}
.balloon-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.arcade .balloon-controls p {
  text-align: center;
  max-width: 550px;
  min-height: 1.5em;
}
.fill-controls,
.launch-controls {
  width: min(420px, 100%);
}
.fill-meter,
.wind-meter {
  position: relative;
  height: 20px;
  border-radius: 20px;
  background: #e2e5cf;
  margin-top: 8px;
}
.fill-target {
  position: absolute;
  left: 76%;
  width: 12%;
  height: 100%;
  background: #e5c76a;
  border: 2px solid #b48e30;
  border-radius: 4px;
  z-index: 2;
}
.fill-level {
  display: block;
  height: 100%;
  width: 8%;
  border-radius: 20px;
  background: #88b3a0;
}
.fill-pointer,
.wind-meter i {
  position: absolute;
  height: 30px;
  width: 5px;
  border: 1px solid #fff;
  border-radius: 3px;
  top: -5px;
  background: #345a4a;
  z-index: 3;
  transform: translateX(-50%);
}
.meter-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: #879071;
  margin: 7px 0 10px;
}
.pump-button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  background: #365e4c;
  color: #fff9df;
  min-height: 50px;
  padding: 14px 22px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 600;
  touch-action: none;
  user-select: none;
}
.pump-button.pumping {
  background: #bc9956;
}
.weather-buttons {
  display: flex;
  gap: 10px;
}
.weather-buttons button {
  background: #e4e8d2;
  color: #5b7b60;
  width: 80px;
  height: 65px;
  padding: 6px;
  border: 2px solid transparent;
  border-radius: 16px;
}
.weather-buttons span {
  display: block;
  font-size: 27px;
  line-height: 32px;
}
.weather-buttons small {
  font-size: 10px;
}
.weather-buttons button:disabled {
  opacity: 1;
  cursor: default;
}
.weather-buttons button.lit {
  background: #f5db81;
  border-color: #c5a84a;
  color: #766028;
  box-shadow: 0 0 25px #f4d37780;
}
.signal-progress {
  min-height: 23px;
  text-align: center;
  font-size: 12px;
  color: #7e885f;
  margin-bottom: 6px;
}
.signal-controls .signal-repeat {
  margin-top: 3px;
  padding: 6px;
  font-size: 11px;
  border: 0;
  min-height: 32px;
}
.wind-meter {
  background: linear-gradient(
    90deg,
    #dbba86,
    #ece2b5 34%,
    #93b897 34%,
    #93b897 66%,
    #ece2b5 66%,
    #dbba86
  );
}
.balloon-controls .keyboard-tip {
  justify-self: auto;
  max-width: none;
}
@media (max-width: 600px) {
  .arcade-header {
    padding: max(12px, env(safe-area-inset-top)) 14px 10px;
    gap: 8px;
  }
  .arcade-header .arcade-exit span {
    display: none;
  }
  .arcade-header h1 {
    font-size: 21px;
  }
  .arcade-header small {
    font-size: 8px;
  }
  .game-hud {
    justify-content: space-between;
    gap: 10px;
    padding: 10px 20px;
  }
  .game-hud div {
    flex-direction: column;
    gap: 3px;
  }
  .game-hud b {
    font-size: 18px;
  }
  .game-footer {
    grid-template-columns: 1fr auto;
    gap: 15px;
    padding: 12px 18px max(14px, env(safe-area-inset-bottom));
  }
  .arcade .game-footer p {
    font-size: 11px;
  }
  .game-footer .keyboard-tip {
    display: none;
  }
  .hop-controls {
    grid-template-columns: repeat(3, 46px);
    grid-template-rows: repeat(2, 42px);
  }
  .game-overlay {
    top: calc(73px + env(safe-area-inset-top));
    padding: 16px;
  }
  .arcade-card {
    padding: 24px;
    border-radius: 24px;
  }
  .arcade-card h2 {
    font-size: 34px;
  }
  .arcade-card .beaver-badge {
    margin: 9px;
  }
  .game-instructions {
    margin: 16px 0 20px;
  }
  .balloon-controls {
    padding: 10px 20px max(14px, env(safe-area-inset-bottom));
  }
  .balloon-hud > div:first-child b {
    font-size: 16px;
  }
}
@media (max-height: 550px) and (min-width: 600px) {
  .arcade-header {
    padding: 7px 16px;
    min-height: 54px;
  }
  .arcade-header small {
    display: none;
  }
  .arcade-header h1 {
    font-size: 22px;
  }
  .arcade-content {
    padding-right: 210px;
  }
  .game-hud {
    padding: 6px 16px;
    gap: 35px;
  }
  .game-hud b {
    font-size: 17px;
  }
  .game-footer {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 210px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
    padding: 18px;
  }
  .game-footer p {
    text-align: center;
  }
  .keyboard-tip {
    display: none;
  }
  .game-overlay {
    top: 58px;
    padding: 12px;
  }
  .arcade-card {
    width: min(670px, 100%);
    padding: 20px 26px;
  }
  .arcade-card h2 {
    font-size: 28px;
    margin: 8px 0;
  }
  .arcade-card h2 br {
    display: none;
  }
  .arcade-card p {
    font-size: 12px;
    margin-bottom: 8px;
  }
  .arcade-card .beaver-badge,
  .arcade-card .balloon-badge {
    display: none;
  }
  .game-instructions {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin: 13px 0;
    font-size: 10px;
  }
  .arcade-card .primary {
    max-width: 300px;
    margin: auto;
    padding: 12px 18px;
  }
  .arcade-card > small {
    margin-top: 7px;
  }
  .result-stars {
    margin: 5px;
    font-size: 25px;
  }
  .result-numbers {
    margin: 12px;
  }
  .result-numbers b {
    font-size: 24px;
  }
  .arcade-card .subtle-button {
    margin-top: 4px;
    padding: 8px;
  }
  .balloon-controls {
    gap: 10px;
  }
  .weather-buttons {
    gap: 5px;
  }
  .weather-buttons button {
    width: 54px;
    height: 61px;
  }
  .weather-buttons small {
    font-size: 8px;
  }
}

.tap-mode {
  display: block;
  margin: 5px auto 0;
  min-height: 28px;
  background: transparent;
  color: #788767;
  font-size: 10px;
  padding: 5px;
}
