* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%; overflow: hidden; overscroll-behavior: none;
  background: #fdf3e0; color: #4a3524;
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
#wrap { position: fixed; inset: 0; width: 100%; height: 100%; display: flex; flex-direction: column; }
.hidden { display: none !important; }

#hud {
  padding: calc(8px + env(safe-area-inset-top)) 14px 6px;
  display: flex; justify-content: space-between; align-items: center;
  background: #f5d9a8; border-bottom: 3px solid #d9a85e;
  font-weight: 700; font-size: 15px;
}
#day-label { font-size: 17px; }
#coin-box { background: #fff; border-radius: 20px; padding: 4px 12px; border: 2px solid #d9a85e; }
#target-box { font-size: 12px; color: #8a6a45; }

#shop { padding: 8px 14px 4px; }
#shop-title { font-size: 13px; font-weight: 700; margin-bottom: 6px; color: #8a6a45; }
#packs { display: flex; gap: 8px; }
.pack-btn {
  flex: 1; min-height: 74px; border-radius: 12px; border: 3px solid #b5834e;
  background: linear-gradient(160deg, #fff8ec, #f5dfb8);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: inherit; cursor: pointer; padding: 6px 2px;
  box-shadow: 0 3px 0 #b5834e;
}
.pack-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #b5834e; }
.pack-btn .pname { font-size: 11.5px; font-weight: 800; }
.pack-btn .pcost { font-size: 13px; font-weight: 700; color: #b5834e; margin-top: 3px; }
.pack-btn.locked { opacity: .45; filter: grayscale(.8); }
.pack-btn.cant { opacity: .55; }
.pack-btn.holo { background: linear-gradient(160deg, #e8f4ff, #b8d9f5); border-color: #5e8fd9; box-shadow: 0 3px 0 #5e8fd9; }
.pack-btn.limited { background: linear-gradient(160deg, #fff3d0, #f5cf6e); border-color: #c9962e; box-shadow: 0 3px 0 #c9962e; }

#display { padding: 6px 14px 2px; }
#display-title { font-size: 13px; font-weight: 700; margin-bottom: 6px; color: #8a6a45; }
#grid-value { color: #c96a2e; }
#grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px;
  background: #e8c98f; border: 3px solid #b5834e; border-radius: 14px; padding: 8px;
}
.cell {
  aspect-ratio: 1; border-radius: 10px; background: rgba(255,255,255,.55);
  border: 2px dashed rgba(140,100,55,.4);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 30px; cursor: pointer; position: relative;
}
.cell.filled { border: 2px solid #b5834e; background: #fff; }
.cell .val {
  position: absolute; bottom: 2px; right: 4px; font-size: 10px; font-weight: 800; color: #8a6a45;
}
.cell .shine { position: absolute; inset: 0; border-radius: 8px; pointer-events: none; }

#inv-row { padding: 6px 14px; flex-shrink: 0; }
#inv-title { font-size: 12px; font-weight: 700; color: #8a6a45; margin-bottom: 4px; }
#inv { display: flex; gap: 7px; min-height: 56px; flex-wrap: wrap; }
.inv-card {
  width: 52px; height: 56px; border-radius: 9px; border: 2px solid #b5834e; background: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 26px;
  cursor: pointer; box-shadow: 0 2px 0 #b5834e; position: relative;
}
.inv-card.selected { outline: 3px solid #e25555; transform: translateY(-3px); }

.rar-common {}
.rar-rare { border-color: #4a7fe0 !important; box-shadow: 0 0 8px rgba(74,127,224,.5) !important; }
.rar-holo { border-color: #9b59d0 !important; box-shadow: 0 0 10px rgba(155,89,208,.7) !important; }
.rar-legend { border-color: #e0a92e !important; box-shadow: 0 0 14px rgba(224,169,46,.9) !important; }

#btn-sell {
  margin: auto 14px calc(12px + env(safe-area-inset-bottom)); min-height: 54px;
  border: none; border-radius: 14px; font-family: inherit;
  font-size: 17px; font-weight: 800; color: #fff;
  background: linear-gradient(180deg, #e2692e, #c9502a);
  box-shadow: 0 4px 0 #94391c; cursor: pointer;
}
#btn-sell:active { transform: translateY(3px); box-shadow: 0 1px 0 #94391c; }

.overlay {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(253,243,224,.97);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center;
}
.title-kr { font-size: 52px; font-weight: 900; color: #c9502a; text-shadow: 0 3px 0 rgba(148,57,28,.25); margin-bottom: 8px; }
.title-sub { font-size: 14px; color: #8a6a45; margin-bottom: 16px; }
.best-line { font-size: 13px; color: #c9962e; font-weight: 700; margin-bottom: 12px; }
.howto { margin-bottom: 24px; display: flex; flex-direction: column; gap: 11px; }
.how-row { display: flex; align-items: center; gap: 11px; text-align: left; font-size: 13px; line-height: 1.45; max-width: 310px; }
.how-ico { font-size: 22px; flex-shrink: 0; width: 32px; text-align: center; }
.big-btn {
  min-width: 190px; min-height: 54px; padding: 13px 30px;
  font-size: 19px; font-weight: 800; font-family: inherit;
  color: #fff; background: linear-gradient(180deg, #e2692e, #c9502a);
  border: none; border-radius: 12px; cursor: pointer;
  box-shadow: 0 4px 0 #94391c;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #94391c; }

#pack-overlay { background: rgba(60,40,20,.92); }
#pack-hint { color: #fff; font-size: 16px; font-weight: 700; margin-bottom: 20px; animation: bob 1s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }
#pack-foil {
  width: 220px; height: 300px; border-radius: 16px;
  background: linear-gradient(135deg, #d7d7e0 0%, #f8f8ff 25%, #b8b8c8 50%, #f0f0f8 75%, #c8c8d8 100%);
  border: 4px solid #9898a8; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
#pack-foil.holo { background: linear-gradient(135deg, #a8d8f0, #f0d0f8, #a8f0d8, #f8f0b0, #a8d8f0); border-color: #5e8fd9; }
#pack-foil.limited { background: linear-gradient(135deg, #f5d06e, #fff3c0, #e0a92e, #fff8d8, #f5d06e); border-color: #c9962e; }
#pack-foil-label { font-size: 22px; font-weight: 900; color: rgba(70,60,80,.75); transform: rotate(-8deg); }
#pack-foil.ripping { transition: transform .18s ease-in, opacity .18s; transform: translateY(-340px) rotate(-14deg); opacity: 0; }
#pack-cards { display: flex; gap: 16px; margin-top: 6px; }
.reveal-card {
  width: 130px; height: 180px; border-radius: 14px; background: #fff; border: 4px solid #b5834e;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 56px; animation: cardIn .45s cubic-bezier(.2,1.6,.4,1) backwards;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); position: relative; overflow: hidden;
}
.reveal-card:nth-child(2) { animation-delay: .18s; }
@keyframes cardIn { from { transform: translateY(60px) scale(.6); opacity: 0; } }
.reveal-card .rc-name { font-size: 13px; font-weight: 800; margin-top: 8px; color: #4a3524; }
.reveal-card .rc-rar { font-size: 11px; font-weight: 700; margin-top: 2px; }
.reveal-card .beam {
  position: absolute; inset: -40%; pointer-events: none;
  background: conic-gradient(transparent, rgba(255,255,220,.85), transparent 30%);
  animation: spin 2.2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.float-num {
  position: absolute; font-weight: 900; font-size: 18px; color: #c9502a;
  pointer-events: none; animation: floatUp 1s ease-out forwards; z-index: 20;
  text-shadow: 0 1px 0 #fff;
}
@keyframes floatUp { to { transform: translateY(-70px); opacity: 0; } }

.icon-btn {
  position: absolute; bottom: calc(12px + env(safe-area-inset-bottom)); right: 12px; z-index: 12;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.85); border: 2px solid #b5834e; font-size: 19px; cursor: pointer;
}
@media (max-height: 700px) {
  .cell { font-size: 24px; }
  .inv-card { width: 46px; height: 50px; font-size: 22px; }
  #pack-foil { width: 190px; height: 260px; }
}
