﻿/* Phone controls float over the stage. Touch areas are larger than the glyphs. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.game-more-button, .game-more-panel, .mobile-scene-shade, .mobile-match {
  display: none;
}

body:is(.portrait, .touch-landscape) {
  --hud-top: env(safe-area-inset-top, 0px);
  --hud-bottom: env(safe-area-inset-bottom, 0px);
  --hud-left: max(16px, env(safe-area-inset-left));
  --hud-right: max(16px, env(safe-area-inset-right));
  --mobile-ink: #eee8db;
  --mobile-muted: #bdc3bb;
  --mobile-accent: #ddc18e;
}
body.forced-landscape {
  position: fixed;
  left: 100vw;
  top: 0;
  width: var(--game-width);
  height: var(--game-height);
  transform: rotate(90deg);
  transform-origin: 0 0;
  --hud-top: 0px;
  --hud-bottom: 0px;
  --hud-left: max(16px, env(safe-area-inset-top));
  --hud-right: max(16px, env(safe-area-inset-bottom));
}
.forced-landscape .app, .forced-landscape .game { width: 100%; height: 100%; }
.forced-landscape .settings-box {
  max-height: calc(var(--game-height) - 24px);
  width: min(410px, calc(var(--game-width) - 24px));
}

:is(.portrait, .touch-landscape) .game {
  background: #0b1318;
  isolation: isolate;
}
:is(.portrait, .touch-landscape) .game #canvas,
:is(.portrait, .touch-landscape) .game #lightScene {
  left: 0;
  top: 0;
  bottom: auto;
  width: 100%;
  height: 100%;
  transform: none;
}
.portrait .game #canvas, .portrait .game #lightScene {
  top: calc(58px + var(--hud-top));
  height: calc(100% - 88px - var(--hud-top) - var(--hud-bottom));
}
:is(.portrait, .touch-landscape) .mobile-scene-shade {
  position: absolute;
  display: block;
  inset: 0;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 90% 87%, #0b131bd9, #0b131b81 30%, transparent 72%);
  transition: opacity .23s ease;
}
:is(.portrait, .touch-landscape) .tools-open .mobile-scene-shade { opacity: 1; }

:is(.portrait, .touch-landscape) .topbar {
  top: calc(10px + var(--hud-top));
  left: var(--hud-left);
  right: var(--hud-right);
  display: grid;
  grid-template-columns: auto auto 1fr 44px;
  grid-template-rows: minmax(24px, auto) 18px;
  gap: 0 9px;
  align-items: center;
  transition: opacity .22s ease;
}
:is(.portrait, .touch-landscape) #pause { grid-area: 1 / 4 / 3 / 5; }
:is(.portrait, .touch-landscape) .level-title {
  grid-area: 1 / 1 / 2 / 4;
  min-width: 0;
  max-width: none;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--mobile-ink);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .04em;
  text-shadow: 0 2px 6px #000b;
}
:is(.portrait, .touch-landscape) .timer {
  grid-area: 2 / 1;
  pointer-events: none;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
  color: var(--mobile-muted);
  font-size: 12px;
  font-weight: 500;
  text-shadow: 0 1px 5px #000b;
}
:is(.portrait, .touch-landscape) .progress-wrap {
  grid-area: 2 / 2;
  width: 42px;
  height: 2px;
  margin: 0;
  background: #ddc18e38;
  box-shadow: none;
}
:is(.portrait, .touch-landscape) .progress { background: var(--mobile-accent); box-shadow: none; }
:is(.portrait, .touch-landscape) .mobile-match {
  grid-area: 2 / 3;
  display: block;
  color: var(--mobile-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 5px #000b;
}
:is(.portrait, .touch-landscape) .game-actions { display: none; }
:is(.portrait, .touch-landscape) :is(.tools-open, .immersive) .topbar,
:is(.portrait, .touch-landscape) :is(.tools-open, .immersive) .instruction {
  opacity: 0;
}
:is(.portrait, .touch-landscape) .tools-open #pause { visibility: hidden; }

:is(.portrait, .touch-landscape) :is(.game-more-button, .game-more-panel button, .game #pause, .game #fineMode.active) {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  color: var(--tool-ink, var(--mobile-ink));
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  backdrop-filter: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
:is(.portrait, .touch-landscape) .game button:focus-visible { outline-color: var(--mobile-accent); }
:is(.portrait, .touch-landscape) :is(.game-more-button, .game-more-panel button, #pause) svg {
  width: 23px;
  height: 23px;
  flex: none;
  filter: drop-shadow(0 2px 4px #000c);
  transition: color .18s ease, filter .18s ease;
}
:is(.portrait, .touch-landscape) :is(.game-more-button, .game-more-panel button, #pause):active svg { scale: .87; }
:is(.portrait, .touch-landscape) .game-more-button {
  position: absolute;
  right: var(--hud-right);
  bottom: calc(14px + var(--hud-bottom));
  width: 54px;
  height: 54px;
  z-index: 4;
}
.game-more-button span {
  position: absolute;
  display: grid;
  place-items: center;
  inset: 0;
  transition: opacity .16s ease, transform .3s cubic-bezier(.2,.8,.25,1);
}
#gameMore svg { width: 26px; height: 26px; }
.mobile-menu-close { opacity: 0; transform: rotate(-65deg) scale(.6); }
.tools-open .mobile-menu-open { opacity: 0; transform: rotate(65deg) scale(.6); }
.tools-open .mobile-menu-close { opacity: 1; transform: rotate(0) scale(1); }

:is(.portrait, .touch-landscape) .game-more-panel {
  position: absolute;
  right: var(--hud-right);
  bottom: calc(70px + var(--hud-bottom));
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, 52px);
  gap: 5px 9px;
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0s .34s;
}
.touch-landscape .game-more-panel {
  right: calc(var(--hud-right) + 62px);
  bottom: calc(16px + var(--hud-bottom));
  grid-template-columns: repeat(4, 54px);
}
:is(.portrait, .touch-landscape) .tools-open .game-more-panel {
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}
:is(.portrait, .touch-landscape) .game-more-panel button {
  width: 100%;
  min-height: 49px;
  opacity: 0;
  transform: translateY(10px) scale(.9);
  transition: opacity .13s ease, transform .18s ease;
  transition-delay: calc((7 - var(--tool-index, 0)) * 17ms);
}
:is(.portrait, .touch-landscape) .tools-open .game-more-panel button {
  opacity: 1;
  transform: translateY(0) scale(1);
  transition-duration: .18s, .28s;
  transition-timing-function: ease, cubic-bezier(.2,.78,.25,1.12);
  transition-delay: calc(var(--tool-index, 0) * 24ms);
}
:is(.portrait, .touch-landscape) .game-more-panel button[aria-pressed="true"] { --tool-ink: var(--mobile-accent); }
:is(.portrait, .touch-landscape) .game-more-panel button[aria-pressed="true"] svg {
  filter: drop-shadow(0 1px 4px #000d) drop-shadow(0 0 6px #ddc18e60);
}
:is(.portrait, .touch-landscape) .tools-open .game-more-panel button:disabled { opacity: .48; }
.mobile-tool-label {
  color: inherit;
  font-size: 11px;
  line-height: 14px;
  white-space: nowrap;
  text-shadow: 0 1px 4px #000e, 0 2px 8px #000b;
}
.twist-indicator:not([hidden]) {
  display: inline-flex;
  align-items: center;
  position: absolute;
  z-index: 2;
  left: var(--hud-left, 16px);
  bottom: calc(51px + var(--hud-bottom, 0px));
  min-height: 44px;
  padding: 7px 12px;
  color: #e8d1a9;
  background: #14232bed;
  border: 1px solid #c5ab7355;
  border-radius: 12px;
  font-size: 12px;
}
#game:is(.tools-open, .immersive, .has-toast) .twist-indicator { visibility: hidden; }

:is(.portrait, .touch-landscape) .instruction {
  top: auto;
  bottom: calc(25px + var(--hud-bottom));
  left: var(--hud-left);
  right: calc(var(--hud-right) + 62px);
  width: auto;
  max-width: none;
  padding: 0;
  transform: none;
  font-size: 11px;
  line-height: 15px;
  text-align: left;
  color: var(--mobile-muted);
  text-shadow: 0 1px 5px #000d;
  background: none;
  border: 0;
  box-shadow: none;
  transition: opacity .22s ease;
}
:is(.portrait, .touch-landscape) .instruction b { color: var(--mobile-ink); }
:is(.portrait, .touch-landscape) .toast {
  z-index: 3;
  bottom: calc(68px + var(--hud-bottom));
  max-width: calc(var(--game-width, 100vw) - 32px);
  width: max-content;
  padding: 4px 8px;
  white-space: normal;
  background: none;
  border: 0;
  box-shadow: none;
  color: var(--mobile-ink);
  font-size: 12px;
  text-shadow: 0 1px 4px #000, 0 2px 8px #000;
  transition: opacity .22s ease, transform .22s ease;
  transform: translate(-50%, 7px);
}
:is(.portrait, .touch-landscape) .toast.show { transform: translate(-50%, 0); }
.touch-landscape .toast {
  left: var(--hud-left);
  bottom: calc(53px + var(--hud-bottom));
  transform: translateY(7px);
}
.touch-landscape .toast.show { transform: translateY(0); }
@keyframes mobile-note-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  #game :is(.topbar, .instruction, .game-more-panel, .game-more-panel button,
      .game-more-button span, .mobile-scene-shade, .toast) {
    transition: none;
    animation: none;
  }
}
