* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #040904;
  color: #e8fff0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Trebuchet MS", sans-serif;
  touch-action: none;
}

#game-shell {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 6px);
  padding-bottom: env(safe-area-inset-bottom, 6px);
  padding-left: env(safe-area-inset-left, 8px);
  padding-right: env(safe-area-inset-right, 8px);
  background: var(--shell-bg, #040904);
  transition: background-color 0.4s ease;
}

#hud {
  flex: 0 0 auto;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 20;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-btn {
  position: relative;
  min-width: 44px;
  height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(12, 18, 28, 0.85);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.hud-btn:active {
  transform: scale(0.95);
}

.parent-hold {
  overflow: hidden;
}

.parent-ring {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 4px;
  width: 0%;
  background: #ffd166;
  transition: width 0.05s linear;
}

.secrets-pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  background: rgba(10, 16, 24, 0.82);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

#stage-wrap {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#game-canvas {
  display: block;
  image-rendering: -moz-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-radius: 10px;
  touch-action: none;
}

#fx-canvas {
  position: absolute;
  pointer-events: none;
  touch-action: none;
}

/* ЭЛТ-эффект лёгких сканлайнов, не мешающих чтению */
#stage-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 3px,
    rgba(0, 0, 0, 0.12) 4px
  );
  opacity: 0.45;
}

body.reduced-motion #stage-wrap::after {
  opacity: 0.15;
}

.speech-box {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(94%, 520px);
  background: rgba(9, 14, 22, 0.94);
  border: 3px solid #48ff48;
  border-radius: 14px;
  padding: 12px 16px;
  z-index: 30;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

.speech-who {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #ffd166;
  margin-bottom: 3px;
}

.speech-text {
  font-size: clamp(18px, 3vw, 23px);
  font-weight: 800;
  line-height: 1.25;
  color: #ffffff;
}

.speech-tap {
  margin-top: 4px;
  text-align: right;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.75;
}

.bang-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  background: #ffd166;
  color: #10182b;
  border: 3px solid #10182b;
  border-radius: 12px;
  padding: 6px 16px;
  text-align: center;
  z-index: 25;
  pointer-events: none;
  box-shadow: 4px 4px 0 #ff3b5c;
}

.bang-word {
  font-size: clamp(24px, 5vw, 34px);
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1;
}

.bang-sub {
  font-size: clamp(14px, 2.5vw, 18px);
  font-weight: 800;
  margin-top: 2px;
}

.red-button {
  position: absolute;
  right: 12%;
  top: 44%;
  padding: 14px 18px;
  border-radius: 999px;
  border: 4px solid #fff;
  background: #ff2a55;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.8px;
  box-shadow: 0 6px 0 #8a0d27;
  cursor: pointer;
  z-index: 26;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

.red-button.run-away {
  transform: translateX(160px);
  opacity: 0;
}

.terminal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(2, 7, 2, 0.96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 35;
  gap: 18px;
}

.terminal-lines {
  width: min(92%, 520px);
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(16px, 2.8vw, 22px);
  font-weight: 700;
  line-height: 1.5;
  color: #48ff48;
  white-space: pre-wrap;
}

.terminal-lines .err {
  color: #ff5c77;
}

.terminal-lines .glitch-hungry {
  display: block;
  margin-top: 12px;
  font-size: clamp(26px, 5vw, 38px);
  color: #ff3880;
  letter-spacing: 4px;
  text-align: center;
}

.dev-note-btn, .replay-btn, .action-btn, .danger-btn {
  min-height: 46px;
  padding: 12px 22px;
  border-radius: 12px;
  border: 2px solid #48ff48;
  background: #0d2212;
  color: #e8fff0;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
}

.replay-btn {
  border-color: #ffd166;
  background: #231f0a;
  color: #ffd166;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.sleep-card, .note-card, .parent-card {
  width: min(94%, 420px);
  background: #10182b;
  border: 3px solid #22d3ee;
  border-radius: 18px;
  padding: 22px;
  color: #f1f5f9;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sleep-card {
  text-align: center;
  cursor: pointer;
}

.sleep-zzz {
  font-size: 38px;
  font-weight: 900;
  color: #ffd166;
}

.note-header {
  font-family: "Courier New", monospace;
  font-size: 16px;
  font-weight: 800;
  color: #48ff48;
}

.note-body {
  font-size: 20px;
  line-height: 1.45;
  color: #ffffff;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 17px;
  font-weight: 700;
  padding: 6px 0;
}

.toggle-row input {
  width: 24px;
  height: 24px;
}

.family-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding-top: 10px;
}

.family-title {
  font-size: 13px;
  color: #94a3b8;
  font-weight: 700;
}

.family-section input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: #080d18;
  color: #fff;
  font-size: 16px;
}

.parent-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.danger-btn {
  border-color: #ff3b5c;
  background: #3b0d18;
  color: #ffd5dc;
}

.action-btn {
  border-color: #22d3ee;
  background: #0c3342;
  color: #fff;
}

.hidden {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .red-button {
    transition: none;
  }
}
