@charset "utf-8";

:root {
  --yellow: #ffd60a;
  --navy: #1b2a6b;
  --pink: #ff3d7f;
  --pink-deep: #c2185b;
  --paper: #fffdf2;
  --ink: #2b2118;
  --muted: #7a6a55;
  --font: 'Jua', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif;
  --star-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffd84a' stroke='%23b8860b' stroke-width='.7' stroke-linejoin='round' d='M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3l-5.9 3.3 1.3-6.6-4.9-4.6 6.6-.8z'/%3E%3C/svg%3E");
  --cell-bg: linear-gradient(160deg, #2d4296 0%, #1b2a6b 55%, #121d52 100%);
  --scale: 1;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }

body.game {
  background: var(--yellow) radial-gradient(rgba(255, 255, 255, .35) 1.2px, transparent 1.6px) 0 0 / 16px 16px;
  overflow: hidden;
}
.app { height: 100vh; display: flex; flex-direction: column; }

/* ---------- 헤더 ---------- */
.top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(300px, 600px);
  align-items: center;
  gap: 16px;
  padding: 8px 16px 2px;
}
.head-mid { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.shop { width: 100px; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .18)); }
.awning {
  position: relative;
  height: 26px;
  border-radius: 8px 8px 3px 3px;
  background: repeating-linear-gradient(90deg, #e53935 0 15px, #fff 15px 30px);
}
.awning::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -8px; height: 9px;
  background:
    radial-gradient(circle at 7.5px 0, #e53935 7px, transparent 7.5px) 0 0 / 30px 9px repeat-x,
    radial-gradient(circle at 22.5px 0, #fff 7px, transparent 7.5px) 0 0 / 30px 9px repeat-x;
}
.shop-body {
  margin: 0 8px;
  padding: 14px 6px 8px;
  text-align: center;
  background: #fff6dc;
  border: 3px solid #8d5a2b;
  border-top: 0;
  border-radius: 0 0 8px 8px;
}
.shop-sign {
  display: inline-block;
  padding: 3px 8px;
  font-size: 16px;
  letter-spacing: 1px;
  white-space: nowrap;
  color: #fff;
  background: #1e88e5;
  border-radius: 6px;
  box-shadow: 0 2px 0 #0d47a1;
}
.shop-body::after { content: '🍭 🎈 🍬'; display: block; margin-top: 6px; font-size: 15px; }

.title {
  margin: 0;
  text-align: center;
  line-height: 1.1;
  font-weight: 400;
  white-space: nowrap;
  filter: drop-shadow(0 5px 0 rgba(140, 20, 70, .45));
}
.t-small, .t-big { position: relative; display: inline-block; z-index: 0; }
.t-small::before, .t-big::before {
  content: attr(data-text);
  position: absolute; left: 0; top: 0; z-index: -1;
  -webkit-text-stroke: var(--sw) var(--sc);
}
.t-small { font-size: clamp(24px, 2.8vw, 44px); color: #fff; --sw: 9px; --sc: var(--pink); }
.t-big { font-size: clamp(38px, 4.6vw, 76px); color: var(--pink); --sw: 12px; --sc: #fff; }

/* ---------- 판 선택 탭 ---------- */
.board-tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.tab {
  max-width: 220px;
  padding: 3px 14px;
  overflow: hidden;
  font-size: 16px;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: #fff8d6;
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 2px 0 var(--ink);
  cursor: pointer;
}
.tab small { margin-left: 4px; opacity: .7; font-size: 13px; }
.tab.on { color: #fff; background: var(--ink); }
.tab:disabled { cursor: not-allowed; opacity: .6; }

/* ---------- 상품판 ---------- */
.prize-panel {
  max-height: 150px;
  overflow: auto;
  padding: 6px 12px;
  background: #fff;
  border: 4px solid #e53935;
  border-radius: 14px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .15);
}
.prize-list { list-style: none; margin: 0; padding: 0; }
.prize-list.two-col { columns: 2; column-gap: 18px; }
.prize-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 3px 0;
  font-size: 17px;
  border-bottom: 2px dashed #ffc9c9;
  break-inside: avoid;
}
.prize-row:last-child { border-bottom: 0; }
.prize-row .rank {
  min-width: 54px;
  padding: 1px 10px;
  text-align: center;
  color: #fff;
  background: var(--c);
  border-radius: 999px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .25);
}
.prize-row .item { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prize-row .item.blank { height: 1.1em; border-bottom: 2px solid #e0d6c2; margin-top: -4px; }
.prize-row .left { font-size: 15px; color: var(--muted); }
.prize-row .left b { font-size: 20px; font-weight: 400; color: var(--ink); }
.prize-row.done .item, .prize-row.done .left { text-decoration: line-through; opacity: .45; }
.prize-row.done .rank { filter: grayscale(.85); opacity: .6; }
.prize-empty { padding: 8px 0; text-align: center; color: var(--muted); }

/* ---------- 툴바 ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 6px 16px 6px;
}
.zoom { display: flex; align-items: center; gap: 4px; }
.zoom .btn { width: 40px; padding: 6px 0; }
.zoom-val { min-width: 64px; font-size: 15px; text-align: center; }
.status {
  padding: 6px 14px;
  font-size: 19px;
  background: rgba(255, 255, 255, .75);
  border-radius: 999px;
}
.status b { font-weight: 400; color: var(--pink-deep); }
.tools { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  padding: 6px 14px;
  font-size: 17px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: 3px solid #1e88e5; outline-offset: 2px; }
.btn-pink { color: #fff; background: var(--pink); }
.btn-danger { color: #c62828; background: #ffebee; }
.btn-sm { padding: 4px 10px; font-size: 15px; }

/* ---------- 뽑기판 ---------- */
.board-wrap { flex: 1; min-height: 0; overflow: auto; display: flex; padding: 2px 12px 12px; }
.board {
  --star-pos: center;
  --star-size: auto 58%;
  margin: auto;
  display: grid;
  grid-template-columns: repeat(var(--cols, 20), var(--cw, 40px));
  grid-auto-rows: var(--ch, 47px);
  gap: 3px;
  padding: 8px;
  background: #ffe866;
  border-radius: 14px;
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .06), 0 6px 0 rgba(0, 0, 0, .12);
}
.cell {
  position: relative;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: max(2px, calc(var(--cmin) * .1));
  background: var(--star-img) var(--star-pos) / var(--star-size) no-repeat, var(--cell-bg);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14), 0 1px 0 rgba(0, 0, 0, .25);
  font-family: inherit;
  transition: transform .12s, box-shadow .12s;
  perspective: 240px;
}
button.cell { cursor: pointer; }
.board.interactive .cell:not(.open):hover {
  z-index: 2;
  transform: scale(1.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25), 0 5px 12px rgba(0, 0, 0, .35);
}
.cell.open { background: var(--paper); cursor: default; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.cell.win { background: var(--c); }
.cell .lbl {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  line-height: 1;
  font-size: calc(var(--cmin) * .42);
  pointer-events: none;
}
/* 번호 표시: 별은 왼쪽 위에 작게, 번호는 가운데 크게 */
.board.numbered { --star-pos: 5% 8%; --star-size: auto 28%; }
.cell .num {
  position: relative;
  font-size: calc(var(--cmin) * .5);
  line-height: 1;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .45);
  pointer-events: none;
}
.cell.open .num {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: max(10px, calc(var(--cmin) * .22));
  color: rgba(0, 0, 0, .45);
  text-shadow: none;
}
.cell.win .num { color: rgba(255, 255, 255, .85); }
.flap .num { position: static; font-size: calc(var(--cmin) * .5); color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .45); }
.cell.win .lbl { color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, .3); }
.cell.lose .lbl { color: #b5aa92; }
.cell.picking {
  z-index: 3;
  transform: scale(1.3);
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--pink), 0 6px 14px rgba(0, 0, 0, .4);
}
.cell.just { z-index: 2; }
.cell.just::after {
  content: '';
  position: absolute; inset: -4px;
  border: 3px solid #fff;
  border-radius: inherit;
  pointer-events: none;
  animation: ring 1.1s ease-out 2;
}
.flap {
  position: absolute; inset: 0;
  display: grid;
  place-items: center;
  border-radius: inherit;
  background: var(--star-img) var(--star-pos) / var(--star-size) no-repeat, var(--cell-bg);
  transform-origin: 50% 0;
  pointer-events: none;
  animation: tear .7s cubic-bezier(.45, 0, .75, .3) forwards;
}
@keyframes tear {
  0% { transform: rotateX(0); opacity: 1; }
  25% { transform: rotateX(-40deg) translateY(-4%); opacity: 1; }
  100% { transform: rotateX(-170deg) translateY(-70%) rotate(10deg); opacity: 0; }
}
@keyframes ring {
  0% { transform: scale(.9); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ---------- 결과 팝업 ---------- */
.reveal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; overflow: hidden; }
.reveal[hidden] { display: none; }
.reveal.backdrop { background: rgba(25, 16, 45, .55); cursor: pointer; animation: fade .2s; }
.reveal-hint { position: absolute; left: 0; right: 0; bottom: 24px; text-align: center; font-size: 18px; color: #fff; opacity: .8; }
.ticket-stage { position: relative; isolation: isolate; display: grid; place-items: center; transform: scale(var(--scale)); }
.rays {
  position: absolute; z-index: -1;
  left: 50%; top: 50%;
  width: 900px; height: 900px;
  margin: -450px 0 0 -450px;
  border-radius: 50%;
  background: repeating-conic-gradient(var(--c) 0deg 9deg, transparent 9deg 18deg);
  -webkit-mask-image: radial-gradient(closest-side, #000 30%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 30%, transparent 100%);
  animation: spin 14s linear infinite, raysIn .7s ease-out both;
}
.ticket {
  position: relative;
  min-width: min(420px, 86vw);
  max-width: min(640px, 92vw);
  padding: 28px 46px 26px;
  text-align: center;
  background: var(--paper);
  border-radius: 16px;
  box-shadow: 0 0 0 8px var(--c), 0 0 0 12px #fff, 0 24px 60px rgba(0, 0, 0, .4);
  animation: pop .6s cubic-bezier(.2, 1.5, .35, 1) both;
}
.ticket::before, .ticket::after {
  content: '';
  position: absolute; top: 50%;
  width: 26px; height: 26px;
  margin-top: -13px;
  background: var(--c);
  border-radius: 50%;
}
.ticket::before { left: -13px; }
.ticket::after { right: -13px; }
.ticket-no { font-size: 18px; color: var(--muted); }
.ticket-rank {
  margin: 4px 0 2px;
  font-size: clamp(72px, 13vw, 150px);
  line-height: 1.05;
  color: var(--c);
  text-shadow: 0 5px 0 rgba(0, 0, 0, .12);
  overflow-wrap: anywhere;
}
.ticket-item {
  display: inline-block;
  margin-bottom: 4px;
  padding: 4px 16px;
  font-size: clamp(24px, 3.4vw, 40px);
  background: #fff3c4;
  border-radius: 10px;
}
.ticket-msg { margin-top: 6px; font-size: 22px; color: var(--muted); }
.is-lose .ticket { animation: popLose .75s ease both; }
.reveal.out .ticket-stage { animation: out .3s ease forwards; }

@keyframes pop {
  0% { transform: scale(.15) rotate(-14deg); opacity: 0; }
  100% { transform: scale(1) rotate(-2deg); opacity: 1; }
}
@keyframes popLose {
  0% { transform: translateY(-40px) scale(.6); opacity: 0; }
  55% { transform: translateY(6px) scale(1.02) rotate(3deg); opacity: 1; }
  75% { transform: rotate(-3deg); }
  100% { transform: rotate(-1deg); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes raysIn { from { opacity: 0; } to { opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
@keyframes out { to { transform: scale(calc(var(--scale) * .7)); opacity: 0; } }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 80; pointer-events: none; }

/* ---------- 대화상자 ---------- */
dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-radius: 18px;
  box-shadow: 0 0 0 4px var(--ink), 0 18px 50px rgba(0, 0, 0, .35);
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(25, 16, 45, .55); }
dialog form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  font-size: 22px;
  color: #fff;
  background: var(--pink);
}
.x { border: 0; background: transparent; color: #fff; font-size: 22px; cursor: pointer; }
.dlg-body { flex: 1; min-height: 0; overflow: auto; padding: 16px 20px; }
.dlg-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 2px dashed #eadfc6;
}
.spacer { flex: 1; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 14px; }
.f { display: flex; flex-direction: column; gap: 4px; font-size: 15px; color: var(--muted); }
.f input, .f select, .url-row input, .pe-row input:not([type=color]) {
  min-width: 0;
  padding: 7px 10px;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
  border: 2px solid #d9cba8;
  border-radius: 10px;
}
.f input:focus, .f select:focus, .pe-row input:focus { outline: none; border-color: var(--pink); }
.f output { color: var(--ink); }
.dlg-body h3 { margin: 18px 0 8px; font-size: 19px; font-weight: 400; }
.pe-head, .pe-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 76px 44px 36px;
  gap: 6px;
  align-items: center;
}
.pe-head { padding: 0 2px 4px; font-size: 13px; color: var(--muted); }
.pe-row { margin-bottom: 6px; }
.pe-color { width: 44px; height: 38px; padding: 2px; background: #fff; border: 2px solid #d9cba8; border-radius: 10px; cursor: pointer; }
.pe-del { height: 36px; font-size: 16px; color: #c62828; background: #ffe3e3; border: 0; border-radius: 10px; cursor: pointer; }
.summary { margin: 12px 0 0; font-size: 16px; }
.err { min-height: 1.2em; margin: 4px 0 0; color: #c62828; }
.backup { margin-top: 14px; font-size: 15px; color: var(--muted); }
.backup summary { cursor: pointer; }
.backup .row { margin-top: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.url-row { display: flex; flex-direction: column; gap: 4px; margin: 14px 0 8px; font-size: 15px; color: var(--muted); }
.url-row input { font-size: 13px; font-family: ui-monospace, Menlo, monospace; }
.help { margin-top: 16px; padding: 12px 16px; font-size: 15px; line-height: 1.6; background: #fff; border-radius: 12px; }
.help ol { margin: 6px 0; padding-left: 20px; }
.help .note { margin: 8px 0 0; color: #b23c17; }

.history { list-style: none; margin: 0; padding: 0; }
.history li {
  display: grid;
  grid-template-columns: 52px 76px auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 7px 4px;
  font-size: 17px;
  border-bottom: 1px dashed #eadfc6;
}
.history .no, .history .pos { color: var(--muted); }
.history .pill { padding: 1px 10px; text-align: center; color: #fff; background: var(--c); border-radius: 999px; }
.history .it { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .empty { display: block; padding: 30px 0; text-align: center; color: var(--muted); border: 0; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 90;
  padding: 10px 18px;
  color: #fff;
  background: rgba(30, 20, 40, .9);
  border-radius: 999px;
  transform: translateX(-50%);
  animation: fade .2s;
}

/* ---------- 오버레이 ---------- */
body.overlay { overflow: hidden; }
.ov-prizes { position: fixed; left: 20px; top: 20px; width: 400px; transform: scale(var(--scale)); transform-origin: 0 0; }
.ov-prizes .prize-panel { max-height: none; }
.ov-prizes .prize-list.two-col { columns: 1; }
.ov-prizes .status { margin-top: 8px; text-align: center; background: #fff3c4; border: 3px solid #e53935; }
.pp-title { margin: 2px 0 6px; font-size: 24px; text-align: center; color: var(--pink-deep); }
.nodata {
  position: fixed; left: 12px; bottom: 12px; z-index: 99;
  max-width: 560px;
  padding: 10px 14px;
  font-size: 16px;
  line-height: 1.5;
  color: #fff;
  background: rgba(0, 0, 0, .75);
  border-radius: 10px;
}

@media (max-width: 860px) {
  .top { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .shop { display: none; }
  .prize-panel { max-height: 140px; }
  .prize-list.two-col { columns: 1; }
  body.game { overflow: auto; }
}
