    :root {
      --bg1: #07111d;
      --bg2: #10243b;
      --panel: rgba(13, 24, 38, 0.82);
      --panel-strong: rgba(16, 31, 50, 0.95);
      --line: rgba(255, 255, 255, 0.12);
      --text: #eef4ff;
      --sub: #b6c4df;
      --accent: #6ed1ff;
      --ok: #64dc9d;
      --warn: #ffb25c;
      --danger: #ff7d91;
      --shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
      --tube-width: 74px;
      --tube-height: 290px;
      --cell-gap: 2px;
      --cell-height: 60px;
    }

    * { box-sizing: border-box; }

    body {
      margin: 0;
      min-height: 100vh;
      font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
      color: var(--text);
      background:
        radial-gradient(circle at top, rgba(49, 102, 173, 0.35), transparent 38%),
        linear-gradient(180deg, #102845 0%, #08111d 55%, #050b13 100%);
    }

    .page {
      width: min(1320px, 100%);
      margin: 0 auto;
      padding: 20px 18px 28px;
    }

    .hero {
      background: linear-gradient(180deg, rgba(22, 42, 67, 0.92), rgba(10, 17, 28, 0.92));
      border: 1px solid var(--line);
      border-radius: 22px;
      padding: 18px 20px 16px;
      box-shadow: var(--shadow);
      backdrop-filter: blur(8px);
    }

    .hero h1 {
      margin: 0 0 8px;
      font-size: clamp(24px, 3vw, 36px);
      line-height: 1.15;
    }

    .hero p {
      margin: 8px 0 0;
      color: var(--sub);
      line-height: 1.7;
      font-size: 14px;
    }

    .layout {
      display: grid;
      grid-template-columns: minmax(0, 1fr) 340px;
      gap: 18px;
      margin-top: 18px;
      align-items: start;
    }

    .panel {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 20px;
      box-shadow: var(--shadow);
      backdrop-filter: blur(8px);
    }

    .workspace {
      padding: 16px;
    }

    .sidebar {
      padding: 16px;
      position: sticky;
      top: 16px;
    }

    .section-title {
      margin: 0 0 10px;
      font-size: 16px;
      color: #fff;
      letter-spacing: 0.02em;
    }

    .toolbar {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      margin-bottom: 16px;
    }

    button {
      appearance: none;
      border: 1px solid transparent;
      border-radius: 12px;
      padding: 10px 14px;
      font: inherit;
      font-size: 14px;
      font-weight: 700;
      color: #fff;
      cursor: pointer;
      transition: transform 0.12s ease, opacity 0.12s ease, border-color 0.12s ease, background 0.12s ease;
    }

    button:hover { transform: translateY(-1px); }
    button:disabled {
      opacity: 0.45;
      cursor: not-allowed;
      transform: none;
    }

    .btn-primary { background: linear-gradient(180deg, #2c9ef6, #136bcb); }
    .btn-secondary { background: linear-gradient(180deg, #42546c, #2b3646); }
    .btn-warn { background: linear-gradient(180deg, #f0a44b, #d77b17); }
    .btn-danger { background: linear-gradient(180deg, #ef6d82, #cb425a); }
    .btn-ok { background: linear-gradient(180deg, #4dd797, #21a56a); }
    .btn-ghost {
      background: rgba(255, 255, 255, 0.05);
      border-color: var(--line);
      color: var(--text);
    }

    .status-row {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 10px;
      margin-bottom: 16px;
    }

    .stat {
      background: rgba(255, 255, 255, 0.05);
      border: 1px solid var(--line);
      border-radius: 16px;
      padding: 12px;
      min-height: 82px;
    }

    .stat .label {
      font-size: 12px;
      color: var(--sub);
      margin-bottom: 6px;
    }

    .stat .value {
      font-size: 18px;
      font-weight: 800;
      line-height: 1.3;
    }

    .editor-box,
    .info-box,
    .log-box {
      background: rgba(255, 255, 255, 0.04);
      border: 1px solid var(--line);
      border-radius: 18px;
      padding: 14px;
    }

    .editor-top {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
      margin-bottom: 12px;
      flex-wrap: wrap;
    }

    .small-note {
      color: var(--sub);
      font-size: 13px;
      line-height: 1.6;
    }

    .palette {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
      gap: 10px;
      margin-top: 12px;
    }

    .token-btn {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      min-height: 48px;
      border-radius: 14px;
      border: 2px solid transparent;
      background: rgba(255, 255, 255, 0.06);
      padding: 8px 10px;
      color: #fff;
    }

    .token-btn.selected {
      border-color: #fff;
      box-shadow: 0 0 0 3px rgba(110, 209, 255, 0.28);
    }

    .token-chip {
      width: 26px;
      height: 26px;
      border-radius: 999px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      color: #fff;
      font-size: 16px;
      font-weight: 900;
      text-shadow: 0 1px 1px rgba(0,0,0,0.25);
      border: 1px solid rgba(255,255,255,0.32);
      box-shadow: inset 0 1px 0 rgba(255,255,255,0.24);
      flex: 0 0 auto;
    }

    .board {
      margin-top: 18px;
      padding: 18px 12px 8px;
      border-radius: 22px;
      background:
        linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.02)),
        radial-gradient(circle at top, rgba(110, 209, 255, 0.09), transparent 42%);
      border: 1px solid var(--line);
      overflow-x: auto;
    }

    .tube-grid {
      display: grid;
      grid-template-columns: repeat(6, var(--tube-width));
      gap: 24px 18px;
      align-items: start;
      justify-items: center;
      justify-content: center;
      width: fit-content;
      margin: 0 auto;
      min-width: 100%;
    }

    .tube-wrap {
      width: 100%;
      max-width: 96px;
      text-align: center;
    }

    .tube-number {
      font-size: 12px;
      color: var(--sub);
      margin-bottom: 6px;
      letter-spacing: 0.04em;
    }

    .tube {
      position: relative;
      width: var(--tube-width);
      height: var(--tube-height);
      margin: 0 auto;
      padding: 8px 8px 12px;
      border-radius: 0 0 26px 26px;
      border: 3px solid rgba(238, 244, 255, 0.65);
      border-top-width: 5px;
      background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.05));
      box-shadow:
        inset 12px 0 12px rgba(255,255,255,0.05),
        inset -8px 0 10px rgba(0,0,0,0.18),
        0 14px 24px rgba(0,0,0,0.24);
      cursor: pointer;
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      gap: var(--cell-gap);
      transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
    }

    .tube::before {
      content: "";
      position: absolute;
      top: -8px;
      left: -5px;
      right: -5px;
      height: 12px;
      border-radius: 12px;
      background: linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0.08));
      border: 2px solid rgba(255,255,255,0.58);
    }

    .tube:hover { transform: translateY(-2px); }

    .tube.selected {
      border-color: #ff5c73;
      box-shadow:
        inset 12px 0 12px rgba(255,255,255,0.05),
        inset -8px 0 10px rgba(0,0,0,0.18),
        0 0 0 4px rgba(255, 92, 115, 0.24),
        0 16px 30px rgba(0,0,0,0.28);
    }

    .tube.complete {
      border-color: rgba(100, 220, 157, 0.95);
      box-shadow:
        inset 12px 0 12px rgba(255,255,255,0.05),
        inset -8px 0 10px rgba(0,0,0,0.18),
        0 0 0 4px rgba(100, 220, 157, 0.16),
        0 16px 30px rgba(0,0,0,0.28);
    }

    .cell {
      position: relative;
      height: var(--cell-height);
      border-radius: 12px 12px 8px 8px;
      border: 1px dashed rgba(255,255,255,0.15);
      background: rgba(255,255,255,0.03);
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      user-select: none;
    }

    .cell.editable:hover {
      border-color: rgba(110, 209, 255, 0.8);
      background: rgba(110, 209, 255, 0.12);
    }

    .liquid {
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 30px;
      font-weight: 900;
      color: white;
      text-shadow: 0 2px 5px rgba(0,0,0,0.28);
      border-top: 1px solid rgba(255,255,255,0.15);
    }

    .liquid::before {
      content: "";
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      height: 14px;
      background: linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0));
      pointer-events: none;
    }

    .hint-bar {
      margin-top: 12px;
      padding: 12px 14px;
      border-radius: 14px;
      background: rgba(255,255,255,0.05);
      border: 1px solid var(--line);
      color: var(--sub);
      line-height: 1.65;
      font-size: 13px;
    }

    .log-box {
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    .log-header-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      flex-wrap: wrap;
    }

    .log-header-row .section-title {
      margin: 0;
    }

    .log-actions {
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
      justify-content: flex-end;
    }

    .log-undo-btn,
    .log-reset-btn {
      flex: 0 0 auto;
    }

    .download-area {
      display: flex;
      flex-direction: column;
      gap: 8px;
      padding: 10px 12px;
      border-radius: 14px;
      background: rgba(100, 220, 157, 0.08);
      border: 1px solid rgba(100, 220, 157, 0.24);
    }

    .download-area.hidden {
      display: none;
    }

    .download-area .small-note {
      margin: 0;
    }

    .log-list {
      display: flex;
      flex-direction: column;
      gap: 8px;
      max-height: 52vh;
      overflow: auto;
      padding-right: 4px;
    }

    .log-item {
      width: 100%;
      text-align: left;
      background: rgba(255,255,255,0.05);
      border: 1px solid rgba(255,255,255,0.08);
      border-radius: 14px;
      padding: 10px 12px;
      color: var(--text);
      font-weight: 600;
      line-height: 1.5;
    }

    .log-item.active {
      border-color: rgba(110, 209, 255, 0.88);
      background: rgba(110, 209, 255, 0.13);
    }

    .empty-log {
      color: var(--sub);
      font-size: 13px;
      line-height: 1.6;
      padding: 4px 2px;
    }

    .status-box {
      margin-top: 14px;
      padding: 12px 14px;
      border-radius: 16px;
      border: 1px solid var(--line);
      background: rgba(255,255,255,0.05);
      line-height: 1.65;
      min-height: 70px;
      font-size: 14px;
    }

    .status-box.ok { border-color: rgba(100, 220, 157, 0.45); }
    .status-box.warn { border-color: rgba(240, 164, 75, 0.45); }
    .status-box.info { border-color: rgba(110, 209, 255, 0.45); }
    .status-box.danger { border-color: rgba(255, 125, 145, 0.45); }

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

    .legend-item {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 8px 10px;
      border-radius: 12px;
      background: rgba(255,255,255,0.04);
      border: 1px solid rgba(255,255,255,0.08);
      font-size: 13px;
      color: var(--sub);
    }

    .footer-note {
      margin-top: 14px;
      font-size: 12px;
      color: var(--sub);
      line-height: 1.7;
    }

    @media (max-width: 1080px) {
      .layout { grid-template-columns: 1fr; }
      .sidebar { position: static; }
      .status-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }

    @media (max-width: 640px) {
      .page { padding: 12px; }
      .hero, .workspace, .sidebar { padding: 14px; }
      .status-row { grid-template-columns: 1fr; }
      :root {
        --tube-width: 66px;
        --tube-height: 260px;
        --cell-height: 53px;
      }
      .tube-grid {
        grid-template-columns: repeat(6, var(--tube-width));
      }
    }
