/* LOTTERY ROULETTE CSS */
/* Retro Korean Stationery Shop Theme */

/* === Custom Properties === */
#lotteryGame {
  --retro-yellow: #ffd60a;
  --retro-blue: #0096c7;
  --retro-red: #d00000;
  --retro-pink: #ff758f;
  --retro-sky: #90e0ef;
  --retro-cream: #fef9ef;
  --retro-orange: #fb8500;
  --retro-purple: #7209b7;

  background: linear-gradient(180deg, var(--retro-sky) 0%, var(--retro-cream) 50%, var(--retro-sky) 100%) !important;
  color: #3a2a10;
}

/* .screen.active 일 때만 flex 적용 — display:none 을 덮어쓰지 않도록 */
#lotteryGame.active {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

#lotteryGame .back-btn {
  color: #fff; background: rgba(208,0,0,0.7); border-radius: 50%;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  flex-shrink: 0;
}

#lotteryGame .setup-title { color: var(--retro-red); font-weight: 900; }
#lotteryGame .setup-row label { color: #5a3a1a !important; }

#lotteryGame .btn-primary {
  background: linear-gradient(135deg, var(--retro-yellow), var(--retro-orange)) !important;
  border: 4px solid white !important;
  color: var(--retro-red) !important;
  font-family: 'Black Han Sans', sans-serif;
  font-size: 18px;
  border-radius: 50px;
  box-shadow: 0 6px 0 var(--retro-blue), 0 8px 20px rgba(0,0,0,0.3);
  text-shadow: 1px 1px 0 rgba(255,255,255,0.5);
  transition: all 0.2s;
}

#lotteryGame .btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 var(--retro-blue), 0 5px 12px rgba(0,0,0,0.3);
}

/* === Top Bar === */
.lottery-top-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px;
  background: linear-gradient(180deg, var(--retro-red) 0%, #b00000 100%);
  border-bottom: 4px solid var(--retro-blue);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  flex-shrink: 0;
}

.lottery-title {
  font-family: 'Black Han Sans', sans-serif; font-size: 22px;
  color: var(--retro-yellow);
  text-shadow:
    3px 3px 0 rgba(0,0,0,0.3),
    -1px -1px 0 rgba(0,0,0,0.2),
    0 0 12px rgba(255,214,10,0.4);
  letter-spacing: 2px;
}

/* === Mode Tabs === */
.mode-tabs {
  display: flex; gap: 0;
  background: white;
  border-bottom: 3px solid var(--retro-red);
  flex-shrink: 0;
}

.mode-tab {
  flex: 1; padding: 10px 12px;
  background: linear-gradient(180deg, var(--retro-sky) 0%, var(--retro-blue) 100%);
  border: none; border-right: 3px solid white;
  text-align: center; font-size: 15px; font-weight: 700;
  color: white; cursor: pointer; transition: all 0.3s;
  min-height: 40px;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.3);
  position: relative;
  box-shadow: none;
}

.mode-tab:last-child { border-right: none; }

.mode-tab::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: 0; background: var(--retro-yellow); transition: height 0.3s ease;
}

.mode-tab.active::after { height: 4px; }
.mode-tab:active { transform: scale(0.97); }

.mode-tab.active {
  background: linear-gradient(180deg, var(--retro-yellow) 0%, var(--retro-orange) 100%);
  color: var(--retro-red);
  transform: scale(1.03);
  box-shadow: 0 2px 10px rgba(251,133,0,0.4);
  text-shadow: none;
}

/* === Mode Containers — 핵심: 남은 공간 전부 차지 + overflow 제어 === */
.lottery-mode-container, .roulette-mode-container {
  flex: 1 1 0;
  min-height: 0; /* flex overflow 핵심 */
  display: flex; flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, var(--retro-sky) 0%, var(--retro-cream) 50%, var(--retro-sky) 100%);
}

/* === Setup Panels === */
.lottery-setup-panel, .roulette-setup-panel {
  padding: 14px;
  background: white;
  border-radius: 15px;
  border: 4px solid var(--retro-blue);
  margin: 10px;
  box-shadow: 0 6px 0 var(--retro-red), 0 10px 16px rgba(0,0,0,0.2);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 1;
  min-height: 0;
}

.lottery-items-input {
  width: 100%; min-height: 90px; padding: 10px;
  background: var(--retro-cream);
  border: 3px solid var(--retro-blue); border-radius: 10px;
  color: #3a2a10; font-size: 14px; font-family: inherit;
  resize: vertical; outline: none; margin-bottom: 10px;
  box-shadow: inset 2px 2px 6px rgba(0,0,0,0.08);
  max-height: 25vh;
}

.lottery-items-input:focus {
  border-color: var(--retro-orange);
  box-shadow: inset 2px 2px 4px rgba(0,0,0,0.08), 0 0 0 3px rgba(251,133,0,0.3);
}

/* Field-based input rows */
.lottery-fields-container {
  max-height: 30vh; overflow-y: auto; margin-bottom: 8px;
  display: flex; flex-direction: column; gap: 6px;
  -webkit-overflow-scrolling: touch;
}
.lottery-field-row {
  display: flex; align-items: center; gap: 6px;
}
.lottery-field-num {
  min-width: 22px; text-align: center; font-size: 12px; font-weight: 700;
  color: var(--retro-blue); flex-shrink: 0;
}
.lottery-field-input {
  flex: 1; min-width: 0; padding: 8px 10px;
  background: var(--retro-cream);
  border: 2px solid var(--retro-blue); border-radius: 8px;
  color: #3a2a10; font-size: 14px; font-family: inherit;
  outline: none;
}
.lottery-field-input:focus {
  border-color: var(--retro-orange);
  box-shadow: 0 0 0 2px rgba(251,133,0,0.3);
}
.lottery-field-count {
  width: 52px; padding: 8px 4px; text-align: center;
  background: var(--retro-cream);
  border: 2px solid var(--retro-purple); border-radius: 8px;
  color: #3a2a10; font-size: 14px; font-family: inherit;
  outline: none; flex-shrink: 0;
}
.lottery-field-count:focus {
  border-color: var(--retro-orange);
  box-shadow: 0 0 0 2px rgba(251,133,0,0.3);
}
.lottery-field-del {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--retro-red);
  background: rgba(208,0,0,0.1); color: var(--retro-red);
  font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; flex-shrink: 0;
}
.lottery-field-del:active { background: var(--retro-red); color: #fff; }

#lotteryGame .btn-secondary {
  background: white !important; color: var(--retro-blue) !important;
  border: 3px solid var(--retro-blue) !important; border-radius: 20px;
  font-weight: 700;
}

.setup-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px; justify-content: center;
}

.grid-size-select {
  padding: 8px 12px; background: var(--retro-cream);
  border: 3px solid var(--retro-blue); border-radius: 8px;
  color: #3a2a10; font-size: 14px; font-weight: 700;
  outline: none; cursor: pointer;
}

/* === Preset Save/Load Buttons === */
.lottery-preset-btns {
  display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap;
}
.lottery-preset-btns .btn-secondary { flex: 1; min-width: 80px; }
.lottery-save-btn { border-color: var(--retro-purple) !important; color: var(--retro-purple) !important; }
.lottery-load-btn { border-color: var(--retro-orange) !important; color: var(--retro-orange) !important; }

/* === Preset List === */
.lottery-preset-list-wrap {
  background: var(--retro-cream);
  border: 3px solid var(--retro-blue);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 8px;
  max-height: 25vh;
  overflow-y: auto;
}
.preset-list-title {
  font-size: 13px; font-weight: 900; color: var(--retro-red);
  text-align: center; margin-bottom: 6px;
  border-bottom: 2px dashed var(--retro-blue);
  padding-bottom: 4px;
}
.preset-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px;
  background: white;
  border: 2px solid var(--retro-blue);
  border-radius: 8px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: all 0.2s;
}
.preset-list-item:active { transform: scale(0.97); }
.preset-item-name {
  flex: 1; font-size: 14px; font-weight: 700; color: #3a2a10;
}
.preset-item-count {
  font-size: 11px; color: var(--retro-blue); font-weight: 400;
}
.preset-item-del {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--retro-red);
  background: rgba(208,0,0,0.1); color: var(--retro-red);
  font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-left: 6px;
  transition: all 0.2s;
}
.preset-item-del:active { background: var(--retro-red); color: #fff; }
.preset-list-close {
  text-align: center; font-size: 12px; font-weight: 700;
  color: var(--retro-blue); cursor: pointer; padding: 4px 0;
  margin-top: 2px;
}
.preset-list-close:active { color: var(--retro-red); }

/* === Lottery Grid Container — 남은 공간 전부 사용 === */
.lottery-grid-container {
  flex: 1 1 0;
  min-height: 0; /* flex overflow 핵심 */
  display: flex; flex-direction: column;
  padding: 8px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, var(--retro-sky) 0%, var(--retro-cream) 50%, var(--retro-sky) 100%);
  border-left: 4px solid var(--retro-blue);
  border-right: 4px solid var(--retro-blue);
  position: relative;
}

/* Decorative pattern background */
.lottery-grid-container::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,117,143,0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(0,150,199,0.15) 0%, transparent 50%),
    radial-gradient(circle at 40% 80%, rgba(255,214,10,0.15) 0%, transparent 50%);
  pointer-events: none; z-index: 0;
}

.lottery-grid-container > * { position: relative; z-index: 1; }

/* === Lottery Status Bar === */
.lottery-status {
  text-align: center; padding: 8px 12px; margin-bottom: 6px;
  background: linear-gradient(135deg, var(--retro-red), #b00000);
  border-radius: 25px; position: sticky; top: 0; z-index: 10;
  box-shadow: 0 3px 0 var(--retro-blue), 0 5px 10px rgba(0,0,0,0.2);
  border: 2px solid white;
  flex-shrink: 0;
}

.lottery-status .status-text {
  color: #fff; font-weight: 700;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.3);
  font-size: 14px;
}

.picked-count { font-size: 12px; color: var(--retro-yellow); font-weight: 700; }

/* === Lottery Grid === */
.lottery-grid {
  display: grid; gap: 3px;
  background: var(--retro-red);
  padding: 6px; border-radius: 12px;
  box-shadow: 0 6px 0 var(--retro-blue), 0 10px 16px rgba(0,0,0,0.3);
  width: 100%; max-width: 500px; margin: 0 auto;
  /* 그리드가 컨테이너에 맞도록 */
  box-sizing: border-box;
}

/* === Lottery Cell === */
.lottery-cell {
  aspect-ratio: 1;
  background: linear-gradient(135deg, var(--retro-yellow) 0%, var(--retro-orange) 100%);
  border: 2px solid white;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 900; color: rgba(0,0,0,0.3);
  cursor: pointer; transition: all 0.3s;
  position: relative; transform-style: preserve-3d;
  perspective: 1000px;
  touch-action: manipulation;
  box-shadow: 0 2px 0 rgba(0,0,0,0.2), inset 0 1px 3px rgba(255,255,255,0.5);
  overflow: hidden;
  /* 최소 크기 제거 — 그리드 칸 수에 따라 자동 조절 */
  min-height: 0;
  min-width: 0;
}

/* Scratch pattern overlay */
.lottery-cell::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 5px,
    rgba(255,255,255,0.3) 5px,
    rgba(255,255,255,0.3) 10px
  );
  z-index: 1;
}

/* Question mark — hidden now since cell-content handles the ? text */
.lottery-cell::after {
  content: ''; /* disabled — number + ? rendered in cell-content */
  display: none;
}

/* Cell number (top-left corner) — 번호 명확히 표시 (BJ 사용 시 "몇 번 뽑아주세요" 용도) */
.cell-number {
  position: absolute;
  top: 2px; left: 2px;
  font-size: clamp(9px, 2.2vw, 14px);
  font-weight: 900;
  color: rgba(0,0,0,0.85);
  background: rgba(255,255,255,0.55);
  border-radius: 3px;
  padding: 0 2px;
  z-index: 3;
  line-height: 1.3;
  pointer-events: none;
  font-family: 'Noto Sans KR', sans-serif;
}

/* Unrevealed cell-content: show ? in center */
.lottery-cell:not(.revealed) .cell-content {
  position: relative;
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Black Han Sans', sans-serif;
  font-size: clamp(10px, 2.5vw, 16px);
  color: rgba(0,0,0,0.3);
  z-index: 2;
}

/* Hide number after cell is revealed */
.lottery-cell.revealed .cell-number { display: none; }

/* Cell tap effect */
.lottery-cell:active {
  transform: scale(1.08) rotate(3deg);
  box-shadow:
    0 4px 0 rgba(0,0,0,0.3),
    inset 0 2px 5px rgba(255,255,255,0.7),
    0 0 16px rgba(255,214,10,0.8);
}

/* Revealed cell */
.lottery-cell.revealed {
  background: linear-gradient(135deg, var(--retro-pink) 0%, var(--retro-purple) 100%);
  border-color: white;
  cursor: default;
  animation: lotteryRevealPop 0.5s ease-out;
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.2);
}

.lottery-cell.revealed::before { display: none; }
.lottery-cell.revealed::after { display: none; }

.lottery-cell.revealed .cell-content {
  color: white; font-size: clamp(7px, 2vw, 12px); padding: 2px 1px;
  text-align: center; word-break: break-word; line-height: 1.1;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  font-weight: 900; z-index: 3;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

@keyframes lotteryRevealPop {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes lotRevealFadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes lotRevealPop {
  0% { transform: scale(0.3) rotate(-10deg); opacity: 0; }
  60% { transform: scale(1.1) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* === My Result Panel === */
.my-result-panel {
  padding: 12px;
  background: white;
  border: 4px solid var(--retro-blue);
  border-radius: 12px; margin: 6px 8px;
  box-shadow: 0 6px 0 var(--retro-red), 0 10px 16px rgba(0,0,0,0.3);
  flex-shrink: 0;
  max-height: 25vh;
  overflow-y: auto;
}

.my-result-panel .result-label {
  font-family: 'Black Han Sans', sans-serif;
  font-size: 20px; color: var(--retro-blue);
  text-align: center; margin-bottom: 8px;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.1);
}

.result-list {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 15vh; overflow-y: auto;
}

.result-item {
  background: linear-gradient(135deg, var(--retro-yellow) 0%, var(--retro-orange) 100%);
  color: var(--retro-red);
  padding: 6px 14px; border-radius: 20px;
  font-weight: 700; font-size: 13px;
  border: 2px solid white;
  box-shadow: 0 2px 0 rgba(0,0,0,0.2);
  animation: lotteryResultPop 0.5s ease-out;
}

@keyframes lotteryResultPop {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  60% { transform: scale(1.2) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* === ROULETTE MODE === */
.roulette-display-container {
  flex: 1 1 0; min-height: 0;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  padding: 16px 12px; gap: 14px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  /* 짙은 녹색 벨벳 — 카지노 테이블 톤 */
  background: radial-gradient(ellipse at 50% 40%, #1a3a2a 0%, #0e2218 60%, #091510 100%);
  position: relative;
}

/* 은은한 텍스처 노이즈 */
.roulette-display-container::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='4' height='4' viewBox='0 0 4 4' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 3h1v1H1V3zm2-2h1v1H3V1z' fill='%23ffffff' fill-opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 0;
}

/* 상단 빛 줄기 */
.roulette-display-container::after {
  content: ''; position: absolute; top: -30%; left: 20%; right: 20%; height: 60%;
  background: radial-gradient(ellipse at 50% 0%, rgba(255,215,0,0.08) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}

/* Roulette Status */
.roulette-status {
  text-align: center; padding: 10px 16px;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-radius: 25px; width: 100%;
  border: 1px solid rgba(255,215,0,0.25);
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  position: relative; z-index: 1;
  flex-shrink: 0;
}

.roulette-status .status-text {
  color: #ffd700; font-weight: 700; font-size: 14px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  letter-spacing: 0.5px;
}

/* === Roulette Wheel === */
.roulette-wheel-container {
  position: relative;
  width: min(65vw, 55vh, 300px);
  display: flex; flex-direction: column; align-items: center;
  z-index: 1;
  flex-shrink: 0;
}

/* Pointer — CSS 삼각형 (폰트 대체) */
.roulette-pointer {
  width: 0; height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 28px solid #ffd700;
  margin-bottom: -6px; z-index: 10;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.6));
  position: relative;
  font-size: 0; color: transparent; /* 원래 ▼ 텍스트 숨김 */
}
.roulette-pointer::after {
  content: '';
  position: absolute; top: -28px; left: -10px;
  width: 0; height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 22px solid #ffe766;
}

.roulette-wheel {
  width: 100%; aspect-ratio: 1;
  position: relative;
  transition: transform 4s cubic-bezier(0.17, 0.67, 0.12, 0.99);
}

.roulette-wheel.spinning { transition: transform 4s cubic-bezier(0.17, 0.67, 0.12, 0.99); }

#rouletteCanvas {
  width: 100%; height: 100%; border-radius: 50%;
  /* 캔버스가 자체 림을 그리므로 CSS 테두리 최소화 */
  border: none;
  box-shadow:
    0 6px 20px rgba(0,0,0,0.5),
    0 0 40px rgba(255,215,0,0.08);
}

/* === Spin Button === */
.roulette-spin-btn {
  max-width: 240px; width: 100%;
  font-family: 'Black Han Sans', sans-serif;
  font-size: 20px; padding: 12px 24px; min-height: 48px;
  background: linear-gradient(180deg, #ffd700 0%, #e6a800 100%) !important;
  color: #2a1a00 !important;
  border: 2px solid rgba(255,255,255,0.3) !important;
  border-radius: 50px;
  box-shadow:
    0 4px 0 #8a6d00,
    0 6px 16px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.4);
  text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  touch-action: manipulation;
  position: relative; overflow: hidden;
  cursor: pointer; transition: all 0.15s ease;
  z-index: 1; flex-shrink: 0;
  letter-spacing: 1px;
}

.roulette-spin-btn::before {
  content: ''; position: absolute; top: 0; left: -100%; width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  transition: left 0.6s ease;
}

.roulette-spin-btn:hover::before { left: 150%; }

.roulette-spin-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #8a6d00, 0 3px 8px rgba(0,0,0,0.4);
}

.roulette-spin-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* === Result Display === */
.roulette-result-display {
  text-align: center; padding: 20px 24px;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,215,0,0.3);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 0 30px rgba(255,215,0,0.06);
  width: 100%; max-width: 280px;
  animation: resultPop 0.5s ease;
  min-height: 80px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 1; flex-shrink: 0;
}

@keyframes resultPop {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.result-emoji { font-size: 44px; margin-bottom: 8px; }

.result-text {
  font-family: 'Black Han Sans', sans-serif; font-size: 28px;
  color: #ffd700;
  text-shadow: 0 2px 8px rgba(255,215,0,0.3), 0 0 20px rgba(255,215,0,0.15);
  word-break: break-word;
}

.result-text.show {
  animation: rouletteResultReveal 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes rouletteResultReveal {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  60% { transform: scale(1.2) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* === WHEEL SPINNING EFFECTS === */
.wheel-active {
  animation: wheelGlow 0.4s ease-in-out infinite alternate;
}

@keyframes wheelGlow {
  from { filter: drop-shadow(0 0 15px rgba(255,215,0,0.3)) drop-shadow(0 0 30px rgba(255,215,0,0.1)); }
  to { filter: drop-shadow(0 0 35px rgba(255,215,0,0.7)) drop-shadow(0 0 70px rgba(255,215,0,0.3)); }
}

/* Pointer tick — pivots from top (flat edge), fast */
.roulette-pointer.ticking,
.roulette-pointer.ticking-slow {
  transform-origin: center top;
}

.roulette-pointer.ticking {
  animation: pointerTick 0.06s ease-in-out infinite alternate;
  filter: drop-shadow(0 3px 8px rgba(255,215,0,0.8));
}

/* Pointer tick — slow (anticipation) */
.roulette-pointer.ticking-slow {
  animation: pointerTick 0.3s ease-in-out infinite alternate;
  filter: drop-shadow(0 3px 12px rgba(255,80,80,0.9));
}

@keyframes pointerTick {
  0% { transform: rotate(-14deg) scale(1.15); }
  100% { transform: rotate(14deg) scale(1.15); }
}

/* Screen shake on result */
.result-shake {
  animation: resultShake 0.5s ease-out !important;
}

@keyframes resultShake {
  0%, 100% { transform: none; }
  10% { transform: translate(-7px, 2px) rotate(-0.5deg); }
  20% { transform: translate(7px, -2px) rotate(0.5deg); }
  30% { transform: translate(-5px, 1px); }
  40% { transform: translate(5px, -1px); }
  50% { transform: translate(-3px); }
  60% { transform: translate(3px); }
  70% { transform: translate(-1px); }
}

/* === CELEBRATION OVERLAY === */
.roulette-celebration {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 250;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.88);
  animation: celebFadeIn 0.3s ease;
  cursor: pointer;
}

.roulette-celebration.hiding {
  animation: celebFadeOut 0.5s ease forwards;
  pointer-events: none;
}

@keyframes celebFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes celebFadeOut { from { opacity: 1; } to { opacity: 0; } }

.celebration-content {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  animation: celebBounce 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes celebBounce {
  0% { transform: scale(0) rotate(-15deg); opacity: 0; }
  50% { transform: scale(1.15) rotate(3deg); }
  70% { transform: scale(0.95) rotate(-1deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Radial golden burst behind content */
.celebration-burst {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 380px; height: 380px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255,215,0,0.3) 0%,
    rgba(255,150,0,0.12) 35%,
    transparent 70%
  );
  animation: burstPulse 1.2s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes burstPulse {
  from { transform: translate(-50%,-50%) scale(0.7); opacity: 0.4; }
  to { transform: translate(-50%,-50%) scale(1.5); opacity: 1; }
}

/* Spinning ring */
.celebration-ring {
  position: absolute; top: 50%; left: 50%;
  width: 280px; height: 280px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: rgba(255,215,0,0.5);
  border-right-color: rgba(255,215,0,0.2);
  animation: ringRotate 2s linear infinite;
  pointer-events: none;
}

@keyframes ringRotate {
  from { transform: translate(-50%,-50%) rotate(0deg); }
  to { transform: translate(-50%,-50%) rotate(360deg); }
}

.celebration-emoji {
  font-size: 76px; line-height: 1;
  animation: celebEmojiPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s both;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.4));
}

@keyframes celebEmojiPop {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  60% { transform: scale(1.3) rotate(15deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.celebration-label {
  font-family: 'Black Han Sans', sans-serif;
  font-size: 18px; color: rgba(255,255,255,0.7);
  letter-spacing: 6px;
  margin-top: 8px;
  animation: celebLabelIn 0.4s ease 0.25s both;
}

@keyframes celebLabelIn {
  from { transform: translateY(15px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.celebration-result {
  font-family: 'Black Han Sans', sans-serif;
  font-size: clamp(28px, 10vw, 56px); line-height: 1.2;
  color: #ffd700;
  text-shadow:
    0 0 20px rgba(255,215,0,0.6),
    0 0 40px rgba(255,215,0,0.3),
    0 0 80px rgba(255,215,0,0.15),
    0 4px 12px rgba(0,0,0,0.6);
  margin-top: 12px; padding: 8px 24px;
  word-break: break-word; text-align: center;
  max-width: 85vw;
  animation: celebResultIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.35s both;
}

@keyframes celebResultIn {
  0% { transform: scale(0) translateY(30px); opacity: 0; }
  50% { transform: scale(1.2) translateY(-8px); }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.celebration-sub {
  font-size: 12px; color: rgba(255,255,255,0.3);
  margin-top: 24px;
  animation: celebSubIn 0.3s ease 1s both;
}

@keyframes celebSubIn {
  from { opacity: 0; } to { opacity: 1; }
}

/* === CONFETTI === */
.roulette-confetti-wrap {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none; z-index: 300; overflow: hidden;
}

@keyframes rrConfettiFall {
  0% {
    transform: translateY(0) translateX(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  20% { opacity: 1; }
  100% {
    transform: translateY(100vh) translateX(var(--drift, 0px)) rotate(720deg) scale(0.3);
    opacity: 0;
  }
}

/* ==========================================================
   RESPONSIVE — 모바일 (max-width: 430px)
   ========================================================== */
@media (max-width: 430px) {
  .lottery-top-bar { padding: 6px 10px; }
  .lottery-title { font-size: 18px; }
  .mode-tab { font-size: 13px; padding: 8px 10px; min-height: 36px; }

  .lottery-setup-panel, .roulette-setup-panel {
    padding: 10px; margin: 6px 8px;
  }
  .lottery-fields-container { max-height: 25vh; }

  .lottery-grid-container { padding: 6px; }
  .lottery-grid { gap: 2px; padding: 4px; border-radius: 8px; }
  .lottery-cell { border-width: 1.5px; border-radius: 3px; }

  .lottery-status { padding: 6px 10px; margin-bottom: 4px; }
  .lottery-status .status-text { font-size: 13px; }
  .picked-count { font-size: 11px; }

  .my-result-panel { padding: 8px; margin: 4px 6px; }
  .my-result-panel .result-label { font-size: 16px; margin-bottom: 6px; }
  .result-item { font-size: 12px; padding: 5px 10px; }

  .roulette-wheel-container { width: min(60vw, 50vh, 260px); }
  .roulette-display-container { padding: 8px; gap: 10px; }
  .roulette-spin-btn { font-size: 18px; padding: 10px; min-height: 44px; }
  .roulette-result-display { padding: 14px; }
  .result-text { font-size: 22px; }
  .result-emoji { font-size: 36px; }

  .celebration-emoji { font-size: 60px; }
  .celebration-result { font-size: 42px; }
  .celebration-burst { width: 280px; height: 280px; }
  .celebration-ring { width: 220px; height: 220px; }
}

/* ==========================================================
   RESPONSIVE — 작은 모바일 (max-width: 360px)
   ========================================================== */
@media (max-width: 360px) {
  .lottery-top-bar { padding: 4px 8px; }
  .lottery-title { font-size: 16px; }
  .mode-tab { font-size: 12px; padding: 6px 8px; min-height: 32px; }
  .mode-tabs { border-bottom-width: 2px; }

  .lottery-setup-panel, .roulette-setup-panel {
    padding: 8px; margin: 4px 6px; border-width: 3px;
  }
  .lottery-fields-container { max-height: 20vh; }
  .lottery-field-input { padding: 6px 8px; font-size: 13px; }
  .lottery-field-count { width: 44px; padding: 6px 2px; font-size: 13px; }

  .lottery-grid-container { padding: 4px; border-left-width: 3px; border-right-width: 3px; }
  .lottery-grid { gap: 1.5px; padding: 3px; }
  .lottery-cell { border-width: 1px; border-radius: 2px; }
  .cell-number { font-size: clamp(6px, 1.4vw, 9px); }
  .lottery-cell:not(.revealed) .cell-content { font-size: clamp(8px, 2vw, 12px); }
  .lottery-cell.revealed .cell-content { font-size: clamp(6px, 1.8vw, 10px); }

  .lottery-status { padding: 4px 8px; border-width: 2px; }
  .lottery-status .status-text { font-size: 12px; }

  .roulette-wheel-container { width: min(55vw, 45vh, 220px); }
  .roulette-pointer {
    border-left-width: 10px; border-right-width: 10px; border-top-width: 20px;
  }
  .roulette-pointer::after {
    top: -20px; left: -7px;
    border-left-width: 7px; border-right-width: 7px; border-top-width: 16px;
  }
  .roulette-spin-btn { font-size: 16px; padding: 8px; }
  .roulette-result-display { padding: 10px; min-height: 60px; }
  .result-text { font-size: 18px; }
  .result-emoji { font-size: 28px; }

  .celebration-emoji { font-size: 48px; }
  .celebration-result { font-size: 34px; }
  .celebration-label { font-size: 14px; letter-spacing: 4px; }
  .celebration-burst { width: 220px; height: 220px; }
  .celebration-ring { width: 180px; height: 180px; }
}

/* ==========================================================
   RESPONSIVE — 가로 모드 (landscape, short viewport)
   ========================================================== */
@media (orientation: landscape) and (max-height: 500px) {
  .lottery-top-bar { padding: 2px 10px; }
  .lottery-title { font-size: 14px; }
  .mode-tabs { border-bottom-width: 2px; }
  .mode-tab { padding: 4px 8px; font-size: 12px; min-height: 28px; }

  .lottery-setup-panel, .roulette-setup-panel {
    padding: 6px 8px; margin: 4px 6px; border-width: 3px;
    box-shadow: 0 3px 0 var(--retro-red);
  }
  .lottery-fields-container { max-height: 30vh; }

  .lottery-grid-container { padding: 4px; }
  .lottery-grid {
    gap: 2px; padding: 4px;
    max-width: 70vh; /* 가로모드: 높이 기준 제한 */
  }
  .lottery-status { padding: 3px 8px; margin-bottom: 3px; }
  .lottery-status .status-text { font-size: 12px; }

  .my-result-panel {
    padding: 4px 6px; margin: 2px 4px;
    max-height: 20vh;
  }
  .my-result-panel .result-label { font-size: 14px; margin-bottom: 4px; }

  .roulette-wheel-container { width: min(50vw, 55vh, 240px); }
  .roulette-display-container { gap: 6px; padding: 6px; flex-direction: column; }
  .roulette-spin-btn { font-size: 14px; padding: 6px 16px; min-height: 32px; }
  .roulette-result-display { padding: 8px; min-height: 50px; }
  .result-emoji { font-size: 24px; margin-bottom: 2px; }
  .result-text { font-size: 16px; }

  .celebration-emoji { font-size: 48px; }
  .celebration-result { font-size: 36px; }
  .celebration-burst { width: 200px; height: 200px; }
  .celebration-ring { width: 160px; height: 160px; }
}
