/* ---------------------------------------------------------------------------
   Rudiment - 드럼 굼뱅이 (PWA)
   색은 안드로이드 res/values/colors.xml · iOS Theme.swift 와 같은 값.
   --------------------------------------------------------------------------- */
:root {
  --ink: #080808;
  --topbar: #111111;
  --paper: #fafafa;
  --staff: #5c5c5c;
  --accent: #ff6a00;
  --muted: #9a9a9a;
  --hint: #666666;
  --line: #bbbbbb;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic',
    'Noto Sans KR', system-ui, sans-serif;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
}

body {
  position: fixed;
  inset: 0;
}

/* --------------------------------------------------------------- 악보 ----- */
/* iOS 앱과 같은 여백(좌우 72pt, 위아래 24pt) */
#scoreBox {
  position: absolute;
  inset: 24px 72px;
  z-index: 1;
}

#score {
  display: block;
  width: 100%;
  height: 100%;
}

#gestureLayer {
  position: absolute;
  inset: 0;
  z-index: 10;
  touch-action: none;
}

/* --------------------------------------------------------------- HUD ------ */
#hud {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  padding: 12px 22px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease-out;
  pointer-events: none;
}

#hud.show {
  opacity: 1;
  transition: opacity 0.08s ease-in;
}

/* ------------------------------------------------------- 시작 안내 카드 ---- */
#intro {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.7s ease-out;
  pointer-events: none;
}

#intro.show {
  opacity: 1;
  transition: opacity 0.45s ease-in;
}

#intro.gone {
  display: none;
}

#intro .card {
  padding: 34px 40px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  text-align: center;
}

#intro .title {
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 0.8px;
  color: var(--ink);
}

#intro .sub {
  margin-top: 22px;
  font-size: 15px;
  color: #777;
}

/* ------------------------------------------------------- NEW 손잡이 -------- */
#newHandle {
  position: absolute;
  right: 0;
  top: 50%;
  z-index: 40;
  transform: translateY(-50%);
  padding: 9px 10px;
  border: 0;
  border-radius: 14px 0 0 14px;
  background: rgba(26, 26, 26, 0.82);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.2px;
  opacity: 0.95;
  touch-action: none;
  transition: transform 0.18s ease-out, opacity 0.2s ease-out;
}

#newHandle.playing {
  opacity: 0.62;
}

/* ------------------------------------------------------- 설정 서랍 --------- */
#scrim {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease-out;
}

#scrim.open {
  opacity: 1;
  pointer-events: auto;
}

#drawer {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  width: min(680px, 90vw);
  background: var(--paper);
  box-shadow: 4px 0 12px rgba(0, 0, 0, 0.35);
  transform: translateX(-105%);
  transition: transform 0.22s ease-out;
  visibility: hidden;
}

#drawer.open {
  transform: none;
  visibility: visible;
}

.drawer-head {
  display: flex;
  align-items: center;
  padding: 26px 20px 12px;
}

.drawer-head h1 {
  flex: 1;
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  color: var(--ink);
}

#drawerClose {
  width: 33px;
  height: 33px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 8px 20px 40px;
  touch-action: pan-y;
}

.drawer-body section {
  margin-bottom: 18px;
}

.drawer-body h2 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.drawer-body .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.drawer-body .row h2 {
  margin: 0;
}

.drawer-body .row.inline {
  justify-content: flex-start;
  margin-top: 8px;
}

.drawer-body .row.inline.dim {
  opacity: 0.35;
}

.label {
  font-size: 13px;
  color: var(--hint);
}

.gap {
  width: 16px;
}

.value {
  margin-bottom: 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}

.hint {
  margin: 2px 0 0;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--hint);
  word-break: keep-all;
}

.status {
  display: none;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.status.show {
  display: block;
}

.copyright {
  margin: 12px 0 10px;
  padding-top: 12px;
  font-size: 11.5px;
  line-height: 1.6;
  text-align: center;
  color: var(--muted);
}

/* 패턴 선택 그림 */
.pattern-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}

.tile {
  display: block;
  padding: 5px;
  border: 2px solid rgba(140, 140, 140, 1);
  border-radius: 8px;
  background: #fff;
  opacity: 0.3;
  aspect-ratio: 1 / 1;
  transition: opacity 0.12s linear, border-color 0.12s linear;
}

.tile.on {
  border-color: var(--accent);
  opacity: 1;
}

.tile canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* 스위치 */
.switch {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: rgba(120, 120, 120, 0.35);
  transition: background 0.16s linear;
}

.switch span::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.16s ease-out;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

/* 슬라이더 */
input[type='range'] {
  display: block;
  width: 100%;
  margin: 6px 0;
  accent-color: var(--accent);
  touch-action: pan-y;
}

/* 숫자 입력 */
.num {
  width: 62px;
  padding: 6px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  text-align: center;
  -webkit-user-select: text;
  user-select: text;
}

/* 길이 버튼 */
.option {
  flex: 1;
  padding: 10px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
}

.option.on {
  border: 2px solid var(--accent);
  color: var(--accent);
}

/* ------------------------------------------------- 홈 화면에 추가 안내 ----- */
#installHint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%) translateY(8px);
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.86);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease-out, transform 0.35s ease-out;
  pointer-events: none;
}

#installHint.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%);
}

#installHintClose {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  pointer-events: auto;
}

/* --------------------------------------------------- 가로 안내 ------------ */
/* 세로로 열었을 때만 뜨는 안내. 화면을 가리지 않으므로(pointer-events:none)
   세로로도 그대로 쓸 수 있고, 가로로 돌리면 저절로 사라진다. */
#rotateHint {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  z-index: 80;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.86);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

#rotateHint.show {
  display: flex;
}

.rotate-icon {
  font-size: 14px;
  line-height: 1;
  color: var(--accent);
}

/* 작은 화면(가로로 짧은 폰)에서는 안내 문구를 조금 줄인다 */
@media (max-height: 420px) {
  #intro .title {
    font-size: 30px;
  }
  #intro .sub {
    margin-top: 14px;
    font-size: 13px;
  }
  #installHint {
    font-size: 11px;
  }
}

/* 가로가 아닌 좁은 화면에서도 서랍은 그대로 쓸 수 있게 */
@media (max-width: 520px) {
  .pattern-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}
