.controls-dialog {
  position: absolute;
  inset: 0;
  z-index: 20;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(37, 16, 3, 0.76);
  backdrop-filter: blur(3px);
}

.controls-card {
  position: relative;
  width: min(520px, 100%);
  max-height: 100%;
  padding: 28px 30px 24px;
  overflow-y: auto;
  border: 4px solid #7e3a00;
  border-radius: 24px;
  background: linear-gradient(180deg, #ffe6a1 0%, #efb758 100%);
  color: #4b2100;
  text-align: center;
  box-shadow:
    inset 0 4px 0 rgba(255, 255, 255, 0.45),
    inset 0 -5px 0 rgba(117, 47, 0, 0.24),
    0 8px 0 #572200,
    0 18px 36px rgba(0, 0, 0, 0.45);
}

.controls-card h2 {
  margin: 0;
  color: #9a3600;
  font-family: GameFont, GameText, Arial, sans-serif;
  font-size: 44px;
  line-height: 1;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 #ffdb7a;
}

.controls-description {
  max-width: 400px;
  margin: 8px auto 20px;
  font-size: 16px;
  line-height: 1.4;
}

.controls-close-button {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 42px;
  height: 42px;
  border: 3px solid #7e3a00;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffcf55, #e57b00);
  color: #5c2400;
  font-size: 31px;
  font-weight: 900;
  line-height: 30px;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.35),
    0 3px 0 #5c2400;
}

.controls-close-button:hover {
  filter: brightness(1.08);
}

.controls-close-button:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    0 1px 0 #5c2400;
}

.controls-close-button:focus-visible,
.controls-dialog button:focus-visible {
  outline: 4px solid #fff3b4;
  outline-offset: 3px;
}

.controls-content {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.control-group {
  min-height: 150px;
  padding: 16px 10px;
  border: 3px solid rgba(126, 58, 0, 0.7);
  border-radius: 16px;
  background: rgba(255, 244, 199, 0.72);
}

.control-group strong {
  display: block;
  margin-bottom: 12px;
  color: #7c2d00;
  font-size: 17px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.control-group p {
  margin-top: 13px;
  font-size: 13px;
  line-height: 1.3;
}

.key-row {
  min-height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
}

.key {
  min-width: 42px;
  height: 36px;
  padding: 5px 10px;
  border: 3px solid #7a3900;
  border-radius: 9px;
  background: #fff2c6;
  color: #4b2100;
  font-size: 20px;
  line-height: 21px;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.75),
    0 3px 0 #8b4a0a;
}

.wide-key {
  min-width: 92px;
}

.controls-hint {
  margin-top: 18px;
  padding: 9px 14px;
  border-radius: 12px;
  background: rgba(133, 58, 0, 0.12);
  font-size: 14px;
  line-height: 1.35;
}

.pause-dialog {
  position: absolute;
  inset: 0;
  z-index: 30;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(37, 16, 3, 0.78);
  backdrop-filter: blur(4px);
}

.pause-card {
  width: min(420px, 100%);
  max-height: 100%;
  padding: 30px;
  overflow: hidden;
  border: 4px solid #7e3a00;
  border-radius: 24px;
  background: linear-gradient(180deg, #ffe6a1 0%, #efb758 100%);
  color: #4b2100;
  text-align: center;
  box-shadow:
    inset 0 4px 0 rgba(255, 255, 255, 0.45),
    inset 0 -5px 0 rgba(117, 47, 0, 0.24),
    0 8px 0 #572200,
    0 18px 36px rgba(0, 0, 0, 0.45);
}

.pause-card h2 {
  margin: 0;
  color: #9a3600;
  font-family: GameFont, GameText, Arial, sans-serif;
  font-size: 52px;
  line-height: 1;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 #ffdb7a;
}

.pause-card p {
  margin-top: 10px;
  font-size: 17px;
}

.pause-actions {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pause-action-button {
  width: 100%;
  min-width: 0;
  min-height: 54px;
  padding: 0 14px;
  border: 3px solid #7e3a00;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffe174 0%, #ffad16 55%, #dc6f00 100%);
  color: #fff8d6;
  font-family: GameFont, GameText, Arial, sans-serif;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 #7a2600;
  white-space: nowrap;
  box-shadow:
    inset 0 4px 0 rgba(255, 255, 255, 0.4),
    0 4px 0 #5c2400;
}

.pause-sound-button {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
}

.pause-sound-button img {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  object-fit: contain;
  pointer-events: none;
}

.pause-action-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.pause-action-button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #5c2400;
}

.pause-action-button:focus-visible {
  outline: 4px solid #ffffff;
  outline-offset: 3px;
}

@media (orientation: landscape) and (max-width: 1024px) and (max-height: 600px) {
  .controls-dialog {
    padding: 12px;
  }

  .controls-card {
    width: min(470px, 92%);
    padding: 16px 18px 14px;
  }

  .controls-card h2 {
    font-size: 32px;
  }

  .controls-description {
    margin-bottom: 12px;
    font-size: 13px;
  }

  .controls-close-button {
    top: 7px;
    right: 8px;
    width: 36px;
    height: 36px;
    font-size: 26px;
  }

  .controls-content {
    gap: 8px;
  }

  .control-group {
    min-height: 112px;
    padding: 10px 6px;
  }

  .control-group strong {
    margin-bottom: 7px;
    font-size: 14px;
  }

  .control-group p {
    margin-top: 8px;
    font-size: 11px;
  }

  .controls-hint {
    margin-top: 10px;
    padding: 6px 10px;
    font-size: 12px;
  }
}

@media (orientation: landscape) and (hover: none),
  (orientation: landscape) and (any-pointer: coarse) {
  .pause-dialog {
    padding: max(10px, var(--safe-top)) max(12px, var(--safe-right))
      max(10px, var(--safe-bottom)) max(12px, var(--safe-left));
  }

  .pause-card {
    width: min(520px, calc(100% - 8px));
    padding: clamp(12px, 3dvh, 20px) clamp(14px, 3vw, 24px);
    border-width: 3px;
    border-radius: clamp(16px, 3vw, 22px);
  }

  .pause-card h2 {
    font-size: clamp(30px, 9dvh, 42px);
    line-height: 0.95;
  }

  .pause-card p {
    margin-top: 4px;
    font-size: clamp(12px, 3dvh, 14px);
  }

  .pause-actions {
    margin-top: clamp(10px, 3dvh, 16px);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(8px, 2dvh, 12px);
  }

  .pause-action-button {
    min-height: clamp(44px, 12dvh, 52px);
    padding: 0 clamp(8px, 2vw, 14px);
    border-radius: 14px;
    font-size: clamp(20px, 5dvh, 27px);
  }

  .pause-sound-button {
    gap: clamp(5px, 1vw, 8px);
  }

  .pause-sound-button img {
    width: clamp(20px, 5dvh, 25px);
    height: clamp(20px, 5dvh, 25px);
  }
}

@media (orientation: landscape) and (max-height: 360px) {
  .pause-dialog {
    padding: 8px max(10px, var(--safe-right)) 8px max(10px, var(--safe-left));
  }

  .pause-card {
    width: min(500px, calc(100% - 4px));
    padding: 10px 14px;
  }

  .pause-card h2 {
    font-size: 28px;
  }

  .pause-card p {
    display: none;
  }

  .pause-actions {
    margin-top: 8px;
    gap: 8px;
  }

  .pause-action-button {
    min-height: 42px;
    font-size: 20px;
  }

  .pause-sound-button img {
    width: 20px;
    height: 20px;
  }
}
