:root {
    --bg: #f9f9f9;
    --card: #fff;
    --text: #222;
    --muted: #666;
    --accent: #2962ff;
    --border: #ddd;
    --over: #ffebee;
    --under: #fffde7;
    --match: #e8f5e9;
  }
  
  * {
    box-sizing: border-box;
  }
  
  body {
    margin: 0;
    padding: 0;
    font-family: sans-serif;
    background: var(--bg);
    color: var(--text);
    max-width: 100%;
    overflow-x: hidden;
  }
  
  header {
    padding: 16px;
    text-align: center;
    background: var(--card);
    border-bottom: 1px solid var(--border);
  }
  
  header h1 {
    font-size: 20px; /* ← 好きなサイズに変更！ */
    margin: 0;
  }

  main {
    max-width: 640px;
    margin: 24px auto;
    padding: 0 16px;
  }
  
  #goal-section {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
  }
  
  #goal-section label {
    white-space: nowrap;
    font-size: 16px;
  }
  
  #goal-section input {
    width: 120px;
    height: 32px;
    font-size: 16px;
    padding: 4px;
  }
  
  #goal-section button {
    height: 32px;
    font-size: 16px;
    padding: 4px 8px;
    cursor: pointer;
  }
  
  form#item-form {
    display: grid;
    grid-template-columns: 1fr 120px 100px;
    gap: 8px;
    background: var(--card);
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 16px;
  }
  
  form input,
  form button {
    height: 40px;
    font-size: 16px;
    padding: 8px;
  }
  
  form button {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
  }
  
  #list-section {
    margin-top: 16px;
  }
  
  #item-list {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  
  .item {
    display: grid;
    grid-template-columns: 20px 1fr 50px 60px 60px 32px;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-bottom: 1px solid var(--border);
    background: var(--card);
  }
  
  .item.selected {
    background-color: #e3f2fd;
  }
  
  .item input.quantity,
  .item input.unit {
    width: 100%;
    height: 32px;
    font-size: 16px;
    padding: 4px;
  }
  
  .item input[type="text"] {
    font-size: 16px;
  }
  
  .item .subtotal {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    font-size: 16px;
  }
  
  .item .remove {
    height: 32px;
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    padding: 0;
    text-align: center;
  }
  
  #total-section {
    margin-top: 16px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
  }
  
  .total-row,
  .diff-row,
  .goal-row {
    display: flex;
    justify-content: space-between;
    font-size: 18px;
    margin-bottom: 8px;
  }
  
  footer.support {
    margin-top: 32px;
    padding: 16px;
    text-align: center;
    font-size: 14px;
    color: var(--muted);
  }
  
  footer.support img {
    margin: 8px 0;
    max-width: 100%;
    height: auto;
  }
  
  footer.support a {
    color: var(--accent);
    text-decoration: none;
  }
  
  #total-section.over {
    background: var(--over);
  }
  #total-section.under {
    background: var(--under);
  }
  #total-section.match {
    background: var(--match);
  }
  
  /* ✅ スマホ対応（iPhone SE含む） */
  @media (max-width: 480px) {
    body {
      overflow-x: hidden;
    }
  
    #goal-section {
        flex-wrap: nowrap;
        justify-content: space-between;
      }
    
      .goal-group {
        display: flex;
        align-items: center;
        gap: 4px;
      }
    
      .goal-group label {
        font-size: 16px;
      }
    
      .goal-group input {
        font-size: 16px;
        height: 32px;
        width: 100px;
      }
    
      #goal-section button {
        font-size: 16px;
        height: 32px;
        padding: 4px 6px;
      }

    main {
      padding: 0 8px;
    }
  
    form#item-form {
      display: grid;
      /* grid-template-columns: 1fr 80px 60px; */
      grid-template-columns: 1fr minmax(60px, 80px) minmax(50px, 60px);
      gap: 4px;
      padding: 4px; /*test*/
      margin: 4px; /*test*/
    }
  
    form#item-form input[type="text"] {
      min-width: 0;
    }
    

    form#item-form input[type="text"],
    form#item-form input[type="number"],
    form#item-form button {
      font-size: 16px; /* ← ズーム防止のため16px以上 */
      padding: 4px;
      height: 32px;
    }
  
    #goal-section {
      flex-wrap: nowrap;
      justify-content: space-between;
      gap: 4px;
    }
  
    #goal-section label {
      white-space: nowrap;
      font-size: 16px;
    }
  
    #goal-section input {
      font-size: 16px;
      height: 32px;
      width: 100px;
    }
  
    #goal-section button {
      font-size: 16px;
      height: 32px;
      padding: 4px 6px;
    }
  
    .item {
      display: grid;
      grid-template-columns: 20px 1fr 60px 30px 60px 34px;
      align-items: center;
      gap: 4px;
      padding: 4px;
    }
  
    .item input,
    .item button {
      font-size: 16px;
      padding: 4px;
    }
  
    .item input.quantity,
    .item input.unit {
      height: 28px;
    }
  
    .item input[type="text"] {
      font-size: 16px;
    }
  
    .item .subtotal {
      font-size: 16px;
      text-align: right;
    }
  
    .item .remove {
      height: 28px;
      font-size: 16px;
      padding: 0;
      text-align: center;
    }
  }
  