:root {
  --ink: #edf1ff;
  --muted: #8d91ab;
  --muted-strong: #b7b9ca;
  --canvas: #12131f;
  --panel: #1a1b2a;
  --panel-strong: #222337;
  --panel-soft: #181925;
  --line: rgba(235, 239, 255, 0.1);
  --line-strong: rgba(235, 239, 255, 0.18);
  --violet: #8c7cff;
  --cyan: #62e2ec;
  --coral: #ff927f;
  --yellow: #f8d66d;
  --shadow: 0 20px 60px rgba(5, 6, 17, 0.38);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  color-scheme: dark;
  font-family: "Manrope", "Noto Sans SC", system-ui, sans-serif;
  background: var(--canvas);
  color: var(--ink);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 78% -12%, rgba(113, 98, 255, 0.23), transparent 34rem),
    radial-gradient(circle at -8% 48%, rgba(59, 204, 219, 0.08), transparent 28rem),
    var(--canvas);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

.shell { width: min(1720px, calc(100% - 56px)); margin: 0 auto; padding: 20px 0 52px; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 24px; min-height: 54px; }

.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 31px; height: 31px; border: 1px solid rgba(98, 226, 236, 0.6); border-radius: 9px; color: var(--cyan); font: 600 15px/1 "DM Mono", monospace; transform: rotate(-6deg); }
.brand-name { font: 700 15px/1 "Space Grotesk", sans-serif; letter-spacing: -0.02em; }
.brand-name span { color: var(--cyan); }
.header-actions { display: flex; align-items: center; gap: 10px; }

.language-switcher { display: inline-flex; align-items: center; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: rgba(12, 13, 23, 0.32); }
.lang-btn { border: 0; border-radius: 999px; padding: 7px 10px; color: var(--muted); background: transparent; font: 500 11px/1 "DM Mono", monospace; transition: 160ms ease; }
.lang-btn:hover, .lang-btn.is-active { color: var(--ink); background: var(--panel-strong); }

.hero { display: flex; justify-content: space-between; align-items: end; gap: 40px; padding: 64px 0 42px; }
.eyebrow { display: flex; align-items: center; gap: 8px; margin: 0 0 15px; color: var(--cyan); font: 500 11px/1 "DM Mono", monospace; letter-spacing: 0.14em; text-transform: uppercase; }
.eyebrow::before { width: 30px; height: 1px; background: var(--cyan); content: ""; }
.hero h1 { max-width: 760px; margin: 0; font: 700 clamp(42px, 5.4vw, 88px)/0.96 "Space Grotesk", sans-serif; letter-spacing: -0.075em; }
.hero h1 em { color: var(--violet); font-style: normal; }
.hero-copy { max-width: 350px; margin: 0; color: var(--muted-strong); font-size: 13px; line-height: 1.7; }
.hero-stamp { display: flex; align-items: center; gap: 13px; min-width: 200px; padding: 15px 16px; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(26, 27, 42, 0.66); box-shadow: var(--shadow); }
.stamp-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 5px rgba(98, 226, 236, 0.12), 0 0 22px rgba(98, 226, 236, 0.65); }
.stamp-label { color: var(--muted); font: 500 10px/1.45 "DM Mono", monospace; text-transform: uppercase; letter-spacing: 0.06em; }
.stamp-label strong { display: block; color: var(--ink); font: 500 12px/1.3 "DM Mono", monospace; }

.control-deck { display: grid; grid-template-columns: minmax(240px, 1.2fr) minmax(310px, 1fr) auto auto; gap: 14px; align-items: end; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: linear-gradient(100deg, rgba(31, 32, 50, 0.92), rgba(23, 24, 39, 0.84)); box-shadow: var(--shadow); }
.field-label { display: block; margin: 0 0 8px; color: var(--muted); font: 500 10px/1 "DM Mono", monospace; letter-spacing: 0.08em; text-transform: uppercase; }
.title-input, .search-input, .filter-select, .personal-range-select { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); background: rgba(13, 14, 25, 0.56); transition: 160ms ease; }
.title-input { padding: 13px 14px; font: 600 14px/1 "Space Grotesk", sans-serif; }
.title-input:hover, .search-input:hover, .filter-select:hover, .personal-range-select:hover { border-color: var(--line-strong); }
.title-input:focus, .search-input:focus, .filter-select:focus, .personal-range-select:focus { border-color: rgba(98, 226, 236, 0.7); outline: 0; box-shadow: 0 0 0 3px rgba(98, 226, 236, 0.1); }

.segmented { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: rgba(13, 14, 25, 0.56); }
.segment-btn { flex: 1; border: 0; border-radius: 8px; padding: 10px 12px; color: var(--muted); background: transparent; font: 600 12px/1 "Noto Sans JP", "Manrope", sans-serif; letter-spacing: 0.01em; transition: 160ms ease; }
.segment-btn:hover { color: var(--ink); }
.segment-btn[data-mode="clear"] { --mode-fill: #f8d66d; --mode-ink: #191926; color: var(--muted-strong); }
.segment-btn[data-mode="fc"] { --mode-fill: #b18bff; --mode-ink: #191926; color: var(--muted-strong); }
.segment-btn[data-mode="ap"] { --mode-fill: linear-gradient(100deg, #79c8ff, #ff9fc9); --mode-ink: #201c32; color: var(--muted-strong); }
.segment-btn[data-mode]:hover { color: var(--ink); }
.segment-btn.is-active { color: var(--mode-ink, #191926); background: var(--mode-fill, var(--yellow)); box-shadow: 0 5px 14px rgba(12, 13, 23, 0.18); }
.toggle-wrap { display: flex; align-items: center; gap: 9px; height: 42px; padding: 0 5px; white-space: nowrap; }
.toggle { position: relative; display: inline-flex; width: 35px; height: 20px; }
.toggle input { position: absolute; opacity: 0; }
.toggle-track { position: absolute; inset: 0; border: 1px solid var(--line-strong); border-radius: 99px; background: var(--panel-soft); transition: 160ms ease; }
.toggle-track::after { position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); content: ""; transition: 160ms ease; }
.toggle input:checked + .toggle-track { border-color: var(--cyan); background: rgba(98, 226, 236, 0.25); }
.toggle input:checked + .toggle-track::after { background: var(--cyan); transform: translateX(15px); }
.toggle-copy { color: var(--muted-strong); font-size: 12px; }
.primary-btn, .secondary-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; border-radius: var(--radius-sm); padding: 0 15px; font: 700 12px/1 "Space Grotesk", sans-serif; transition: 160ms ease; }
.primary-btn { border: 1px solid var(--violet); color: #fff; background: var(--violet); box-shadow: 0 8px 22px rgba(140, 124, 255, 0.22); }
.primary-btn:hover { background: #a298ff; transform: translateY(-1px); }
.secondary-btn { border: 1px solid var(--line); color: var(--muted-strong); background: transparent; }
.secondary-btn:hover { border-color: var(--line-strong); color: var(--ink); background: rgba(255,255,255,0.04); }

.workspace { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 18px; margin-top: 18px; }
.library, .board-panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-lg); background: rgba(25, 26, 42, 0.86); box-shadow: var(--shadow); }
.library { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.library-head { padding: 20px 18px 14px; border-bottom: 1px solid var(--line); }
.panel-kicker { margin: 0 0 5px; color: var(--cyan); font: 500 10px/1 "DM Mono", monospace; letter-spacing: 0.12em; text-transform: uppercase; }
.panel-title { margin: 0; font: 600 18px/1.1 "Space Grotesk", sans-serif; letter-spacing: -0.03em; }
.search-wrap { position: relative; margin-top: 16px; }
.search-wrap::before { position: absolute; top: 13px; left: 13px; color: var(--muted); content: "⌕"; font-size: 18px; line-height: 1; }
.search-input { padding: 11px 12px 11px 35px; font-size: 12px; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.filter-select { padding: 10px; color: var(--muted-strong); font-size: 11px; }
.library-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; color: var(--muted); font: 500 10px/1.4 "DM Mono", monospace; }
.song-list {
  display: grid;
  flex: 0 0 520px;
  gap: 8px;
  max-height: 520px;
  padding: 13px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(177, 139, 255, 0.78) rgba(11, 12, 23, 0.42);
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}
.song-list::-webkit-scrollbar { width: 8px; }
.song-list::-webkit-scrollbar-track { border-radius: 999px; background: rgba(11, 12, 23, 0.42); }
.song-list::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 999px; background: rgba(177, 139, 255, 0.78); background-clip: padding-box; }
.song-list::-webkit-scrollbar-thumb:hover { background: #c3b4ff; background-clip: padding-box; }
.song-list.is-drop-target { outline: 1px dashed rgba(98, 226, 236, 0.72); outline-offset: -6px; background: rgba(98, 226, 236, 0.06); }
.song-card { display: grid; grid-template-columns: 47px minmax(0,1fr) auto; align-items: center; gap: 11px; min-height: 63px; padding: 7px; border: 1px solid transparent; border-radius: 13px; background: rgba(11, 12, 23, 0.28); transition: 160ms ease; user-select: none; }
.song-card:hover { border-color: rgba(98, 226, 236, 0.35); background: rgba(98, 226, 236, 0.06); transform: translateX(2px); }
.song-card:active { cursor: grabbing; }
.cover { display: block; flex: none; aspect-ratio: 1; width: 100%; border-radius: 9px; object-fit: cover; background: var(--panel-strong); }
.song-card .cover { width: 47px; }
.song-main { min-width: 0; }
.song-title { overflow: hidden; color: var(--ink); font-size: 11px; font-weight: 700; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.song-meta { display: flex; align-items: center; gap: 6px; margin-top: 5px; color: var(--muted); font: 500 9px/1 "DM Mono", monospace; }
.difficulty-pip { width: 6px; height: 6px; border-radius: 50%; background: var(--difficulty-color, var(--violet)); }
.song-level { color: var(--muted-strong); }
.song-grip { color: #575a78; font-size: 17px; }
.empty-state { padding: 26px 12px; color: var(--muted); font: 500 11px/1.6 "DM Mono", monospace; text-align: center; }

.board-panel { padding: 18px; overflow: hidden; }
.board-toolbar { display: flex; justify-content: space-between; align-items: start; gap: 18px; margin-bottom: 17px; }
.board-heading h2 { margin: 0; font: 600 22px/1.05 "Space Grotesk", sans-serif; letter-spacing: -0.045em; }
.board-heading p { margin: 6px 0 0; color: var(--muted); font: 500 10px/1.4 "DM Mono", monospace; }
.toolbar-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font: 500 10px/1 "DM Mono", monospace; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--legend-color); }

.board-columns { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
.board-columns.has-personal { grid-template-columns: minmax(0, 1fr) 228px; }
.rank-column { display: grid; gap: 9px; min-width: 0; }
.tier-row { display: grid; grid-template-columns: 94px minmax(0,1fr); min-height: 137px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: rgba(14, 15, 26, 0.45); }
.tier-label { display: flex; flex-direction: column; justify-content: space-between; min-width: 0; padding: 11px 10px; border-right: 1px solid rgba(0,0,0,0.2); background: var(--tier-color, var(--violet)); color: #171827; }
.tier-label-top { display: flex; align-items: start; justify-content: space-between; gap: 4px; }
.tier-index { font: 500 10px/1 "DM Mono", monospace; opacity: 0.58; }
.tier-drag-handle { margin-left: auto; color: rgba(23,24,39,0.55); cursor: grab; font: 700 14px/1 "DM Mono", monospace; letter-spacing: -0.16em; }
.tier-drag-handle:active { cursor: grabbing; }
.tier-row.is-dragging { opacity: 0.58; }
.tier-row.is-tier-over { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(98,226,236,0.18); }
.tier-name { width: 100%; min-width: 0; border: 0; padding: 4px 0; overflow: hidden; color: #171827; background: transparent; font: 700 22px/1 "Space Grotesk", sans-serif; letter-spacing: -0.06em; text-overflow: ellipsis; }
.tier-name:focus { outline: 0; border-bottom: 1px solid rgba(23,24,39,0.5); }
.tier-label-bottom { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.tier-count { font: 500 10px/1 "DM Mono", monospace; opacity: 0.65; }
.tier-color { width: 20px; height: 20px; padding: 0; border: 1px solid rgba(23,24,39,0.35); border-radius: 50%; background: transparent; cursor: pointer; }
.tier-color::-webkit-color-swatch-wrapper { padding: 0; }
.tier-color::-webkit-color-swatch { border: 0; border-radius: 50%; }
.delete-tier { width: 20px; height: 20px; border: 0; border-radius: 6px; color: rgba(23,24,39,0.55); background: transparent; font-size: 15px; line-height: 1; }
.delete-tier:hover { color: #171827; background: rgba(255,255,255,0.25); }
.dropzone { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 135px; padding: 11px; overflow-x: auto; transition: 160ms ease; }
.dropzone.is-over, .personal-dropzone.is-over { background: rgba(98, 226, 236, 0.08); box-shadow: inset 0 0 0 1px rgba(98, 226, 236, 0.35); }
.drop-hint { display: grid; place-items: center; min-width: 110px; height: 93px; padding: 12px; border: 1px dashed rgba(235,239,255,0.12); border-radius: 11px; color: #62657e; font: 500 10px/1.5 "DM Mono", monospace; text-align: center; }
.board-song { position: relative; flex: 0 0 92px; width: 92px; cursor: grab; }
.board-song .cover { height: 92px; border: 3px solid var(--difficulty-color, var(--violet)); box-shadow: 0 4px 14px rgba(0,0,0,0.24); }
.board-song-title { display: block; width: 100%; margin-top: 5px; overflow: hidden; color: var(--muted-strong); font-size: 9px; font-weight: 600; line-height: 1.3; text-align: center; white-space: nowrap; }
.board-song-title-text { display: inline-block; white-space: nowrap; }
.board-song-title.is-scrollable { text-align: center; }
.board-song-title.is-scrollable .board-song-title-text { animation: board-song-title-marquee var(--title-duration) ease-in-out infinite alternate; animation-delay: 1s; }
.board-song-title:focus-visible { border-radius: 3px; outline: 2px solid var(--cyan); outline-offset: 2px; }
@keyframes board-song-title-marquee {
  0%, 18% { transform: translateX(var(--title-start)); }
  82%, 100% { transform: translateX(var(--title-end)); }
}
.board-song-level { position: absolute; top: 7px; left: 7px; padding: 3px 5px; border-radius: 5px; color: #fff; background: rgba(14,15,26,0.78); font: 500 9px/1 "DM Mono", monospace; }
.tile-remove { position: absolute; top: -6px; right: -6px; display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid rgba(255,255,255,0.22); border-radius: 50%; color: var(--ink); background: #2c2c40; font-size: 14px; line-height: 1; opacity: 0; transition: 120ms ease; }
.board-song:hover .tile-remove { opacity: 1; }

.personal-column { min-width: 0; border: 1px solid rgba(140, 124, 255, 0.42); border-radius: 14px; background: rgba(47, 40, 88, 0.18); overflow: hidden; }
.personal-header { padding: 12px 13px; border-bottom: 1px solid rgba(140, 124, 255, 0.25); background: rgba(140, 124, 255, 0.11); }
.personal-header strong { display: block; font: 700 14px/1.1 "Space Grotesk", sans-serif; }
.personal-header span { display: block; margin-top: 5px; color: var(--muted); font: 500 9px/1.45 "DM Mono", monospace; }
.personal-dropzone { display: grid; gap: 10px; align-content: start; min-height: 530px; padding: 11px; transition: 160ms ease; }
.personal-empty { margin-top: 12px; padding: 16px 9px; border: 1px dashed rgba(140,124,255,0.26); border-radius: 10px; color: var(--muted); font: 500 10px/1.6 "DM Mono", monospace; text-align: center; }
.personal-song { display: grid; grid-template-columns: 55px minmax(0, 1fr); gap: 9px; padding: 6px; border-radius: 10px; background: rgba(11,12,23,0.32); }
.personal-song .cover { width: 55px; border: 2px solid var(--difficulty-color, var(--violet)); }
.personal-song-info { min-width: 0; padding-top: 3px; }
.personal-song-title { overflow: hidden; color: var(--ink); font-size: 10px; font-weight: 700; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.personal-song-caption { margin-top: 4px; color: var(--muted); font: 500 9px/1.35 "DM Mono", monospace; }
.personal-range { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 5px; margin-top: 7px; }
.personal-range-select { min-width: 0; padding: 7px 5px; font: 500 10px/1 "DM Mono", monospace; }
.personal-range-separator { color: var(--cyan); font: 700 12px/1 "DM Mono", monospace; }

.board-footnote { display: flex; align-items: center; gap: 8px; margin-top: 14px; color: var(--muted); font: 500 10px/1.5 "DM Mono", monospace; }
.board-footnote::before { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); content: ""; }
.status-text { color: var(--muted); }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 10; max-width: min(360px, calc(100% - 44px)); padding: 12px 15px; border: 1px solid rgba(98, 226, 236, 0.35); border-radius: 11px; color: var(--ink); background: #23253a; box-shadow: var(--shadow); font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(12px); transition: 180ms ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

.site-footer { margin-top: 22px; }
.credits-panel { border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(25, 26, 42, 0.7); overflow: hidden; }
.credits-panel summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; color: var(--ink); cursor: pointer; font: 600 12px/1 "Space Grotesk", sans-serif; list-style: none; }
.credits-panel summary::-webkit-details-marker { display: none; }
.credits-panel summary::before { width: 18px; height: 18px; margin-right: -4px; border: 1px solid rgba(98, 226, 236, 0.42); border-radius: 50%; color: var(--cyan); content: "+"; font: 500 14px/16px "DM Mono", monospace; text-align: center; }
.credits-panel[open] summary::before { content: "−"; }
.credits-panel summary:focus-visible { outline: 2px solid var(--cyan); outline-offset: -3px; }
.credits-summary-note { margin-left: auto; color: var(--muted); font: 500 10px/1 "DM Mono", monospace; }
.credits-body { padding: 0 16px 16px; border-top: 1px solid var(--line); }
.credits-lead { margin: 15px 0 13px; max-width: 850px; color: var(--muted-strong); font-size: 12px; line-height: 1.65; }
.credits-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.credits-block { min-width: 0; padding: 13px; border: 1px solid rgba(235, 239, 255, 0.07); border-radius: 11px; background: rgba(11, 12, 23, 0.25); }
.credits-block p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.credits-label { margin-bottom: 6px !important; color: var(--cyan) !important; font: 500 10px/1 "DM Mono", monospace !important; letter-spacing: 0.08em; text-transform: uppercase; }
.credits-block a { color: var(--ink); text-decoration-color: rgba(98, 226, 236, 0.6); text-underline-offset: 3px; }
.credits-block a:hover { color: var(--cyan); }
.credits-muted { color: var(--muted); }
.credits-note { margin: 12px 0 0; color: var(--muted); font: 500 10px/1.55 "DM Mono", monospace; }
.site-footer-note { margin: 12px 2px 0; color: rgba(141, 145, 171, 0.7); font: 500 9px/1 "DM Mono", monospace; letter-spacing: 0.08em; text-align: right; text-transform: uppercase; }

@media (max-width: 1180px) {
  .control-deck { grid-template-columns: 1fr 1fr; }
  .workspace { grid-template-columns: 280px minmax(0,1fr); }
  .board-columns.has-personal { grid-template-columns: minmax(0,1fr); }
  .personal-dropzone { min-height: 0; grid-template-columns: repeat(auto-fill, minmax(190px,1fr)); }
  .personal-empty { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .shell { width: min(100% - 28px, 700px); padding-top: 14px; }
  .hero { display: block; padding: 46px 0 30px; }
  .hero-copy { margin-top: 20px; }
  .hero-stamp { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .library { min-height: 0; max-height: 520px; }
  .song-list { flex-basis: 270px; max-height: 270px; }
  .library-head { position: sticky; top: 0; z-index: 1; background: rgba(25,26,42,0.97); }
  .board-toolbar { display: block; }
  .toolbar-actions { justify-content: start; margin-top: 14px; }
}

@media (max-width: 560px) {
  .topbar { align-items: start; }
  .header-actions { display: block; }
  .language-switcher { margin-top: 5px; }
  .control-deck { grid-template-columns: 1fr; }
  .control-deck .primary-btn, .control-deck .secondary-btn { width: 100%; }
  .tier-row { grid-template-columns: 72px minmax(0,1fr); }
  .tier-name { font-size: 17px; }
  .tier-label { padding: 9px 7px; }
  .dropzone { padding: 9px; }
  .board-panel { padding: 12px; }
  .credits-grid { grid-template-columns: 1fr; }
  .credits-summary-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .board-song-title.is-scrollable .board-song-title-text { animation: none !important; transform: none !important; }
}
