:root {
    --bg: #111217;
    --panel: #1a1c22;
    --accent: #3da9fc;
    --accent-soft: rgba(61,169,252,0.2);
    --border: #2a2d36;
    --text: #f5f5f7;
    --sub: #a9afc4;
  }
  * { box-sizing: border-box; }
  body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
      sans-serif;
    background: radial-gradient(circle at top, #1b2540, #050609 60%);
    color: var(--text);
  }
  h1 {
    font-size: 1.4rem;
    margin: 0 0 0.4rem;
  }
  h2 {
    font-size: 1rem;
    margin: 0 0 0.4rem;
  }
  .app {
    display: grid;
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    height: 100vh;
  }
  .sidebar {
    padding: 1rem 1.1rem 1.5rem;
    border-right: 1px solid var(--border);
    background: linear-gradient(180deg, #151824, #0b0c11 70%);
    overflow-y: auto;
    max-height: 100vh;
  }
  .sidebar section {
    margin-bottom: 1.2rem;
    padding: 0.8rem 0.8rem 0.9rem;
    border-radius: 0.75rem;
    background: rgba(8,10,18,0.85);
    border: 1px solid rgba(255,255,255,0.03);
  }
  .sidebar small {
    color: var(--sub);
    font-size: 0.75rem;
  }
  label {
    font-size: 0.8rem;
    color: var(--sub);
    display: block;
    margin-bottom: 0.2rem;
  }
  input[type="file"] {
    font-size: 0.75rem;
    width: 100%;
  }
  .row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-top: 0.35rem;
    flex-wrap: wrap;
  }
  button {
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.1);
    background: #151824;
    color: var(--text);
    font-size: 0.78rem;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: background 0.15s ease, transform 0.1s ease,
      box-shadow 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
  }
  button.primary {
    background: linear-gradient(135deg, #3da9fc, #7f5dff);
    border-color: transparent;
    box-shadow: 0 0 18px rgba(61,169,252,0.35);
  }
  button:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 12px rgba(0,0,0,0.5);
  }
  button.primary:hover {
    box-shadow: 0 0 22px rgba(61,169,252,0.6);
  }
  button.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-soft);
  }
  button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
  }
  input[type="range"] {
    width: 100%;
  }
  .pill {
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.06);
    font-size: 0.7rem;
    color: var(--sub);
  }
  .color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.4);
    background: #555;
  }
  .checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.35rem;
  }
  .checkbox-row input {
    width: 14px;
    height: 14px;
  }
  .text-input {
    width: 100%;
    padding: 0.25rem 0.45rem;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.12);
    background: #10121b;
    color: var(--text);
    font-size: 0.78rem;
  }

  .main {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    overflow: hidden;
  }
  .canvas-wrapper {
    position: relative;
    flex: 1;
    min-height: 0;
    border-radius: 1rem;
    border: 1px solid var(--border);
    overflow: hidden;
    background-size: 20px 20px;
    background-image: linear-gradient(45deg, #1c1e26 25%, transparent 25%),
      linear-gradient(-45deg, #1c1e26 25%, transparent 25%),
      linear-gradient(45deg, transparent 75%, #1c1e26 75%),
      linear-gradient(-45deg, transparent 75%, #1c1e26 75%);
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  }
  .canvas-inner {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: auto;
    touch-action: none; /* ピンチ操作を自前で扱う */
  }
  canvas {
    display: block;
    margin: 0 auto;
    image-rendering: auto;
  }
  #baseCanvas {
    position: relative;
    z-index: 1;
  }
  #overlayCanvas {
    position: absolute;
    top: 0;
    z-index: 2;
    pointer-events: auto;
  }

  .ring-cta {
    position: absolute;
    border-radius: 50%;
    border: 3px solid var(--accent);
    box-shadow: 0 0 12px rgba(61,169,252,0.7);
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 600;
    text-shadow: 0 0 8px rgba(0,0,0,0.8);
    pointer-events: none;
    z-index: 5;
    user-select: none;
    background: radial-gradient(circle at center,
      rgba(61,169,252,0.08) 0%,
      transparent 60%);
  }
  .ring-cta-label {
    pointer-events: none;
  }

  .status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--sub);
    padding: 0.1rem 0.25rem;
  }
  .status-bar span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
  }

  /* 十字キーUI（輪投げ用） */
  .dpad {
    margin-top: 0.6rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.18rem;
  }
  .dpad-row {
    display: flex;
    gap: 0.18rem;
    justify-content: center;
    min-height: 2.1rem;
  }
  .dpad-btn {
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    border-radius: 0.6rem;
    justify-content: center;
  }

  @media (max-width: 880px) {
    .app {
      grid-template-columns: 1fr;
    }
    .sidebar {
      border-right: none;
      border-bottom: 1px solid var(--border);
    }
  }

.ring-cta-label{display:none;}
