.usf-app {
  --usf-ink: #292521;
  --usf-muted: #756d64;
  --usf-paper: #fffdf8;
  --usf-panel: #f6f0e5;
  --usf-red: #d7473e;
  --usf-blue: #3189ad;
  --usf-gold: #d59b28;
  --usf-gray: #8d8c8a;
  width: 100%;
  max-width: 680px;
  margin: 24px auto;
  overflow: hidden;
  box-sizing: border-box;
  color: var(--usf-ink);
  background: var(--usf-paper);
  border: 1px solid #e1d7c8;
  border-radius: 18px;
  box-shadow: 0 12px 32px rgba(65, 45, 22, 0.11);
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", sans-serif;
  line-height: 1.5;
}

.usf-app *,
.usf-app *::before,
.usf-app *::after {
  box-sizing: border-box;
}

.usf-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: auto;
  min-height: 0;
  padding: 16px 20px 14px;
  color: #fff;
  background: linear-gradient(110deg, #2f2924, #514132);
}

.usf-header-copy {
  min-width: 0;
}

.usf-header h2 {
  margin: 0 !important;
  padding: 0;
  color: #fff;
  border: 0;
  font-family: serif;
  font-size: clamp(24px, 5vw, 30px);
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
}

.usf-header h2::before,
.usf-header h2::after {
  display: none;
}

.usf-header p {
  margin: 4px 0 0 !important;
  color: #ddd2c5;
  font-size: 13px;
  line-height: 1.4;
}

.usf-expand-button,
.usf-close-button {
  flex: 0 0 auto;
  margin: 0;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 9px;
  box-shadow: none;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.usf-expand-button {
  min-height: 36px;
  padding: 8px 11px;
  white-space: nowrap;
}

.usf-expand-button:hover,
.usf-expand-button:focus,
.usf-close-button:hover,
.usf-close-button:focus {
  color: #fff;
  background: rgba(255, 255, 255, 0.24);
}

.usf-close-button {
  display: none;
  width: 40px;
  height: 40px;
  padding: 0 0 3px;
  font-size: 28px;
}

.usf-modal-overlay {
  position: fixed;
  z-index: 999999;
  inset: 0;
  display: flex;
  padding: 2.5vh 2.5vw;
  align-items: center;
  justify-content: center;
  background: rgba(18, 15, 12, 0.82);
  backdrop-filter: blur(3px);
}

body.usf-modal-open {
  overflow: hidden;
}

.usf-app.usf-is-modal {
  width: 95vw;
  max-width: 1500px;
  max-height: 95vh;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
}

.usf-app.usf-is-modal .usf-expand-button { display: none; }
.usf-app.usf-is-modal .usf-close-button { display: block; }
.usf-app.usf-is-modal .usf-board { min-width: 1200px; }

.usf-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 20px 24px;
  background: var(--usf-panel);
  border-bottom: 1px solid #dfd5c5;
}

.usf-key-control {
  grid-column: 1 / -1;
}

.usf-caption {
  display: block;
  margin: 0 0 7px;
  color: var(--usf-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.usf-select,
.usf-seg button {
  font: inherit;
}

.usf-select {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 9px 12px;
  color: var(--usf-ink);
  background: #fff;
  border: 1px solid #cfc2b0;
  border-radius: 10px;
  font-weight: 700;
}

.usf-seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #e6ddcf;
  border-radius: 12px;
}

.usf-seg button {
  flex: 1;
  min-height: 40px;
  margin: 0;
  padding: 7px 5px;
  color: #665d54;
  background: transparent;
  border: 0;
  border-radius: 8px;
  box-shadow: none;
  cursor: pointer;
  font-weight: 700;
  line-height: 1.2;
}

.usf-seg button:hover,
.usf-seg button:focus {
  color: #201d1a;
  background: rgba(255, 255, 255, 0.6);
}

.usf-seg button.is-active {
  color: #201d1a;
  background: #fff;
  box-shadow: 0 2px 8px rgba(70, 50, 25, 0.12);
}

.usf-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 18px 24px 10px;
}

.usf-pill {
  padding: 6px 10px;
  background: #efe6d8;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.4;
}

.usf-pill strong {
  font-size: 15px;
}

.usf-key-pill {
  color: #fff;
  background: #2f2924;
}

.usf-shaku-pill {
  background: #ead09a;
}

.usf-hint {
  width: 100%;
  color: var(--usf-muted);
  font-size: 11px;
  text-align: right;
}

.usf-board-wrap {
  width: 100%;
  max-width: 100%;
  padding: 8px 20px 22px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: #b7aa99 #eee7dc;
  scrollbar-width: thin;
}

.usf-board-wrap:focus-visible {
  outline: 3px solid #3189ad;
  outline-offset: -3px;
}

.usf-board {
  position: relative;
  min-width: 1200px;
}

.usf-string-row {
  position: relative;
  display: grid;
  grid-template-columns: 110px 56px repeat(24, minmax(42px, 1fr));
  align-items: center;
  min-height: 82px;
}

.usf-string-row::after {
  content: "";
  position: absolute;
  z-index: 0;
  top: 50%;
  right: 0;
  left: 110px;
  height: 3px;
  background: linear-gradient(#978a7b, #d4c8b9, #75695d);
}

.usf-string-name {
  z-index: 2;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  background: var(--usf-paper);
}

.usf-string-name b,
.usf-string-name span {
  width: 74px;
  text-align: center;
}

.usf-string-name b {
  font-family: serif;
  font-size: 20px;
}

.usf-string-name span {
  margin-top: 4px;
  color: var(--usf-muted);
  font-size: 12px;
}

.usf-note {
  position: relative;
  z-index: 1;
  justify-self: center;
  display: flex;
  width: 38px;
  height: 38px;
  margin: 0;
  padding: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #fff;
  background: var(--usf-gray);
  border: 3px solid var(--usf-paper);
  border-radius: 50%;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.usf-note:hover,
.usf-note:focus {
  color: #fff;
  filter: brightness(1.08);
}

.usf-note:focus-visible {
  outline: 4px solid #111;
  outline-offset: 2px;
}

.usf-note small {
  margin-top: 3px;
  font-size: 9px;
  font-weight: 600;
  opacity: 0.9;
}

.usf-note.usf-minor-root { background: var(--usf-red); }
.usf-note.usf-major-root { background: var(--usf-gold); }
.usf-note.usf-scale { background: var(--usf-blue); }
.usf-note.usf-open { border-color: #2f2924; }
.usf-note.usf-empty { visibility: hidden; }

.usf-nut-line {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 160px;
  width: 5px;
  height: 246px;
  background: #594a3c;
  pointer-events: none;
}

.usf-positions {
  display: grid;
  grid-template-columns: 110px 56px repeat(24, minmax(42px, 1fr));
  color: #918779;
  font-size: 10px;
  text-align: center;
}

.usf-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding: 18px 24px 26px;
  color: #5f574e;
  font-size: 11px;
}

.usf-legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 5px;
  border-radius: 50%;
  vertical-align: -2px;
}

.usf-minor-color { background: var(--usf-red); }
.usf-major-color { background: var(--usf-gold); }
.usf-scale-color { background: var(--usf-blue); }
.usf-out-color { background: var(--usf-gray); }
.usf-open-color { background: #fff; border: 2px solid #2f2924; }

.usf-footer {
  padding: 0 20px 20px;
  color: #8b8176;
  font-size: 11px;
  text-align: center;
}

@media (max-width: 520px) {
  .usf-app { margin: 16px auto; border-radius: 14px; }
  .usf-header { padding: 15px 18px 13px; }
  .usf-header h2 { font-size: 24px; }
  .usf-expand-button { padding-inline: 9px; font-size: 11px; }
  .usf-controls { grid-template-columns: 1fr; padding: 18px; }
  .usf-key-control { grid-column: auto; }
  .usf-summary { padding: 16px 18px 8px; }
  .usf-board-wrap { padding-inline: 14px; }
  .usf-legend { gap: 10px 14px; padding-inline: 18px; }
}

@media print {
  .usf-app { max-width: none; margin: 0; border: 0; box-shadow: none; }
  .usf-controls, .usf-hint, .usf-footer { display: none; }
  .usf-board-wrap { overflow: visible; }
}
