/* General Overlay */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 20px;
  z-index: 100;
  transition: opacity 0.3s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Announce / Turn Transition Overlay */
.overlay.announce-overlay {
  background: radial-gradient(circle at 30% 20%, rgba(129, 244, 149, 0.2), transparent 60%),
    radial-gradient(circle at 70% 80%, rgba(182, 23, 75, 0.18), transparent 65%),
    rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(10px);
  align-items: center;
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.announce-text {
  text-align: center;
  transform: scale(0.8) rotate(-1.5deg);
  animation: announcePop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes announcePop {
  to { transform: scale(1) rotate(0deg); }
}

.announce-text div:first-child {
  font-size: 64px;
  font-weight: 1000;
  letter-spacing: -2px;
  margin-bottom: 0;
  text-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  font-family: 'Cexsons', 'Lokka', system-ui;
}

.announce-text .small-caps {
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 4px;
  opacity: 0.8;
  font-weight: 800;
}

/* Battle Setup Redesign: Compact Horizontal Bar */
.setup-overlay {
  background: transparent;
  backdrop-filter: none;
  padding-top: 0;
  align-items: flex-start;
  pointer-events: none;
}

/* Rules/advanced collapse behavior */
.setup-group.rules.advanced-hidden {
  display: none;
}
.setup-toggle-row {
  width: 100%;
}

/* Button state when rules are visible */
#toggleRulesBtn[aria-expanded="true"] {
  background: linear-gradient(135deg, rgba(129,244,149,0.12), rgba(255,255,255,0.9));
  border-color: rgba(0,0,0,0.12);
}

.setup-overlay > * {
  pointer-events: auto;
}

.setup-compact-bar {
  margin-top: 10px;
  width: 98%;
  max-width: 1060px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 15px;
  padding: 8px 20px !important;
  border-width: 3px !important;
  background: white !important;
  border-color: var(--nearly-black) !important;
  border-radius: 6px 6px 15px 15px / 4px 4px 4px 4px !important;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15) !important;
}

.setup-branding h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1;
  color: var(--nearly-black);
  border-right: 2px solid rgba(0,0,0,0.1);
  padding-right: 15px;
  white-space: nowrap;
}

/* Temporarily hide the branding/title in the battle setup bar */
.setup-branding {
  display: none;
}

.setup-main-sections {
  flex: 1;
  display: flex;
  flex-direction: row;
  gap: 20px;
  align-items: center;
}

.setup-main-sections > div {
  border-left: 1px dashed rgba(0, 0, 0, 0.15);
  padding-left: 20px;
}

.setup-main-sections > div:first-child {
  border-left: none;
  padding-left: 0;
}

.setup-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.setup-toggle-row {
  display: flex;
  align-items: center;
  height: 32px;
}

.group-label {
  font-size: 14px;
  font-weight: 1000;
  letter-spacing: 1px;
  opacity: 0.6;
  text-transform: uppercase;
}

.input-row {
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: center;
}

.field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
}

.field label {
  font-size: 11px;
  text-transform: uppercase;
  white-space: nowrap;
}

.field input[type="number"] {
  width: 38px;
  padding: 2px 4px;
  border: 2px solid rgba(0,0,0,0.15);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 800;
}

.field select {
  padding: 2px 4px;
  border: 2px solid rgba(0,0,0,0.15);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 800;
  background: #fff;
}

.checkbox-field {
  gap: 4px;
}

.checkbox-field input {
  margin: 0;
}

.mini-btn {
  padding: 4px 8px !important;
  font-size: 13px !important;
  letter-spacing: 1px;
  border-width: 2px !important;
  box-shadow: 0 2px 0 rgba(0,0,0,0.1) !important;
}

.setup-actions {
  padding-left: 10px;
}

.setup-actions .primary {
  font-size: 14px;
  padding: 8px 20px !important;
  border-radius: 6px;
}

/* Fridge magnet style primary button */
.primary {
  background: linear-gradient(135deg, var(--green), #2d7a2d) !important;
  color: #ffffff !important;
  border-color: #144218 !important;
  font-size: 16px;
  padding: 12px 24px !important;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Upgrade Selection Modal */
.upgrade-modal {
  width: 440px;
  max-width: 90vw;
  padding: 30px !important;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-width: 4px !important;
  /* Hand-drawn paper slip look */
  border-radius: 2px 2px 2px 2px / 30px 4px 30px 4px !important;
  transform: rotate(1deg);
  box-shadow: 5px 10px 20px rgba(0,0,0,0.15) !important;
}

.modal-header {
  text-align: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.5px;
  font-family: 'Cexsons', 'Lokka', system-ui;
}

.modal-header p {
  margin: 4px 0 0;
}

.upgrades-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Tutorial Specifics */
.tutorial-overlay {
  z-index: 200;
  background: rgba(0, 0, 0, 0.4);
  align-items: center;
}

.tutorial-card {
  width: 400px;
  max-width: 85vw;
  padding: 24px !important;
  text-align: center;
  transform: rotate(0.5deg);
  border-width: 4px !important;
  box-shadow: 0 15px 40px rgba(0,0,0,0.4) !important;
  pointer-events: auto;
}

.tutorial-card h3 {
  font-size: 24px;
  margin-top: 0;
  color: var(--blue);
}

.tutorial-card p {
  font-size: 19px;
  line-height: 1.4;
  margin: 15px 0 25px;
}

.tutorial-footer {
  display: flex;
  justify-content: center;
}

.highlight-tutorial {
  position: relative;
  z-index: 210 !important; /* Higher than the 200 overlay */
  outline: 4px solid var(--orange);
  transition: box-shadow 0.3s ease;
  animation: pulse-highlight 1.2s ease-in-out infinite;
}

@keyframes pulse-highlight {
  0%, 100% {
    box-shadow: 0 0 0 10px var(--yellow), 0 0 25px var(--orange);
  }
  50% {
    box-shadow: 0 0 0 14px var(--yellow), 0 0 35px var(--orange);
  }
}

/* 
   Lift ancestors that create stacking contexts (transform/filter) 
   so their highlighted children aren't trapped behind the blur.
*/
#topHud:has(.highlight-tutorial),
#hudBottom:has(.highlight-tutorial),
.card:has(.highlight-tutorial) {
  z-index: 210 !important;
}

/* Specific highlight handling for elements that might need transparency help */
#powerContainer.highlight-tutorial,
.actions-group.highlight-tutorial,
#aimGroup.highlight-tutorial,
#windGroup.highlight-tutorial {
  background: white;
  border-radius: 8px;
}