html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.toolbar {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: flex-start;
  gap: clamp(4px, 0.8vw, 12px);
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 0 0;
  box-sizing: border-box;
  pointer-events: none;
}

.toolbar .tool-wrap {
  position: relative;
  pointer-events: none;
  line-height: 0;
}

.toolbar .tool-wrap .tool {
  position: relative;
  z-index: 2;
}

.toolbar .vol-panel {
  position: absolute;
  z-index: 1;
  top: calc(100% - 10px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 58px;
  padding: 18px 8px 10px;
  box-sizing: border-box;
  border-radius: 18px;
  pointer-events: auto;
  background:
    radial-gradient(circle at 30% 18%, rgba(120, 190, 210, 0.28), transparent 52%),
    linear-gradient(180deg, #3a444c 0%, #1a2126 42%, #101416 100%);
  box-shadow:
    0 14px 28px rgba(0, 0, 0, 0.55),
    inset 0 0 0 2px rgba(150, 176, 186, 0.45),
    inset 0 0 16px rgba(70, 210, 230, 0.16);
  animation: vol-panel-in 0.16s ease;
}

.toolbar .vol-panel[hidden] {
  display: none;
}

.toolbar .vol-slider {
  position: relative;
  width: 28px;
  height: min(132px, 26vh);
  touch-action: none;
  cursor: ns-resize;
}

.toolbar .vol-groove {
  position: absolute;
  left: 50%;
  top: 11px;
  bottom: 11px;
  width: 10px;
  transform: translateX(-50%);
  border-radius: 6px;
  overflow: hidden;
  background: #0b0e11;
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(130, 220, 235, 0.28);
}

.toolbar .vol-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  background: linear-gradient(180deg, #e7fbff 0%, #3ee7ff 30%, #6d7bff 72%, #c06bff 100%);
  box-shadow: 0 0 10px rgba(80, 220, 255, 0.75);
}

.toolbar .vol-thumb {
  position: absolute;
  left: 50%;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #f4ffff 0%, #67e7ff 38%, #6a4cff 78%);
  box-shadow:
    0 0 10px rgba(90, 220, 255, 0.95),
    0 2px 4px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.toolbar .vol-readout {
  font-family: Palatino, "Palatino Linotype", serif;
  font-size: 13px;
  line-height: 1;
  letter-spacing: 0.04em;
  color: rgba(214, 246, 255, 0.92);
  text-shadow: 0 0 8px rgba(80, 210, 255, 0.85);
  pointer-events: none;
  user-select: none;
}

.toolbar .vol-slider:focus-visible {
  outline: 2px solid rgba(140, 230, 255, 0.9);
  outline-offset: 3px;
  border-radius: 10px;
}

.toolbar .tool[data-tool="sound"].is-hint,
.toolbar .tool[data-tool="tale"].is-hint {
  animation: sound-hint 1s ease-in-out 5;
}

.toolbar .tool[data-tool="sound"].is-hint img,
.toolbar .tool[data-tool="tale"].is-hint img {
  animation: sound-hint-img 1s ease-in-out 5;
}

@keyframes sound-hint {
  0%, 100% {
    transform: scale(1);
    filter:
      drop-shadow(0 8px 14px rgba(0, 0, 0, 0.55))
      drop-shadow(0 0 4px rgba(110, 230, 255, 0.2));
  }
  50% {
    transform: scale(1.08);
    filter:
      drop-shadow(0 10px 16px rgba(0, 0, 0, 0.5))
      drop-shadow(0 0 10px rgba(140, 245, 255, 1))
      drop-shadow(0 0 22px rgba(70, 190, 255, 0.9))
      drop-shadow(0 0 36px rgba(190, 90, 255, 0.75));
  }
}

@keyframes sound-hint-img {
  0%, 100% {
    filter: grayscale(0.45) brightness(0.85) saturate(0.7);
  }
  50% {
    filter: grayscale(0) brightness(1.28) saturate(1.2);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toolbar .vol-panel {
    animation: none;
  }

  .toolbar .tool[data-tool="sound"].is-hint,
  .toolbar .tool[data-tool="sound"].is-hint img,
  .toolbar .tool[data-tool="tale"].is-hint,
  .toolbar .tool[data-tool="tale"].is-hint img {
    animation: none;
  }

  .toolbar .tool[data-tool="sound"].is-hint,
  .toolbar .tool[data-tool="tale"].is-hint {
    filter:
      drop-shadow(0 8px 14px rgba(0, 0, 0, 0.55))
      drop-shadow(0 0 14px rgba(120, 235, 255, 0.95))
      drop-shadow(0 0 28px rgba(180, 90, 255, 0.7));
  }

  .toolbar .tool[data-tool="sound"].is-hint img,
  .toolbar .tool[data-tool="tale"].is-hint img {
    filter: grayscale(0) brightness(1.15) saturate(1.05);
  }
}

@keyframes vol-panel-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.toolbar .tool {
  pointer-events: auto;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  line-height: 0;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.55));
  transition: transform 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.toolbar .tool img {
  display: block;
  height: clamp(64px, 9vh, 108px);
  width: auto;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

@media (hover: hover) and (pointer: fine) {
  .toolbar .tool:hover {
    transform: translateY(-2px) scale(1.035);
  }

  .toolbar .tool:hover img {
    filter: brightness(1.14);
  }

  .toolbar .tool.is-off:hover img {
    filter: grayscale(0.7) brightness(0.72) saturate(0.55);
  }

  .toolbar .tool:disabled:hover {
    transform: none;
  }

  .toolbar .tool:disabled:hover img {
    filter: none;
  }
}

.toolbar .tool:active {
  transform: translateY(1px) scale(0.98);
}

.toolbar .tool.is-off img {
  filter: grayscale(0.9) brightness(0.58) saturate(0.4);
}

.toolbar .tool:focus-visible {
  outline: 2px solid rgba(140, 230, 255, 0.9);
  outline-offset: 3px;
  border-radius: 8px;
}

.toolbar .tool:disabled {
  cursor: default;
  pointer-events: none;
}

.toolbar .tool:disabled:active {
  transform: none;
}

html[data-age="18"] .toolbar .tool[data-tool="age"] .age-0,
html:not([data-age="18"]) .toolbar .tool[data-tool="age"] .age-18 {
  display: none;
}

[data-age-copy="18"] {
  display: none;
}

html[data-age="18"] [data-age-copy="0"] {
  display: none;
}

html[data-age="18"] [data-age-copy="18"] {
  display: block;
}

html[data-age="18"] .redhat span,
html[data-age="18"] .home span {
  background: linear-gradient(90deg, #ff1a1a 0%, #ffd4d4 38%, #f0d0d0 62%, #000000 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 4px rgba(160, 0, 0, 0.55)) drop-shadow(0 0 8px rgba(0, 0, 0, 0.8)) drop-shadow(0 1px 1px rgba(0, 0, 0, 0.85));
}

@media (max-width: 720px), (max-height: 520px) {
  .toolbar {
    gap: 2px;
  }

  .toolbar .tool img {
    height: clamp(44px, 11vmin, 64px);
  }
}

.rotate-gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin: 0;
  padding:
    max(24px, env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
  box-sizing: border-box;
  background: rgba(2, 8, 7, 0.84);
  text-align: center;
  -webkit-user-select: none;
  user-select: none;
}

@media (orientation: portrait) and (pointer: coarse) {
  html.tale-page .book,
  html.tale-page .home,
  html.tale-page .toolbar {
    visibility: hidden;
  }

  html.tale-page .rotate-gate {
    display: flex;
  }
}

.rotate-phone {
  position: relative;
  width: 74px;
  height: 120px;
  border: 3px solid rgba(190, 246, 255, 0.92);
  border-radius: 16px;
  box-shadow:
    0 0 12px rgba(70, 220, 255, 0.7),
    0 0 28px rgba(180, 80, 255, 0.45);
  animation: rotate-phone 2.4s ease-in-out infinite;
}

.rotate-phone::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  width: 28px;
  height: 5px;
  margin-left: -14px;
  border-radius: 4px;
  background: rgba(190, 246, 255, 0.85);
}

.rotate-phone::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 22px;
  bottom: 12px;
  border-radius: 4px;
  background: linear-gradient(160deg, rgba(62, 231, 255, 0.4), rgba(224, 107, 255, 0.32));
}

@keyframes rotate-phone {
  0%, 35% { transform: rotate(0deg); }
  65%, 100% { transform: rotate(90deg); }
}

.rotate-title {
  margin: 0;
  font-family: "Cinzel Decorative", Palatino, "Palatino Linotype", serif;
  font-size: clamp(22px, 6.4vw, 36px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.04em;
  background: linear-gradient(90deg, #3ee7ff 0%, #d9fbff 42%, #e06bff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 8px rgba(70, 220, 255, 0.55));
}

.rotate-note {
  margin: 0;
  max-width: 18em;
  font-family: Literata, Palatino, "Palatino Linotype", Georgia, serif;
  font-size: 17px;
  line-height: 1.45;
  color: rgba(214, 246, 255, 0.9);
}

@media (prefers-reduced-motion: reduce) {
  .rotate-phone {
    animation: none;
    transform: rotate(90deg);
  }
}

.loader {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: #020605 url("resources/nano-banana-1791393677251.png") center / cover no-repeat;
  transition: opacity 0.55s ease, visibility 0.55s ease;
}

.loader.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-bar {
  --tube-l: 21.51%;
  --tube-t: 46.09%;
  --tube-w: 58.79%;
  --tube-h: 8.72%;
  --p: 0;
  position: relative;
  width: min(920px, 94vw);
}

.loader-bar img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  pointer-events: none;
}

.loader-bar::before {
  content: "";
  position: absolute;
  inset: 22% 10%;
  background: radial-gradient(ellipse, rgba(70, 230, 255, 0.22), rgba(210, 80, 255, 0.1) 46%, transparent 72%);
  filter: blur(16px);
  animation: loader-aura 2.6s ease-in-out infinite;
  pointer-events: none;
}

.loader-veil,
.loader-shine,
.loader-bubbles {
  position: absolute;
  left: var(--tube-l);
  top: var(--tube-t);
  width: var(--tube-w);
  height: var(--tube-h);
  border-radius: 999px;
  pointer-events: none;
}

.loader-veil {
  --edge: clamp(0px, calc((1 - var(--p)) * 90px), 16px);
  background: #101114;
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.75),
    inset 0 -2px 4px rgba(255, 255, 255, 0.05);
  opacity: clamp(0, calc((1 - var(--p)) * 24), 1);
  -webkit-mask-image: linear-gradient(90deg, transparent calc(var(--p) * 100% - var(--edge)), #000 calc(var(--p) * 100%));
  mask-image: linear-gradient(90deg, transparent calc(var(--p) * 100% - var(--edge)), #000 calc(var(--p) * 100%));
}

.loader-shine {
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(var(--p) * 100% - 8px), transparent calc(var(--p) * 100%));
  mask-image: linear-gradient(90deg, #000 calc(var(--p) * 100% - 8px), transparent calc(var(--p) * 100%));
}

.loader-shine::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 28%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: loader-sweep 1.7s ease-in-out infinite;
}

.loader-shine::after {
  content: "";
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: calc(var(--p) * 100%);
  width: 18px;
  transform: translateX(-60%);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(160, 255, 255, 0.35) 42%, transparent 72%);
}

.loader-bubbles {
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(var(--p) * 100% - 8px), transparent calc(var(--p) * 100%));
  mask-image: linear-gradient(90deg, #000 calc(var(--p) * 100% - 8px), transparent calc(var(--p) * 100%));
}

.loader-bubbles i {
  position: absolute;
  bottom: -20%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 8px rgba(170, 255, 255, 0.9);
  animation: loader-bubble 2.2s linear infinite;
}

.loader-bubbles i:nth-child(1) { left: 12%; animation-duration: 2.1s; }
.loader-bubbles i:nth-child(2) { left: 28%; width: 5px; height: 5px; animation-duration: 2.6s; animation-delay: -0.8s; }
.loader-bubbles i:nth-child(3) { left: 46%; animation-duration: 1.9s; animation-delay: -1.2s; }
.loader-bubbles i:nth-child(4) { left: 63%; width: 4px; height: 4px; animation-duration: 2.4s; animation-delay: -0.4s; }
.loader-bubbles i:nth-child(5) { left: 78%; width: 6px; height: 6px; animation-duration: 2.8s; animation-delay: -1.6s; }

@keyframes loader-aura {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

@keyframes loader-sweep {
  from { left: -30%; }
  to { left: 110%; }
}

@keyframes loader-bubble {
  0% { transform: translateY(0) scale(0.7); opacity: 0; }
  18% { opacity: 0.9; }
  100% { transform: translateY(-320%) scale(0.45); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .loader-bar::before,
  .loader-shine::before,
  .loader-bubbles i {
    animation: none;
  }
}
