:root {
  --wall: #efe3cc;
  --wall-line: #e4d4b6;
  --wood: #8a5a33;
  --wood-dark: #5e3b1f;
  --wood-light: #b07a4a;
  --plank: 18px;
  --box-w: 112px;
  --box-h: 168px;
  --row-h: calc(var(--box-h) + var(--plank) + 30px);
  --ink: #2b1d12;
  --accent: #d6342c;
  --tag: #ffd84d;
  --sign-font: 'Black Han Sans', 'Noto Sans KR', sans-serif;
  --label-font: 'Do Hyeon', 'Noto Sans KR', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Noto Sans KR', system-ui, sans-serif;
  color: var(--ink);
  background:
    repeating-linear-gradient(90deg, transparent 0 79px, var(--wall-line) 79px 80px),
    var(--wall);
  min-height: 100vh;
}

/* ---------- 간판 ---------- */
.storefront { position: relative; }
.awning {
  height: 56px;
  background: repeating-linear-gradient(90deg, var(--accent) 0 48px, #fff7ea 48px 96px);
  position: relative;
  box-shadow: 0 6px 10px rgba(0, 0, 0, .18);
}
.awning::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -14px; height: 14px;
  background:
    radial-gradient(circle at 24px 0, var(--accent) 23px, transparent 24px) 0 0 / 96px 14px repeat-x,
    radial-gradient(circle at 72px 0, #fff7ea 23px, transparent 24px) 0 0 / 96px 14px repeat-x;
}
.signboard {
  max-width: 1100px;
  margin: 34px auto 0;
  padding: 18px 28px;
  display: flex; align-items: center; gap: 18px; justify-content: center;
  background: linear-gradient(#2a1a10, #1a0f08);
  border: 6px solid var(--wood);
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px #000, 0 10px 20px rgba(0, 0, 0, .25);
  margin-inline: 16px;
}
@media (min-width: 1132px) { .signboard { margin-inline: auto; } }
.signboard h1 {
  margin: 0;
  font-family: var(--sign-font);
  font-weight: 400;
  font-size: clamp(28px, 5vw, 52px);
  color: #fff4d6;
  letter-spacing: .02em;
  text-shadow: 0 0 6px #ffb347, 0 0 18px #ff7b22, 0 0 32px #ff5a1f;
  text-align: center;
  overflow-wrap: anywhere;
}
.owner-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  border: 3px solid #ffd27a;
  box-shadow: 0 0 12px #ff9a3c;
  flex-shrink: 0;
}
.open-sign {
  font-family: var(--label-font);
  font-size: 18px;
  padding: 4px 10px;
  border-radius: 6px;
  color: #555;
  border: 2px solid #555;
  flex-shrink: 0;
}
.open-sign.on {
  color: #7dffb0; border-color: #7dffb0;
  text-shadow: 0 0 8px #3dff8a; box-shadow: 0 0 10px rgba(61, 255, 138, .4);
}

/* ---------- 입력 ---------- */
.entry { max-width: 1100px; margin: 24px auto 0; padding: 0 16px; }
.entry-label { font-family: var(--label-font); font-size: 18px; display: block; margin-bottom: 6px; }
.entry-row { display: flex; gap: 8px; flex-wrap: wrap; }
.entry-row input { flex: 1 1 280px; }
input[type=text], input[type=search] {
  font: inherit; font-size: 16px;
  padding: 10px 14px;
  border: 2px solid var(--wood-dark);
  border-radius: 8px;
  background: #fffaf0;
  color: var(--ink);
  min-width: 0;
}
.btn {
  font-family: var(--label-font); font-size: 17px;
  padding: 10px 16px;
  border: 2px solid var(--wood-dark);
  border-radius: 8px;
  background: #fff3da;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center;
}
.btn:hover { background: #ffe8b8; }
.btn.primary { background: var(--accent); color: #fff; border-color: #8f1d17; }
.btn.primary:hover { background: #e94a40; }
.btn:disabled { opacity: .6; cursor: wait; }
.notice, .message {
  margin: 12px 0 0; padding: 10px 14px; border-radius: 8px; font-size: 14px; line-height: 1.6;
}
.notice { background: #fff6d8; border: 1px dashed #c9a24a; }
.message { background: #ffe3df; border: 1px solid #e2a29b; }
.message.info { background: #e8f3ff; border-color: #a6c6ea; }
code { background: rgba(0, 0, 0, .07); padding: 1px 5px; border-radius: 4px; }

/* ---------- 매장 ---------- */
.store { max-width: 1100px; margin: 28px auto 60px; padding: 0 16px; }
.aisle-tools { display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; margin-bottom: 18px; }
.aisle-tools input { flex: 1 1 240px; max-width: 420px; }
.seg { display: inline-flex; border: 2px solid var(--wood-dark); border-radius: 8px; overflow: hidden; }
.seg button {
  font-family: var(--label-font); font-size: 16px;
  border: 0; padding: 8px 14px; background: #fff3da; cursor: pointer; color: var(--ink);
}
.seg button.active { background: var(--wood-dark); color: #fff3da; }

/* 진열장 유닛 */
.unit {
  position: relative;
  margin-bottom: 36px;
  padding: 0 14px 14px;
  background: linear-gradient(#3b2414, #4a2e19 30px, #3b2414);
  border: 10px solid var(--wood);
  border-top-width: 0;
  border-radius: 6px;
  box-shadow: 0 14px 24px rgba(0, 0, 0, .28), inset 0 0 40px rgba(0, 0, 0, .5);
}
.unit-header {
  margin: 0 -24px 14px;
  padding: 10px 20px;
  background: linear-gradient(var(--wood-light), var(--wood));
  border-radius: 6px 6px 0 0;
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  box-shadow: 0 4px 6px rgba(0, 0, 0, .3);
}
.unit-header h2 {
  margin: 0;
  font-family: var(--sign-font); font-weight: 400;
  font-size: 26px; color: #fff8e6;
  text-shadow: 0 2px 0 var(--wood-dark);
}
.unit-header .sub { font-family: var(--label-font); color: #ffe9bf; font-size: 16px; }
.unit-header .count {
  margin-left: auto; font-family: var(--label-font); font-size: 15px;
  background: #fff8e6; color: var(--wood-dark); padding: 2px 10px; border-radius: 99px;
}
.unit.unit-best .unit-header { background: linear-gradient(#e0b23c, #b8861d); }
.unit.unit-best .unit-header h2 { text-shadow: 0 2px 0 #7a5410; }
.unit.unit-new .unit-header { background: linear-gradient(#e2574e, #b3302a); }
.unit.unit-new .unit-header h2 { text-shadow: 0 2px 0 #6d1a16; }
.unit.unit-recent .unit-header { background: linear-gradient(#4f8fd1, #2d64a3); }
.unit.unit-recent .unit-header h2 { text-shadow: 0 2px 0 #183b63; }

/* 선반: 각 그리드 행 아래에 판자가 그려진다 */
.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--box-w), 1fr));
  grid-auto-rows: var(--row-h);
  column-gap: 14px;
  padding: 0 6px;
  background:
    repeating-linear-gradient(to bottom,
      transparent 0 calc(var(--row-h) - var(--plank)),
      #c99561 calc(var(--row-h) - var(--plank)) calc(var(--row-h) - var(--plank) + 4px),
      var(--wood-light) calc(var(--row-h) - var(--plank) + 4px) calc(var(--row-h) - 5px),
      var(--wood-dark) calc(var(--row-h) - 5px) var(--row-h));
  margin: 0 -6px;
}
.shelf.spines {
  grid-template-columns: repeat(auto-fill, 30px);
  column-gap: 3px;
  justify-content: start;
}

.item {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding-bottom: calc(var(--plank) - 2px);
  cursor: pointer;
  background: none; border: 0; font: inherit; color: inherit;
}
.item:focus-visible { outline: 3px solid #ffd84d; outline-offset: 2px; border-radius: 4px; }

/* 앞면 패키지 */
.case {
  position: relative;
  width: 100%; max-width: var(--box-w);
  aspect-ratio: 2 / 3;
  border-radius: 3px 5px 5px 3px;
  overflow: hidden;
  background: #222;
  box-shadow: -3px 0 0 #111 inset, 0 8px 10px -2px rgba(0, 0, 0, .6);
  transition: transform .18s ease, box-shadow .18s ease;
  transform-origin: bottom center;
}
.case img { width: 100%; height: 100%; object-fit: cover; display: block; }
.case::before {
  /* 케이스 왼쪽 경첩 */
  content: ''; position: absolute; inset: 0 auto 0 0; width: 8px; z-index: 2;
  background: linear-gradient(90deg, rgba(255, 255, 255, .28), rgba(0, 0, 0, .35) 60%, rgba(255, 255, 255, .1));
}
.case::after {
  /* 플라스틱 광택 */
  content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, .35) 0%, rgba(255, 255, 255, .06) 28%, transparent 45%, transparent 80%, rgba(255, 255, 255, .12));
}
.item:hover .case, .item:focus-visible .case {
  transform: translateY(-10px) rotate(-2deg);
  box-shadow: -3px 0 0 #111 inset, 0 18px 16px -4px rgba(0, 0, 0, .55);
}
.case.wide img { object-fit: cover; object-position: center; }
.cover-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 12px 10px 12px 16px;
  font-family: var(--sign-font); font-size: 15px; line-height: 1.25; color: #fff;
  text-shadow: 0 2px 2px rgba(0, 0, 0, .5);
  overflow-wrap: anywhere;
}

/* 미개봉 비닐 포장 */
.case.sealed::after {
  background:
    linear-gradient(115deg, rgba(255, 255, 255, .55) 0%, rgba(255, 255, 255, .1) 22%, transparent 40%),
    linear-gradient(170deg, transparent 60%, rgba(255, 255, 255, .25) 62%, transparent 66%),
    linear-gradient(20deg, transparent 30%, rgba(255, 255, 255, .18) 31%, transparent 34%),
    rgba(220, 235, 255, .08);
}
.sticker {
  position: absolute; z-index: 3;
  top: 8px; right: 0;
  font-family: var(--label-font); font-size: 13px; line-height: 1;
  padding: 5px 8px 5px 10px;
  background: var(--accent); color: #fff;
  border-radius: 4px 0 0 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .4);
  transform: rotate(4deg);
}
.rank {
  position: absolute; z-index: 3; top: -2px; left: 10px;
  width: 30px; padding: 6px 0 10px;
  text-align: center;
  font-family: var(--sign-font); font-size: 15px; color: #4a3000;
  background: linear-gradient(#ffe27a, #f2b51c);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, .4);
}
.rank.r1 { background: linear-gradient(#fff2a8, #f5c400); }
.rank.r2 { background: linear-gradient(#f3f3f3, #b9c0c8); color: #333; }
.rank.r3 { background: linear-gradient(#f5c69b, #c27a3c); color: #3d1f05; }

/* 가격표 자리에 플레이 시간 */
.tag {
  position: absolute; bottom: -4px; z-index: 4;
  font-family: var(--label-font); font-size: 13px; line-height: 1;
  padding: 4px 8px 3px;
  background: var(--tag);
  color: #3a2a00;
  border-radius: 2px;
  box-shadow: 0 2px 2px rgba(0, 0, 0, .35);
  white-space: nowrap;
}
.tag.zero { background: #fff; color: var(--accent); }

/* 옆면 진열 */
.spine {
  position: relative;
  width: 30px; height: var(--box-h);
  border-radius: 2px;
  overflow: hidden;
  display: flex; flex-direction: column; align-items: center;
  box-shadow: inset 2px 0 0 rgba(255, 255, 255, .25), inset -3px 0 0 rgba(0, 0, 0, .35), 0 6px 6px -2px rgba(0, 0, 0, .55);
  transition: transform .15s ease;
}
.spine .band {
  width: 100%; height: 22px; flex-shrink: 0;
  background: #1b2838;
  color: #c7d5e0;
  font: 700 7px/22px 'Noto Sans KR', sans-serif;
  letter-spacing: .05em;
  text-align: center;
}
.spine .title {
  flex: 1; min-height: 0;
  writing-mode: vertical-rl;
  font-family: var(--label-font); font-size: 13px; line-height: 1;
  color: #fff;
  padding: 8px 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .5);
}
.spine .dot { width: 8px; height: 8px; border-radius: 50%; margin-bottom: 8px; flex-shrink: 0; background: rgba(255, 255, 255, .55); }
.spine .dot.played { background: #7dffb0; box-shadow: 0 0 4px #7dffb0; }
.item:hover .spine, .item:focus-visible .spine { transform: translateY(-14px); }

.more-row { text-align: center; padding-top: 12px; }
.empty { color: #ffe9bf; font-family: var(--label-font); padding: 30px 0 40px; text-align: center; }

/* 호버 미리보기 */
.peek {
  position: fixed; z-index: 50; pointer-events: none;
  width: 150px;
  background: #fffaf0; border: 2px solid var(--wood-dark); border-radius: 8px;
  padding: 6px; box-shadow: 0 10px 20px rgba(0, 0, 0, .3);
  font-size: 13px; line-height: 1.35;
}
.peek img { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 4px; display: block; background: #333; }
.peek strong { display: block; margin-top: 6px; }

/* ---------- 계산대 ---------- */
.counter {
  margin-top: 20px;
  display: flex; gap: 24px; align-items: flex-start; justify-content: center; flex-wrap: wrap;
  padding: 26px 16px 34px;
  background: linear-gradient(#6b4326, #4b2d17);
  border-top: 12px solid var(--wood-light);
  border-radius: 10px;
  box-shadow: 0 14px 24px rgba(0, 0, 0, .3);
}
.register {
  width: 180px; height: 120px;
  background: linear-gradient(#3a3f45, #23272b);
  border-radius: 10px 10px 4px 4px;
  padding: 14px;
  box-shadow: 0 6px 0 #15181b;
}
.register-screen {
  background: #0d2a14; color: #59ff8c;
  font: 700 22px/1 ui-monospace, Consolas, monospace;
  padding: 10px; text-align: right; border-radius: 4px;
  text-shadow: 0 0 6px #2bff6a;
}
.register-screen::after { content: '시간'; font-size: 12px; margin-left: 4px; }
.receipt {
  margin: 0;
  width: min(320px, 100%);
  background: #fffdf7;
  padding: 18px 18px 26px;
  font: 13px/1.6 ui-monospace, Consolas, 'D2Coding', monospace;
  color: #333;
  white-space: pre-wrap;
  box-shadow: 0 6px 10px rgba(0, 0, 0, .3);
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 14px 100%;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 14px 100%;
}

/* ---------- 상세 ---------- */
.detail {
  border: 4px solid var(--wood); border-radius: 12px; padding: 0;
  background: #fffaf0; color: var(--ink);
  max-width: min(640px, calc(100vw - 32px));
}
.detail::backdrop { background: rgba(20, 10, 0, .6); }
.detail-inner { display: flex; gap: 20px; padding: 20px; flex-wrap: wrap; }
.detail-cover { width: 200px; aspect-ratio: 2/3; position: relative; flex-shrink: 0; margin-inline: auto; }
.detail-cover .case { max-width: none; height: 100%; }
.detail-info { flex: 1 1 240px; min-width: 0; }
.detail-info h2 { font-family: var(--sign-font); font-weight: 400; margin: 0 0 12px; font-size: 26px; overflow-wrap: anywhere; }
.detail-info dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 18px; }
.detail-info dt { color: #7a6450; }
.detail-info dd { margin: 0; font-weight: 700; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 640px) {
  :root { --box-w: 92px; --box-h: 138px; }
  .awning { height: 40px; }
  .signboard { padding: 14px; gap: 10px; flex-wrap: wrap; }
  .owner-avatar { width: 48px; height: 48px; }
  .unit { border-width: 0 6px 6px; padding: 0 8px 8px; }
  .unit-header { margin: 0 -14px 12px; }
  .unit-header h2 { font-size: 21px; }
  .shelf { column-gap: 10px; }
  .tag { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .case, .spine { transition: none; }
}
