@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Noto+Sans+JP:wght@300;400;500;700&display=swap');

  :root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface2: #f0f2f7;
    --border: #dde2ee;
    --accent: #0099bb;
    --accent2: #e08800;
    --accent3: #e53e3e;
    --text: #1a2340;
    --text-dim: #7a8aaa;
    --glow: 0 0 20px rgba(0,153,187,0.15);
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Noto Sans JP', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    touch-action: manipulation;
  }
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
      linear-gradient(rgba(0,229,255,0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(0,229,255,0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
  }

  .container {
    position: relative;
    z-index: 1;
    max-width: 680px;
    margin: 0 auto;
    padding: 24px 16px 60px;
  }

  header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    text-align: left;
    margin-bottom: 28px;
    padding: 24px 20px;
    background: linear-gradient(135deg, #e8f4f8 0%, #ddeef5 100%);
    border: 1px solid var(--border);
    border-radius: 16px;
    position: relative;
    overflow: hidden;
  }
  header::before {
    content: '';
    position: absolute;
    top: -1px; left: 10%; right: 10%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
  }
  .header-titles {
    flex: 1 1 200px;
  }
  .header-titles h1 {
    font-family: 'Orbitron', monospace;
    font-size: clamp(13px, 4vw, 18px);
    font-weight: 900;
    letter-spacing: 0.08em;
    color: var(--accent);
    text-shadow: 0 0 20px rgba(0,229,255,0.5);
    margin-bottom: 6px;
  }
  .header-titles p { font-size: 11px; color: var(--text-dim); letter-spacing: 0.1em; }

  .header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
  }

  .header-btn {
    padding: 10px 14px;
    background: rgba(0, 229, 255, 0.05);
    border: 1px solid var(--accent);
    border-radius: 8px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  }
  .header-btn:hover {
    background: rgba(0, 229, 255, 0.15);
    box-shadow: var(--glow);
    transform: translateY(-1px);
  }

  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
  }
  .card-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .card-title::before {
    content: '';
    width: 3px; height: 14px;
    background: var(--accent);
    border-radius: 2px;
    box-shadow: var(--glow);
  }

  /* PT Input */
  .pt-input-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .pt-input-wrap label { font-size: 13px; color: var(--text-dim); white-space: nowrap; }
  #totalPt {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--accent2);
    font-family: 'Orbitron', monospace;
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    padding: 10px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    max-width: 160px;
  }
  #totalPt:focus { border-color: var(--accent); box-shadow: var(--glow); }
  .pt-unit { font-size: 14px; color: var(--text-dim); }

  /* Ability Group */
  .ability-group { margin-bottom: 18px; }

  .gl-白       { color: #333333; background: rgba(200,216,255,0.15); }
  .gl-金       { color: #ffd700; background: rgba(255,215,0,0.08); }
  .gl-白金     { color: #a78bfa; background: rgba(167,139,250,0.08); }
  .gl-ひらめき { color: #34d399; background: rgba(52,211,153,0.08); }
  .gl-超新規   { color: #6ee7b7; background: rgba(110,231,183,0.08); }
  .gl-贖罪     { color: #f472b6; background: rgba(244,114,182,0.08); }
  .gl-その他   { color: #fb923c; background: rgba(251,146,60,0.08); }

  .group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    margin-bottom: 10px;
    padding: 2px 4px;
    border-radius: 6px;
    transition: background 0.2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  .group-header:hover { background: rgba(255,255,255,0.05); }
  .group-toggle-icon {
    font-size: 11px;
    color: var(--text-dim);
    margin-right: 8px;
    transition: transform 0.2s;
  }

  .group-label {
    font-size: 10px;
    letter-spacing: 0.2em;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 4px;
    display: inline-block;
  }

  .ability-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 7px;
    transition: border-color 0.2s;
  }
  .ability-row:hover { border-color: #3a4560; }
  .ability-row.active { border-color: var(--accent); }

  .ability-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  .ability-sublabel {
    font-size: 10px;
    color: var(--text-dim);
    white-space: nowrap;
  }
  .ability-cost {
    font-family: 'Orbitron', monospace;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
  }
  .ability-disc {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border: 1px solid currentColor;
    border-radius: 4px;
    white-space: nowrap;
    color: var(--accent2);
  }

  /* Counter */
  .counter { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
  .counter-btn {
    width: 34px; height: 34px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    line-height: 1;
  }
  .counter-btn:hover { border-color: var(--accent); color: var(--accent); }
  .counter-btn:active { transform: scale(0.88); }
  .counter-val {
    width: 36px;
    text-align: center;
    font-family: 'Orbitron', monospace;
    font-size: 15px;
    font-weight: 700;
    color: var(--accent2);
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 0;
  }

  /* Buttons */
  .btn-primary {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #0097aa, #00e5ff);
    border: none;
    border-radius: 10px;
    color: #000;
    font-family: 'Orbitron', monospace;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 20px rgba(0,229,255,0.25);
    -webkit-tap-highlight-color: transparent;
  }
  .btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 30px rgba(0,229,255,0.4); }
  .btn-primary:active { transform: translateY(0); }

  .btn-secondary {
    width: 100%;
    padding: 13px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-dim);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
  }
  .btn-secondary:hover { border-color: var(--accent2); color: var(--accent2); }
  .btn-row { display: flex; flex-direction: column; gap: 10px; }

  /* Result */
  #result {
    display: none;
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 20px;
    margin-top: 16px;
    box-shadow: var(--glow);
    animation: fadeIn 0.3s ease;
  }
  @keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

  .result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }
  .stat-box {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 8px;
    text-align: center;
  }
  .stat-label { font-size: 9px; letter-spacing: 0.15em; color: var(--text-dim); text-transform: uppercase; margin-bottom: 4px; }
  .stat-value { font-family: 'Orbitron', monospace; font-size: 20px; font-weight: 700; color: var(--accent2); }
  .stat-value.s-blue  { color: var(--accent); }
  .stat-value.s-green { color: #34d399; }

  .result-list { list-style: none; }
  .result-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    gap: 8px;
  }
  .result-list li:last-child { border-bottom: none; }
  .result-item-name { color: var(--text); flex: 1; line-height: 1.4; }
  .result-item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
  }
  .result-item-count {
    font-family: 'Orbitron', monospace;
    font-size: 12px;
    color: var(--accent);
    background: rgba(0,229,255,0.08);
    padding: 2px 8px;
    border-radius: 4px;
  }
  .result-item-pt { font-size: 10px; color: var(--text-dim); }

  .no-result { text-align: center; padding: 24px; color: var(--text-dim); font-size: 13px; }

  .reset-link { text-align: center; margin-top: 10px; }
  .reset-link button {
    background: none; border: none;
    color: var(--text-dim); font-size: 11px;
    cursor: pointer; text-decoration: underline; padding: 4px;
  }
  .reset-link button:hover { color: var(--accent3); }

  /* Modal */
  .modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 16px;
  }
  .modal-overlay.open { display: flex; }
  .modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 620px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn 0.22s ease;
  }
  @keyframes modalIn { from { opacity:0; transform:scale(0.95); } to { opacity:1; transform:scale(1); } }
  .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .modal-header h2 {
    font-family: 'Orbitron', monospace;
    font-size: 13px; font-weight: 700;
    color: var(--accent); letter-spacing: 0.1em;
  }
  .modal-close {
    width: 30px; height: 30px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    font-size: 16px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
  }
  .modal-close:hover { border-color: var(--accent3); color: var(--accent3); }
  .modal-body { overflow-y: auto; padding: 0 4px 16px; }

  .help-body {
    padding: 16px 20px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text);
  }
  .help-body ul {
    list-style-type: disc;
    padding-left: 20px;
  }
  .help-body li {
    margin-bottom: 12px;
  }
  .help-body li:last-child {
    margin-bottom: 0;
  }

  table { width: 100%; border-collapse: collapse; font-size: 12px; }
  th {
    position: sticky; top: 0;
    background: var(--surface);
    text-align: left;
    padding: 10px 10px 8px;
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    white-space: nowrap;
    z-index: 1;
  }
  td { padding: 8px 10px; border-bottom: 1px solid rgba(42,52,80,0.5); white-space: nowrap; }
  tr:hover td { background: var(--surface2); }

  .type-badge {
    font-size: 10px; font-weight: 700;
    padding: 2px 6px; border-radius: 4px;
    display: inline-block;
  }
  .tb-白       { color: #c8d8ff; background: rgba(200,216,255,0.1); }
  .tb-金       { color: #ffd700; background: rgba(255,215,0,0.1); }
  .tb-白特殊   { color: #a78bfa; background: rgba(167,139,250,0.1); }
  .tb-白金     { color: #a78bfa; background: rgba(167,139,250,0.1); }
  .tb-ノラモン { color: #34d399; background: rgba(52,211,153,0.1); }
  .tb-調       { color: #fb923c; background: rgba(251,146,60,0.1); }
  .tb-律       { color: #f472b6; background: rgba(244,114,182,0.1); }
  .tb-超虹     { color: #00e5ff; background: rgba(0,229,255,0.1); }
  .tb-超新規   { color: #6ee7b7; background: rgba(110,231,183,0.1); }
  .tb-ひらめき { color: #34d399; background: rgba(52,211,153,0.1); }
  .tb-その他   { color: #fb923c; background: rgba(251,146,60,0.1); }
  .tb-贖罪     { color: #f472b6; background: rgba(244,114,182,0.1); }

  .eff-value { font-family: 'Orbitron', monospace; font-size: 11px; font-weight: 700; }
  .eff-high { color: #34d399; }
  .eff-mid  { color: var(--accent2); }
  .eff-low  { color: var(--text-dim); }

  ::-webkit-scrollbar { width: 6px; }
  ::-webkit-scrollbar-track { background: var(--surface); }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

  /* Link Button */
  .link-btn {
    width: 28px; height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-dim);
    font-size: 13px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  .link-btn:hover { border-color: var(--accent2); color: var(--accent2); }
  .link-btn.link-btn-active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(0,229,255,0.1);
    box-shadow: 0 0 8px rgba(0,229,255,0.2);
  }

  /* Link Modal */
  .modal-sm { max-width: 360px; }
  .link-modal-body { padding: 12px 16px 16px; }
  .link-modal-hint {
    font-size: 11px; color: var(--text-dim);
    line-height: 1.6; margin-bottom: 12px;
  }
  .link-modal-empty {
    font-size: 12px; color: var(--text-dim);
    text-align: center; padding: 20px 0; line-height: 1.7;
  }
  .link-candidate {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 7px;
    cursor: pointer;
    transition: border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
  }
  .link-candidate:hover { border-color: var(--accent); }
  .link-candidate:active { transform: scale(0.98); }

  /* Modal Tabs */
  .modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .modal-tab-btn {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
  }
  .modal-tab-btn:hover { color: var(--text); }
  .modal-tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
  }
  .modal-tab-content { }
  .base-rate-desc {
    font-size: 11px; color: var(--text-dim);
    padding: 10px 10px 4px;
    line-height: 1.6;
  }
