html, body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  font-family: sans-serif;
  background: #000;
  color: white;
  overflow-x: hidden;
  touch-action: pan-y;
  overscroll-behavior-x: none;
}

.orientation-warning {
  display: none;
  position: fixed;
  z-index: 9999;
  width: 100vw;
  height: 100vh;
  background: #000000ee;
  color: white;
  font-size: 24px;
  justify-content: center;
  align-items: center;
  text-align: center;
  animation: blink 1.5s infinite;
  font-family: 'Arial', sans-serif;
  padding: 20px;
  box-sizing: border-box;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@media screen and (orientation: portrait) {
  .static-screen, .start-screen, .video-container { display: none; }
  .orientation-warning { display: flex; }
}

.start-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.9)), url('pages/menu-bg.png') no-repeat center center;
  background-size: cover;
  position: fixed;
  z-index: 50;
}

.logo {
  font-size: 48px;
  font-weight: bold;
  color: #ff6d6d;
  text-shadow: 0 0 10px rgba(255, 109, 109, 0.7);
  margin-bottom: 80px;
  letter-spacing: 3px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.9; }
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 25px;
  align-items: center;
}

.play-btn {
  background: #28a745;
  color: white;
  border: none;
  border-radius: 30px;
  padding: 15px 60px;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 0 #1e7e34;
}

.play-btn:active {
  transform: translateY(4px);
  box-shadow: none;
}

.settings-menu-btn {
  background: linear-gradient(145deg, #4e4e4e, #3a3a3a);
  color: white;
  border: 1px solid #666;
  border-radius: 14px;
  padding: 14px 40px;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease;
}
.settings-menu-btn:hover {
  background: #5a5a5a;
  transform: scale(1.03);
}
.settings-menu-btn:active {
  transform: scale(0.98);
  box-shadow: none;
}

.video-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 40;
  display: none;
  justify-content: center;
  align-items: center;
}

.intro-video {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

.static-screen {
  width: 1280px;
  height: 720px;
  position: relative;
  overflow: hidden;
  display: none;
  max-width: 100vw;
  max-height: 100vh;
  transform-origin: top left;
  transform: scale(calc(min(100vw / 1280, 100vh / 720)));
  background: url("pages/fon1.png") no-repeat center center;
  background-size: contain;
  background-color: black;
}

.left-panel {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}

.left-panel img {
  width: 50px;
  cursor: pointer;
  border-radius: 6px;
  border: none;
}
.left-panel img:focus {
  outline: none;
}

#add-choices-btn {
  padding: 4px 8px;
  font-size: 13px;
  border-radius: 8px;
  background: #287233;
  color: white;
  border: none;
  cursor: pointer;
}
#add-choices-btn:focus {
  outline: none;
}

.hud {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.3);
  padding: 6px;
  border-radius: 12px;
  backdrop-filter: blur(5px);
  z-index: 10;
}

#settings-btn {
  width: 28px;
  height: 28px;
  cursor: pointer;
  border: none;
}
#settings-btn:focus {
  outline: none;
}

.stats-column {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat {
  font-size: 13px;
}

.progress {
  width: 140px;
  height: 10px;
  background: #333;
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
}

.rep  { background: #ff6d6d; width: 40%; }
.frnd { background: #ff9cb0; width: 50%; }
.knwl { background: #5caeff; width: 60%; }

.money {
  font-size: 14px;
  color: #98ffbb;
}

.dialogue {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.25);
  padding: 12px 16px;
  border-radius: 14px;
  max-width: 80%;
  font-family: monospace;
  z-index: 15;
}

.speaker {
  font-weight: bold;
  font-size: 16px;
}

.text {
  font-size: 14px;
  min-height: 40px;
  white-space: pre-wrap;
}

.text .cursor {
  display: inline-block;
  width: 8px;
  background-color: white;
  animation: blink 1s step-start infinite;
}

.choices {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 90%;
}

.choice {
  background: rgba(255, 255, 255, 0.15);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: white;
  backdrop-filter: blur(2px);
  cursor: pointer;
  border: none;
  transition: background-color 0.3s ease;
}

.choice.good {
  background-color: rgba(144, 238, 144, 0.5);
}

.choice.bad {
  background-color: rgba(255, 99, 71, 0.5);
}

.choice:focus {
  outline: none;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.85);
  z-index: 100;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
  border-radius: 12px;
  border: 1px solid #444;
  max-height: 80vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#passport-modal, #diary-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90vw;
  max-width: 400px;
  max-height: 90vh;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 12px;
  border: 1px solid #444;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 10px;
  box-sizing: border-box;
  z-index: 1000;
  overflow: hidden;
}

#passport-modal.active, #diary-modal.active {
  display: flex;
}

#passport-modal img, #diary-modal img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 10px;
  display: block;
  margin: 0 auto;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.6);
  display: none;
  z-index: 999;
}

.modal-overlay.active {
  display: block;
}

#name-modal, #settings-modal {
  width: 320px;
  padding: 30px;
  max-height: 80vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.name-input-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 100%;
}

#player-name {
  padding: 12px;
  border-radius: 8px;
  border: none;
  background: #333;
  color: white;
  font-size: 16px;
  text-align: center;
}

#name-submit {
  padding: 10px;
  background: #28a745;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
}

.settings-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #444;
}
.setting-item label {
  font-size: 14px;
  color: #ccc;
}
.setting-item input[type="range"] {
  width: 100%;
  accent-color: #28a745;
}

#settings-close {
  background: #444;
  padding: 10px 16px;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  border: 1px solid #666;
  transition: background 0.3s ease;
  cursor: pointer;
}
#settings-close:hover {
  background: #666;
}

.install-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  color: white;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 0 10px #000;
  display: none;
}

#installBtn {
  padding: 6px 12px;
  background: #28a745;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
#installBtn:focus {
  outline: none;
}

.modal {
  background: transparent !important;
  border: none !important;
}

.modal-image {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.7);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes slideUp {
  from { transform: translateY(50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.fade-in {
  animation: fadeIn 0.5s ease forwards;
}

.fade-out {
  animation: fadeOut 0.5s ease forwards;
}

.slide-up {
  animation: slideUp 0.4s ease forwards;
}

.screen-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 5;
  display: none;
}

.skip-prompt {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 14px;
  color: #fff;
  animation: pulse 1.5s infinite;
}

.quick-menu {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
  z-index: 25;
}

.quick-menu button {
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quick-menu button:hover {
  background: rgba(50, 50, 150, 0.7);
}

.continue-btn {
  background: #ff9800 !important;
  box-shadow: 0 4px 0 #e08600 !important;
}

.continue-btn:active {
  transform: translateY(4px);
  box-shadow: none !important;
}

.settings-scroll::-webkit-scrollbar {
  width: 8px;
}
.settings-scroll::-webkit-scrollbar-track {
  background: #222;
  border-radius: 4px;
}
.settings-scroll::-webkit-scrollbar-thumb {
  background-color: #888;
  border-radius: 4px;
  transition: background 0.3s ease;
}
.settings-scroll::-webkit-scrollbar-thumb:hover {
  background-color: #aaa;
}

img, button, input, video {
  outline: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

img:focus, button:focus, input:focus, video:focus {
  outline: none;
}

.error-message {
  color: #ff6d6d;
  font-size: 12px;
  min-height: 14px;
  margin-top: -10px;
  margin-bottom: 5px;
}

.screen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: black;
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  transition: opacity 1s ease-in-out;
}

* {
  -webkit-tap-highlight-color: transparent;
}

#settings-modal {
  animation: slideDown 0.4s ease forwards;
  background: rgba(0, 0, 0, 0.85) !important;
  padding: 30px;
  border-radius: 12px;
  border: 1px solid #444 !important;
  width: 320px;
  max-height: 80vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.7);
}

@keyframes slideDown {
  from {
    transform: translate(-50%, -60%);
    opacity: 0;
  }
  to {
    transform: translate(-50%, -50%);
    opacity: 1;
  }
}

.buttons-group {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.buttons-group button {
  flex: 1;
  padding: 10px 12px;
  font-weight: 700;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background-color: #444;
  color: white;
  transition: background-color 0.3s ease;
}

.buttons-group button:hover {
  background-color: #666;
}
/* Экран установки */
#install-screen {
  display: none;
  height: 100vh;
  background: #0e0e0f;
  color: #f0f0f0;
  font-family: 'Segoe UI', sans-serif;
  padding: 24px;
  box-sizing: border-box;
  overflow-y: auto;

  display: flex;
  justify-content: center;
  align-items: flex-start;
}
#install-screen .card {
  background: #1a1a1d;
  border-radius: 20px;
  box-shadow: 0 0 32px rgba(0, 0, 0, 0.5);
  max-width: 840px;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: visible;
  padding: 24px;
  gap: 24px;
  color: #ddd;
}
#install-screen .top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
#install-screen .icon {
  width: 100px;
  height: 100px;
  border-radius: 16px;
  object-fit: cover;
  background: #444;
  flex-shrink: 0;
}
#install-screen .text {
  font-size: 16px;
  line-height: 1.7;
  max-width: 640px;
  text-align: center;
}
#install-screen .text p {
  margin-bottom: 12px;
}
#install-screen .buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
  align-items: center;
}
#install-screen .buttons button,
#install-screen .buttons a {
  background: #29292d;
  color: #fff;
  text-align: center;
  padding: 14px;
  border-radius: 12px;
  text-decoration: none;
  font-size: 15px;
  transition: all 0.2s ease;
  border: 1px solid #444;
  min-width: 180px;
  cursor: pointer;
  user-select: none;
}
#install-screen .buttons button:hover,
#install-screen .buttons a:hover {
  background: #38383d;
  transform: scale(1.03);
}
#install-screen .buttons button:disabled {
  background: #555;
  cursor: default;
  transform: none;
}
#install-screen h5 {
  color: #aaa;
  max-width: 640px;
  text-align: center;
}
#install-screen a {
  color: #ffa24b;
  text-decoration: underline;
}
@media (min-width: 640px) {
  #install-screen .top {
    flex-direction: row;
    align-items: flex-start;
    text-align: left;
  }
  #install-screen .icon {
    margin-right: 20px;
  }
  #install-screen .text {
    text-align: left;
  }
  #install-screen .buttons {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
  }
  #install-screen .buttons button,
  #install-screen .buttons a {
    min-width: 160px;
  }
  #install-screen h5 {
    text-align: left;
  }
}

.full-darkness {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s ease-in-out;
}
.version-info {
  color: #888; 
  font-family: monospace; 
  font-size: 12px; 
  margin-top: 15px; 
  opacity: 0.7; 
  letter-spacing: 1px; 
  user-select: none; 