:root {
  --ui-font: "Inter", system-ui, -apple-system, sans-serif;
  --narrative-font: "Cormorant Garamond", serif;
  --text: #f6f3ef;
  --muted: rgba(246, 243, 239, 0.8);
  --shadow: 0 18px 38px rgba(0, 0, 0, 0.34);
  --panel-shadow: 0 20px 42px rgba(0, 0, 0, 0.42);
  --panel-border: rgba(232, 214, 187, 0.18);
  --narration-bg: linear-gradient(135deg, rgba(26, 15, 11, 0.82), rgba(49, 28, 20, 0.76));
  --mark-bg: linear-gradient(135deg, rgba(16, 18, 24, 0.9), rgba(36, 42, 52, 0.82));
  --player-bg: rgba(174, 126, 78, 0.92);
  --choice-bg: linear-gradient(135deg, rgba(82, 49, 30, 0.94), rgba(146, 98, 58, 0.9));
  --choice-bg-hover: linear-gradient(135deg, rgba(102, 61, 36, 0.98), rgba(171, 116, 67, 0.94));
  --choice-border: rgba(244, 223, 196, 0.24);
  --primary-bg: linear-gradient(135deg, rgba(236, 221, 197, 0.98), rgba(204, 164, 108, 0.96));
  --primary-bg-hover: linear-gradient(135deg, rgba(245, 229, 206, 1), rgba(217, 177, 119, 0.98));
  --button-text-dark: #231910;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--ui-font);
  background: #0b0b0b;
  color: var(--text);
}

#app {
  position: relative;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: opacity 300ms ease;
}

#app.fade {
  opacity: 0;
}

#bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 0;
}

#overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.55) 60%, rgba(0,0,0,0.72) 100%);
  z-index: 1;
}

.top-controls {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 4;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.top-button {
  border: 1px solid rgba(244, 223, 196, 0.22);
  border-radius: 999px;
  padding: 7px 10px;
  font-family: var(--ui-font);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  color: rgba(246, 243, 239, 0.86);
  background: rgba(18, 16, 15, 0.5);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px) saturate(115%);
  -webkit-backdrop-filter: blur(12px) saturate(115%);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.top-button:hover,
.top-button:focus-visible {
  color: var(--text);
  background: rgba(50, 34, 26, 0.76);
  border-color: rgba(244, 223, 196, 0.42);
  transform: translateY(-1px);
}

.top-button:active {
  transform: translateY(1px);
}

.volume-control {
  position: relative;
}

.volume-panel {
  position: absolute;
  top: 34px;
  left: 50%;
  width: 36px;
  height: 148px;
  padding: 12px 0;
  border: 1px solid rgba(244, 223, 196, 0.18);
  border-radius: 999px;
  background: rgba(18, 16, 15, 0.58);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(18px) saturate(120%);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  transform: translateX(-50%);
}

.volume-slider {
  display: block;
  width: 116px;
  height: 12px;
  margin: 56px 0 0 -40px;
  accent-color: #f6f3ef;
  cursor: pointer;
  transform: rotate(-90deg);
  transform-origin: 58px 6px;
}

#content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  max-height: 100vh;
  padding: 24px 18px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.narration {
  font-family: var(--narrative-font);
  font-style: italic;
  font-size: 20px;
  line-height: 1.4;
  color: var(--text);
  background: var(--narration-bg);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 18px 20px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.32);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(14px) saturate(115%);
  -webkit-backdrop-filter: blur(14px) saturate(115%);
  max-height: 24vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.narration.ending {
  max-height: 22vh;
}

.bubble {
  max-width: 90%;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 16px;
  line-height: 1.35;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  max-height: 24vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.bubble.mark {
  align-self: flex-start;
  background: var(--mark-bg);
}

.bubble.player {
  align-self: flex-end;
  background: var(--player-bg);
}

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

.button {
  width: 100%;
  border: none;
  border-radius: 18px;
  padding: 16px 18px;
  font-size: 16px;
  font-family: var(--ui-font);
  background: var(--choice-bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  box-shadow: var(--panel-shadow);
  border: 1px solid var(--choice-border);
  font-weight: 600;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button:hover,
.button:focus-visible {
  background: var(--choice-bg-hover);
  transform: translateY(-1px);
  box-shadow: 0 24px 44px rgba(0, 0, 0, 0.38);
}

.button:active {
  transform: translateY(1px) scale(0.995);
}

.button.primary {
  background: var(--primary-bg);
  color: var(--button-text-dark);
  text-align: center;
  border-color: rgba(255, 244, 223, 0.42);
}

.button.primary:hover,
.button.primary:focus-visible {
  background: var(--primary-bg-hover);
}

.share-card {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.4;
  text-shadow: var(--shadow);
}

.meta {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(246, 243, 239, 0.6);
}

.share-status {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
  text-align: center;
}

.share-status.error {
  color: #f2b7b7;
}

.vk-debug {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--ui-font);
}

.vk-debug-toggle {
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  background: rgba(15, 17, 22, 0.85);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.vk-debug-panel {
  width: min(360px, 90vw);
  max-height: 50vh;
  background: rgba(10, 12, 16, 0.92);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vk-debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.vk-debug-actions {
  display: flex;
  gap: 6px;
}

.vk-debug-btn {
  border: none;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  background: rgba(225, 206, 176, 0.92);
  color: #231f18;
  cursor: pointer;
}

.vk-debug-list {
  margin: 0;
  padding: 8px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (min-width: 768px) {
  #content {
    padding-bottom: 36px;
  }

  .narration {
    font-size: 22px;
    padding: 20px 24px;
  }
}
