* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  position: fixed;
  inset: 0;
}

/* 発光エリア */
.light {
  position: fixed;
  inset: 0;
  background: #ff3030;
  transition: background-color 120ms linear;
  z-index: 0;
  will-change: background-color, opacity;
}

/* 操作パネル */
.controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 12px calc(env(safe-area-inset-bottom, 0px) + 10px);
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
  transition: opacity 400ms ease, transform 400ms ease;
}

.controls.dimmed {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

/* セクション */
.panel-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 4px;
  border-radius: 10px;
  transition: opacity 200ms ease, background-color 200ms ease;
}

.panel-section.active {
  background: rgba(255, 255, 255, 0.06);
}

.panel-section:not(.active) {
  opacity: 0.55;
}

.section-title {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
}

.panel-section.active .section-title {
  color: #fff;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

/* 色ボタン */
.color-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  padding: 0;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.color-btn[aria-checked="true"] {
  border-color: #fff;
  transform: scale(1.15);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

/* モードボタン */
.mode-btn, .sub-btn, .action-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 18px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.mode-btn[aria-checked="true"], .sub-btn[aria-checked="true"] {
  background: rgba(255, 255, 255, 0.85);
  color: #111;
  border-color: #fff;
}

.action-btn[aria-pressed="true"] {
  background: rgba(255, 220, 100, 0.85);
  color: #111;
  border-color: #fff;
}

.mode-btn:active, .sub-btn:active, .action-btn:active {
  transform: scale(0.96);
}

/* 戻るボタン（左上） */
.back-btn {
  position: fixed;
  left: calc(env(safe-area-inset-left, 0px) + 12px);
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  width: 44px;
  height: 44px;
  border-radius: 22px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  font-size: 22px;
  line-height: 42px;
  text-align: center;
  text-decoration: none;
  z-index: 11;
  transition: opacity 400ms ease, transform 400ms ease;
  -webkit-tap-highlight-color: transparent;
}

.back-btn.dimmed {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}

/* パネル非表示時に表示する小ボタン */
.show-controls-btn {
  position: fixed;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  width: 44px;
  height: 44px;
  border-radius: 22px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  font-size: 20px;
  z-index: 11;
  display: none;
  cursor: pointer;
}

.show-controls-btn.visible {
  display: block;
}

/* モーダル */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.modal-content {
  position: relative;
  max-width: 460px;
  width: calc(100% - 32px);
  max-height: 80vh;
  overflow: auto;
  background: #1a1a1a;
  color: #fff;
  border-radius: 14px;
  padding: 18px 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.modal-content h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.help-intro {
  margin: 0 0 10px;
  padding: 10px 12px;
  background: rgba(255, 220, 100, 0.08);
  border-left: 3px solid rgba(255, 220, 100, 0.7);
  border-radius: 6px;
  font-size: 13.5px;
  line-height: 1.7;
  color: #f4ead0;
}

.help-intro-survey {
  background: rgba(120, 180, 255, 0.08);
  border-left-color: rgba(120, 180, 255, 0.7);
  color: #dceaff;
  margin-bottom: 14px;
}

.swatch {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  border-radius: 50%;
  vertical-align: -0.1em;
  margin: 0 2px 0 1px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.swatch-red    { background: #ff2030; }
.swatch-yellow { background: #ffe800; }
.swatch-blue   { background: #1860ff; }

.help-section-title {
  margin: 14px 0 6px;
  font-size: 14px;
  color: #ffd57a;
  border-bottom: 1px solid rgba(255, 213, 122, 0.25);
  padding-bottom: 3px;
}

.help-subtitle {
  margin: 10px 0 4px;
  font-size: 13px;
  font-weight: 600;
  color: #ffe9c0;
}

.help-text {
  margin: 0 0 8px;
  font-size: 13.5px;
  line-height: 1.7;
}

.help-steps {
  margin: 0 0 10px;
  padding-left: 22px;
  line-height: 1.65;
  font-size: 13px;
}

.help-steps li {
  margin-bottom: 2px;
}

.modal-content ul {
  margin: 0 0 6px;
  padding-left: 20px;
  line-height: 1.7;
  font-size: 14px;
}

.modal-content li {
  margin-bottom: 4px;
}

.close-btn {
  background: rgba(255, 255, 255, 0.85);
  color: #111;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  display: block;
  margin: 0 auto;
}

.qr-wrap {
  display: flex;
  justify-content: center;
  margin: 6px 0 14px;
}

.qr-code {
  width: 180px;
  height: 180px;
  max-width: 60vw;
  max-height: 60vw;
  background: #fff;
  border-radius: 8px;
  padding: 8px;
  object-fit: contain;
}

.qr-code:not([src]),
.qr-code[src=""] {
  background: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.08) 8px,
    rgba(255, 255, 255, 0.16) 8px,
    rgba(255, 255, 255, 0.16) 16px
  );
}

.legal-link-wrap {
  margin: 14px 0 0;
  text-align: center;
}

.legal-link {
  color: rgba(255, 255, 255, 0.65);
  font-size: 12px;
  text-decoration: underline;
}

.legal-link:hover {
  color: #fff;
}

@media (max-height: 480px) {
  .controls { padding: 6px 10px calc(env(safe-area-inset-bottom, 0px) + 6px); gap: 6px; }
  .panel-section { padding: 4px 4px; gap: 4px; }
  .section-title { font-size: 10px; }
  .color-btn { width: 28px; height: 28px; }
  .mode-btn, .sub-btn, .action-btn { padding: 5px 10px; font-size: 12px; }
}
