:root {
  --panel-bg: rgba(8, 15, 32, 0.54);
  --panel-border: rgba(255, 255, 255, 0.16);
  --text-main: rgba(245, 249, 255, 0.96);
  --text-sub: rgba(230, 239, 255, 0.74);
  --accent: #bcd8ff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #02040a;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "YuGothic", "Noto Sans JP", sans-serif;
  color: var(--text-main);
  touch-action: manipulation;
}

#app {
  position: relative;
  width: 100vw;
  height: 100svh;
  min-height: 100vh;
  overflow: hidden;
  isolation: isolate;
}

#bgImg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
  user-select: none;
}

/* 背景の夜空を少し締めるレイヤー。スライダーで濃さを変更 */
#nightVeil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 22%, rgba(90, 130, 190, 0.05), transparent 34%),
    linear-gradient(to bottom, rgba(0, 5, 18, 0.18), rgba(0, 0, 0, 0.05) 55%, rgba(0, 0, 0, 0.22));
  opacity: 0.55;
  z-index: 1;
  pointer-events: none;
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.brand {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: max(22px, env(safe-area-inset-left));
  z-index: 5;
  text-shadow: 0 0 18px rgba(0, 0, 0, 0.55), 0 0 18px rgba(170, 210, 255, 0.14);
  user-select: none;
  pointer-events: none;
}

.brand h1 {
  font-size: clamp(18px, 2.4vw, 28px);
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: 0.09em;
}

.brand p {
  margin-top: 7px;
  font-size: clamp(11px, 1.4vw, 14px);
  color: var(--text-sub);
  letter-spacing: 0.08em;
}

.hint {
  position: absolute;
  left: max(22px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 5;
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  letter-spacing: 0.03em;
  user-select: none;
  transition: opacity 0.25s ease;
}

.console {
  position: absolute;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  width: min(360px, calc(100vw - 32px));
  z-index: 10;
  border-radius: 22px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  overflow: hidden;
  transition: transform 0.28s ease, opacity 0.28s ease;
}

.console.collapsed {
  transform: translateY(calc(100% - 58px));
}

.consoleRestore {
  display: none;
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 20;
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  color: var(--text-main);
  font-size: 13px;
  letter-spacing: 0.06em;
  cursor: pointer;
  touch-action: manipulation;
}

.consoleRestore.visible {
  display: block;
}

.consoleHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  cursor: default;
  user-select: none;
}

.consoleTitle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cfe4ff;
  box-shadow: 0 0 12px rgba(190, 220, 255, 0.95), 0 0 28px rgba(100, 160, 255, 0.32);
  flex: 0 0 auto;
}

.console h2 {
  font-size: 15px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: 0.07em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.collapseBtn {
  flex: 0 0 auto;
  width: 34px;
  height: 30px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  font-size: 14px;
}

.consoleBody {
  padding: 14px 16px 16px;
}

.controlGroup {
  margin-bottom: 14px;
}

.labelRow {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 7px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.88);
}

.value {
  color: #d9eaff;
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

input[type="range"] {
  width: 100%;
  height: 22px;
  accent-color: var(--accent);
  cursor: pointer;
}

.buttonGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 12px;
}

button {
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.92);
  border-radius: 13px;
  padding: 10px 10px;
  font-size: 12px;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

button:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.24);
}

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

button.primary {
  grid-column: 1 / -1;
  background: rgba(175, 210, 255, 0.14);
  border-color: rgba(195, 225, 255, 0.25);
}

.statusBox {
  margin-top: 13px;
  padding: 10px 11px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.20);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  line-height: 1.7;
}

.statusBox span {
  color: rgba(225, 240, 255, 0.96);
}

.tiny {
  margin-top: 9px;
  color: rgba(255, 255, 255, 0.52);
  font-size: 10.5px;
  line-height: 1.55;
}

@media (max-width: 780px) {
  .brand {
    top: max(13px, env(safe-area-inset-top));
    left: max(14px, env(safe-area-inset-left));
  }

  .brand p {
    max-width: 260px;
  }

  .hint {
    display: none;
  }

  .console {
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    width: auto;
  }

  .consoleBody {
    padding: 12px 14px 14px;
  }
}
