  * { margin: 0; padding: 0; box-sizing: border-box; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #1a1a2e;
    color: #eee;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
  }

  /* Top bar */
  #toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    flex-shrink: 0;
    flex-wrap: wrap;
  }
  #toolbar h1 { font-size: 16px; font-weight: 600; margin-right: 8px; }
  #toolbar button, #toolbar label {
    background: #0f3460;
    color: #eee;
    border: 1px solid #533483;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
  }
  #toolbar button:hover, #toolbar label:hover { background: #533483; }
  #toolbar button.active { background: #533483; border-color: #e94560; }
  #info-panel {
    font-size: 13px;
    margin-left: auto;
    display: flex;
    gap: 16px;
    align-items: center;
  }
  #info-panel span { white-space: nowrap; }

  /* Main area */
  #main { flex: 1; position: relative; overflow: hidden; }
  #canvas-area { position: absolute; inset: 0; overflow: hidden; }
  #grid-canvas {
    position: absolute;
    top: 0; left: 0;
    cursor: crosshair;
  }

  /* Direction popup */
  #direction-popup {
    display: none;
    position: absolute;
    z-index: 50;
    grid-template-columns: 32px 32px 32px;
    grid-template-rows: 32px 32px 32px;
    gap: 2px;
  }
  #direction-popup.visible { display: grid; }
  #direction-popup button {
    width: 32px; height: 32px;
    background: #0f3460;
    color: #eee;
    border: 1px solid #533483;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }
  #direction-popup button:hover { background: #533483; }
  #btn-clear-dot-visited { background: #8b0000; font-size: 12px; }
  #btn-clear-dot-visited:hover { background: #c0392b; }
  .dir-spacer { visibility: hidden; }

  /* Build order panels (shared styles) */
  .build-panel {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 260px;
    background: #16213e;
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 40;
  }
  .build-panel.visible { display: flex; }
  #build-panel { right: 0; border-left: 1px solid #0f3460; }
  #build-panel-left { left: 0; border-right: 1px solid #0f3460; }
  .build-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #0f3460;
    font-weight: 600;
    font-size: 14px;
  }
  .build-panel-header button {
    background: none;
    border: none;
    color: #aaa;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
  }
  .build-panel-header button:hover { color: #e94560; }
  .build-panel-info {
    padding: 8px 12px;
    font-size: 12px;
    color: #aaa;
    border-bottom: 1px solid #0f3460;
  }
  .build-panel-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
  }
  .build-run {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 14px;
  }
  .build-run-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.2);
  }
  .build-panel-footer {
    padding: 10px 12px;
    border-top: 1px solid #0f3460;
    text-align: center;
  }
  .btn-speak {
    background: #0f3460;
    color: #eee;
    border: 1px solid #533483;
    padding: 6px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
  }
  .btn-speak:hover { background: #533483; }

  #footer {
    text-align: center;
    padding: 4px;
    font-size: 11px;
    color: #555;
    background: #16213e;
    border-top: 1px solid #0f3460;
    flex-shrink: 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 101;
  }

  /* Import overlay */
  #import-overlay {
    position: absolute;
    inset: 0;
    background: rgba(26, 26, 46, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    z-index: 100;
    overflow-y: auto;
  }
  #import-overlay.hidden { display: none; }
  #toolbar.hidden { display: none; }
  #footer.hidden { display: none; }

  .homepage {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 900px;
    width: 100%;
    padding: 40px;
    margin: auto;
  }
  .homepage-title {
    font-size: 2rem;
    color: #fff;
    line-height: 1.3;
    text-align: center;
    margin-bottom: 10px;
  }
  .homepage-subtext {
    font-size: 0.95rem;
    color: #b0b0c0;
    line-height: 1.6;
    text-align: center;
    max-width: 640px;
    margin-bottom: 20px;
  }
  .backstory-pill {
    display: inline-block;
    padding: 8px 20px;
    font-size: 0.82rem;
    color: #d0c0e0;
    background: rgba(83, 52, 131, 0.35);
    border: 1px solid #533483;
    border-radius: 20px;
    text-decoration: none;
    margin-bottom: 32px;
    transition: all 0.2s;
  }
  .backstory-pill:hover { background: rgba(83, 52, 131, 0.6); color: #fff; }
  .homepage .screenshot {
    width: 100%;
    max-width: 800px;
    border-radius: 12px;
    box-shadow: 0 6px 30px rgba(0,0,0,0.5);
    margin-bottom: 36px;
  }
  .info-row {
    display: flex;
    gap: 32px;
    align-items: flex-start;
    width: 100%;
    max-width: 700px;
    margin-bottom: 36px;
  }
  .info-row .product-img {
    width: 120px;
    flex-shrink: 0;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  }
  .info-row .product-link {
    display: inline-block;
    color: #e94560;
    font-size: 0.82rem;
    text-decoration: none;
  }
  .info-row .product-link:hover { text-decoration: underline; }
  .info-text {
    flex: 1;
  }
  .info-text ul {
    list-style: none;
    padding: 0;
    margin-bottom: 12px;
  }
  .info-text ul li {
    padding: 7px 0;
    font-size: 0.9rem;
    color: #c0c0d0;
  }
  .info-text ul li::before {
    content: "✦ ";
    color: #e94560;
  }
  .homepage #drop-zone {
    width: 100%;
    max-width: 700px;
  }
  @media (max-width: 600px) {
    .homepage { padding: 40px 20px; }
    .info-row { flex-direction: column; align-items: center; text-align: center; }
    .homepage-title { font-size: 1.5rem; }
  }

  #drop-zone {
    border: 3px dashed #533483;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    transition: border-color 0.2s;
  }
  #drop-zone:hover { border-color: #e94560; }
  #drop-zone.dragover { border-color: #e94560; background: rgba(83, 52, 131, 0.2); }
  #drop-zone p { font-size: 16px; color: #aaa; }
  #drop-zone label {
    background: #533483;
    color: #fff;
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
  }
  #drop-zone label:hover { background: #e94560; }
  #file-input { display: none; }

