/* ---------- Секретная кнопка ---------- */

.secret-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 10px;
  border: 0;
  background: none;
  color: var(--mocha);
  font-size: 0.9rem;
  line-height: 1;
  opacity: 0.22;
  cursor: pointer;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.secret-btn:hover,
.secret-btn:focus-visible {
  opacity: 0.9;
  transform: scale(1.25);
}

/* ---------- Игра ---------- */

.game {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2b1d2e;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: "Press Start 2P", monospace;
}

.game[hidden],
.game [hidden] {
  display: none !important;
}

.game-stage {
  position: relative;
  height: 100%;
  aspect-ratio: 9 / 16;
  max-width: 100%;
  overflow: hidden;
  background: #50bbff;
}

.game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.game-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) 12px 0 14px;
  pointer-events: none;
}

.game-score {
  color: #fff;
  font-size: 18px;
  text-shadow: 2px 2px 0 #1a1010, -2px 0 0 #1a1010, 0 -2px 0 #1a1010, 2px 0 0 #1a1010, 0 2px 0 #1a1010;
}

.game-buttons {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.game-btn-icon {
  width: 36px;
  height: 36px;
  border: 3px solid #1a1010;
  background: #fff6ea;
  color: #4f3428;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  box-shadow: inset -3px -3px 0 #e2cdb4;
}

.game-btn-icon.is-off {
  opacity: 0.5;
}

.game-progress {
  position: absolute;
  right: 10px;
  top: 64px;
  bottom: 24px;
  width: 10px;
  pointer-events: none;
}

.game-progress-track {
  position: absolute;
  inset: 18px 2px 0;
  background: rgba(26, 16, 16, 0.25);
  border: 2px solid rgba(26, 16, 16, 0.55);
}

.game-progress-goal {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  color: #f4d32a;
  font-size: 12px;
  text-shadow: 1px 1px 0 #1a1010;
}

.game-progress-dot {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 10px;
  height: 10px;
  transform: translate(-50%, 50%);
  background: #ff5d8a;
  border: 2px solid #1a1010;
}

.game-toast {
  position: absolute;
  top: 22%;
  left: 0;
  right: 0;
  text-align: center;
  color: #fff;
  font-size: 13px;
  text-shadow: 2px 2px 0 #1a1010;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.game-toast.is-visible {
  opacity: 1;
}

.game-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(86%, 340px);
  transform: translate(-50%, -50%);
  padding: 22px 18px 18px;
  text-align: center;
  color: #4f3428;
  background: #fff6ea;
  border: 4px solid #1a1010;
  box-shadow: inset -4px -4px 0 #e2cdb4, 6px 6px 0 rgba(26, 16, 16, 0.35);
}

.game-panel h2 {
  margin: 0 0 16px;
  font-family: inherit;
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: 0;
  color: #c2335a;
}

.game-panel p {
  margin: 0 0 12px;
  font-size: 9px;
  line-height: 1.8;
}

.game-panel .game-big {
  font-size: 22px;
  line-height: 1.4;
  color: #c2335a;
}

.game-panel-actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.game-btn {
  padding: 12px 10px;
  border: 3px solid #1a1010;
  background: #ff7aa2;
  color: #fff;
  font: inherit;
  font-size: 11px;
  text-shadow: 1px 1px 0 #8a2443;
  cursor: pointer;
  box-shadow: inset -3px -3px 0 #d84f7a;
}

.game-btn:active {
  box-shadow: inset 3px 3px 0 #d84f7a;
}

.game-btn.is-secondary {
  background: #f1e2cf;
  color: #4f3428;
  text-shadow: none;
  box-shadow: inset -3px -3px 0 #d3bb9d;
}

.game-banner {
  position: absolute;
  top: 16%;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0 24px;
  text-align: center;
  color: #fff;
  font-size: 16px;
  line-height: 1.6;
  text-shadow: 3px 3px 0 #c2335a;
  animation: game-banner-in 1s ease both;
  pointer-events: none;
}

@keyframes game-banner-in {
  from { opacity: 0; transform: translateY(12px) scale(0.9); }
  to { opacity: 1; transform: none; }
}

/* ---------- Письмо ---------- */

.letter-screen {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 16px;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 238, 228, 0.95), transparent 60%),
    linear-gradient(180deg, #f6ecdf 0%, #ecd6c6 100%);
  animation: letter-fade 0.8s ease both;
  overflow: hidden;
}

.letter-screen[hidden] {
  display: none;
}

@keyframes letter-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.envelope {
  position: relative;
  width: min(82vw, 380px);
  aspect-ratio: 3 / 2;
  perspective: 1200px;
  animation: envelope-in 0.9s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
  transition: transform 0.8s ease, opacity 0.6s ease;
}

@keyframes envelope-in {
  from { opacity: 0; transform: translateY(40px) scale(0.7) rotate(-6deg); }
  to { opacity: 1; transform: none; }
}

.env-back,
.env-front,
.env-flap {
  position: absolute;
  inset: 0;
}

.env-back {
  background: #d9bfa3;
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.env-letter {
  position: absolute;
  z-index: 1;
  left: 7%;
  right: 7%;
  top: 6%;
  height: 88%;
  padding: 7% 8% 0;
  background: linear-gradient(180deg, #fffdf8, #f8efe2);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(76, 46, 32, 0.15);
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.1rem, 4.6vw, 1.5rem);
  font-style: italic;
  text-align: center;
  color: var(--mocha);
  transition: transform 0.9s cubic-bezier(0.3, 0.7, 0.2, 1) 0.55s;
}

.env-front {
  z-index: 2;
  border-radius: 6px;
  background:
    linear-gradient(to top right, #ead6be 49.6%, transparent 50%) left bottom / 50.5% 100% no-repeat,
    linear-gradient(to top left, #e4cdb2 49.6%, transparent 50%) right bottom / 50.5% 100% no-repeat;
  pointer-events: none;
}

.env-front::after {
  content: "";
  position: absolute;
  inset: 40% 0 0;
  background: #efdfca;
  clip-path: polygon(0 100%, 50% 0, 100% 100%);
  border-radius: 0 0 6px 6px;
}

.env-flap {
  z-index: 3;
  height: 58%;
  background: #e0c6a8;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 0.7s ease, z-index 0s linear 0.35s;
  filter: drop-shadow(0 2px 2px rgba(76, 46, 32, 0.2));
}

.env-seal {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 58%;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #c7485f, #8e1f36 70%);
  box-shadow: 0 3px 8px rgba(80, 20, 30, 0.35), inset 0 0 0 4px rgba(255, 255, 255, 0.12);
  color: #ffd9df;
  font-size: 24px;
  cursor: pointer;
  animation: seal-pulse 1.6s ease-in-out infinite;
  transition: opacity 0.3s ease;
}

@keyframes seal-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.1); }
}

.env-hint {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.3rem;
  font-style: italic;
  color: var(--mocha-soft);
  transition: opacity 0.3s ease;
}

.envelope.is-open .env-flap {
  z-index: 0;
  transform: rotateX(180deg);
}

.envelope.is-open .env-seal,
.letter-screen.is-open .env-hint {
  opacity: 0;
  pointer-events: none;
}

.envelope.is-open .env-letter {
  transform: translateY(-62%);
}

.envelope.is-gone {
  opacity: 0;
  transform: translateY(30px) scale(0.9);
}

.letter-card {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 24px 16px;
}

.letter-card[hidden] {
  display: none;
}

.letter-paper {
  width: min(100%, 560px);
  margin: auto;
  padding: clamp(28px, 7vw, 52px) clamp(22px, 6vw, 48px);
  background: linear-gradient(180deg, #fffdf8, #f8efe2);
  border: 1px solid rgba(166, 139, 112, 0.25);
  border-radius: 6px;
  box-shadow: var(--shadow);
  color: var(--mocha);
  animation: paper-unfold 0.9s cubic-bezier(0.2, 0.8, 0.3, 1) both;
  transform-origin: top center;
}

@keyframes paper-unfold {
  from { opacity: 0; transform: perspective(900px) rotateX(-25deg) translateY(-30px) scale(0.92); }
  to { opacity: 1; transform: none; }
}

.letter-paper h2 {
  margin-bottom: 22px;
  font-size: clamp(2rem, 7vw, 2.8rem);
  font-style: italic;
  color: var(--mocha-deep);
}

.letter-paper p {
  margin: 0 0 16px;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.2rem, 4.4vw, 1.4rem);
  line-height: 1.5;
}

.letter-sign {
  margin-top: 26px !important;
  text-align: right;
  font-style: italic;
  font-weight: 600;
}

.letter-close {
  display: block;
  margin: 28px auto 0;
}
