* { box-sizing: border-box; }
html, body { margin: 0; background: #14121a; color: #eee8f5; font: 15px/1.5 system-ui, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif; }
button { font: inherit; color: inherit; }
.top { padding: 18px 16px 4px; max-width: 1200px; margin: 0 auto; }
.top h1 { margin: 0 0 4px; font-size: 20px; }
.top p { margin: 0; color: #b9b0c8; font-size: 13px; }
main { max-width: 1200px; margin: 0 auto; padding: 4px 12px 40px; }
section h2 { font-size: 16px; margin: 22px 4px 10px; }
section h2 span { color: #9d93ae; font-weight: 400; font-size: 13px; margin-left: 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; } }
.tile { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; }
.tile img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 8px; background: #221e2b; display: block; }
.tile .n { font-size: 12px; color: #d9d1e6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g { font-size: 11px; font-weight: 700; padding: 0 5px; border-radius: 4px; line-height: 18px; }
.tile .g { position: absolute; left: 5px; top: 5px; }
.g.UR, .grade.UR { background: #e9c25a; color: #2a1d00; }
.g.SAR, .grade.SAR { background: #b48cf0; color: #1d0d33; }
.g.SR, .grade.SR { background: #6fb6f2; color: #071b2c; }

#view { position: fixed; left: 0; right: 0; top: 0; height: var(--vh, 100svh); z-index: 10; background: rgba(10, 9, 14, .96); display: flex; flex-direction: column; align-items: center;
  touch-action: none; user-select: none; -webkit-user-select: none; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
#view[hidden] { display: none; }
.bar { width: 100%; max-width: 760px; display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; }
.where { font-size: 13px; color: #b9b0c8; }
.close { width: 40px; height: 40px; border: 0; border-radius: 50%; background: #2a2533; font-size: 24px; line-height: 1; cursor: pointer; }
.stage { flex: 1; width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 0; perspective: 1100px; }
.card { position: relative; width: min(88vw, calc((var(--vh, 100svh) - 270px) * 2 / 3), 480px); aspect-ratio: 2 / 3; border-radius: 14px; overflow: hidden;
  background: #221e2b; box-shadow: 0 18px 50px rgba(0, 0, 0, .55); touch-action: none; cursor: grab; transform-style: preserve-3d; will-change: transform; }
.card:active { cursor: grabbing; }
.card canvas, .card .still { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.card .still { object-fit: cover; filter: blur(.5px); }
.card .wait { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); font-size: 12px; background: rgba(0, 0, 0, .55); padding: 2px 10px; border-radius: 10px; }
.nav { flex: none; width: 46px; height: 64px; border: 0; border-radius: 12px; background: #2a2533; font-size: 30px; cursor: pointer; }
.nav:hover, .close:hover { background: #3a3346; }
.info { display: flex; align-items: center; gap: 8px; padding: 10px 12px 2px; font-size: 16px; }
.grade { font-size: 12px; padding: 1px 7px; border-radius: 5px; }
.hint { margin: 2px 0 10px; font-size: 12px; color: #8f869f; text-align: center; padding: 0 12px; }
.note { width: min(94vw, 560px); display: flex; gap: 8px; align-items: stretch; padding: 8px 0 0; touch-action: auto; user-select: text; -webkit-user-select: text; }
.note textarea { flex: 1; min-height: 46px; max-height: 120px; resize: vertical; border: 1px solid #3a3346; border-radius: 10px; background: #1d1a24;
  color: #eee8f5; padding: 8px 10px; font: 16px/1.4 inherit; font-family: inherit; }
.note textarea:focus { outline: 2px solid #e9c25a; outline-offset: 0; }
.note .save { flex: none; padding: 0 16px; border: 0; border-radius: 10px; background: #e9c25a; color: #2a1d00; font-weight: 700; cursor: pointer; }
.note .save:disabled { opacity: .5; cursor: default; }
.note-state { margin: 4px 0 0; min-height: 18px; font-size: 12px; color: #9d93ae; }
.tile .mark { position: absolute; right: 5px; top: 5px; font-size: 11px; font-weight: 700; line-height: 18px; padding: 0 6px; border-radius: 9px;
  background: #ff7a59; color: #fff; display: none; }
.tile.has-note .mark { display: block; }
@media (max-width: 640px) {
  .stage { position: relative; }
  .nav { position: absolute; bottom: -2px; width: 52px; height: 44px; z-index: 2; background: rgba(42, 37, 51, .9); }
  .nav.prev { left: 10px; }
  .nav.next { right: 10px; }
  .stage { padding-bottom: 50px; }
  .card { width: min(92vw, calc((var(--vh, 100svh) - 300px) * 2 / 3)); }
}
