* { box-sizing: border-box; }
:root {
  --yellow: #ffde59;
  --yellow2: #fff1b0;
  --edge: #4a3412;
  --text: #30220c;
  --dim: #785c26;
  --green: #347c3a;
  --red: #ce3e2a;
  --star: #e69614;
}
body {
  margin: 0;
  background: var(--yellow);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  image-rendering: pixelated;
}
#app { max-width: 1100px; margin: 0 auto; padding: 16px; }
header h1 {
  font-size: 34px; margin: 4px 0 12px; letter-spacing: 2px;
  text-shadow: 3px 3px 0 var(--yellow2);
}
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  border: 3px solid var(--edge); background: var(--yellow2);
  color: var(--text); font-weight: bold; font-size: 18px;
  padding: 10px 18px; cursor: pointer; box-shadow: 4px 4px 0 var(--edge);
}
.tab.active { background: var(--star); color: #fff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.btn {
  border: 3px solid var(--edge); background: var(--yellow2);
  color: var(--text); font-weight: bold; font-size: 16px;
  padding: 9px 14px; cursor: pointer; box-shadow: 3px 3px 0 var(--edge);
}
.btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--edge); }
.btn.primary { background: var(--star); color: #fff; }
.btn.danger { background: var(--red); color: #fff; }
.btn.small { font-size: 14px; padding: 6px 10px; }
.stats {
  border: 3px solid var(--edge); background: var(--yellow2);
  padding: 10px 14px; margin-bottom: 14px; font-weight: bold;
  box-shadow: 4px 4px 0 var(--edge);
}
.shop-list { display: grid; gap: 10px; }
.shop {
  border: 3px solid var(--edge); background: var(--yellow2);
  padding: 12px; box-shadow: 4px 4px 0 var(--edge);
  display: grid; grid-template-columns: 1fr auto; gap: 6px; cursor: pointer;
}
.shop:hover { background: #fff8d6; }
.shop h3 { margin: 0; font-size: 20px; }
.shop .loc { color: var(--dim); font-size: 14px; }
.shop .note { grid-column: 1/-1; color: var(--dim); }
.stars { color: var(--star); font-size: 22px; letter-spacing: 2px; }
.stars .off { color: #c4aa60; }
.nottried { color: var(--dim); font-weight: bold; }
.modal {
  position: fixed; inset: 0; background: rgba(60,40,10,.5);
  display: flex; align-items: center; justify-content: center; z-index: 10;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--yellow2); border: 4px solid var(--edge);
  box-shadow: 8px 8px 0 var(--edge); padding: 20px; width: min(520px, 92vw);
}
.modal-box h2 { margin-top: 0; }
.modal-box label { display: block; margin: 10px 0; font-weight: bold; }
.modal-box input {
  width: 100%; padding: 9px; border: 3px solid var(--edge);
  background: #fffdf0; font-size: 16px; margin-top: 4px;
}
.rating-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.stars-input span { font-size: 30px; cursor: pointer; color: #c4aa60; }
.stars-input span.on { color: var(--star); }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--edge); color: var(--yellow2); padding: 10px 20px;
  border-radius: 4px; opacity: 0; transition: opacity .2s; z-index: 20;
}
.toast.show { opacity: 1; }

/* 歌曲编辑器 */
.song-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.song-meta input, .song-meta select {
  border: 3px solid var(--edge); background: #fffdf0; padding: 8px; font-size: 16px;
}
#song-title { flex: 1; min-width: 160px; }
#song-tempo { width: 90px; }
.song-editor {
  border: 3px solid var(--edge); background: #fffdf0;
  padding: 10px; overflow-x: auto; box-shadow: 4px 4px 0 var(--edge);
}
.measure {
  border: 2px solid var(--edge); display: inline-block;
  margin: 4px; padding: 6px; vertical-align: top; background: var(--yellow2);
}
.measure-no { font-size: 12px; color: var(--dim); }
.note-cells { display: flex; gap: 3px; }
.note-cell {
  width: 34px; height: 46px; border: 2px solid var(--edge);
  background: #fff; cursor: pointer; font-weight: bold;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.note-cell:hover { background: #fff3b0; }
.note-cell.filled { background: var(--star); color: #fff; }
.staff-note { position: relative; }
.song-hint { margin-top: 10px; color: var(--dim); font-size: 14px; }
.note-picker {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--edge);
  padding: 10px; display: flex; gap: 6px; flex-wrap: wrap;
  justify-content: center; z-index: 15; display: none;
}
.note-picker.show { display: flex; }
.note-picker button {
  border: 2px solid var(--yellow); background: var(--yellow2); color: var(--edge);
  font-weight: bold; font-size: 18px; min-width: 44px; padding: 8px; cursor: pointer;
}
@media (max-width: 640px) {
  header h1 { font-size: 26px; }
  .tab { font-size: 15px; padding: 8px 12px; }
  .shop { grid-template-columns: 1fr; }
  .note-cell { width: 30px; height: 42px; }
  .modal-box { padding: 14px; }
}

/* 文件选择框：不能用 display:none，否则手机浏览器拒绝打开 */
.file-hidden {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* 手机端按钮加大，方便点击 */
@media (max-width: 640px) {
  .toolbar .btn { font-size: 17px; padding: 12px 16px; }
  .btn { min-height: 44px; }
}
