*, *::before, *::after {
  box-sizing: border-box;
}

/* --- 구매 페이지 전용 스타일 --- */

/* =======================
   상단 배너
   ======================= */
.buy-banner {
  background-color: var(--surface-color);
  color: var(--text-color);
  padding-top: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}
.buy-banner .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

.jackpot-badge {
  border-radius: 50px;
  padding: 8px;
  display: flex;
  align-items: center;
}
.jackpot-badge img { height: 120px; max-width: 100%; }
.jackpot-badge span {
  padding: 0 1.5rem 0 1rem;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-muted-color);
}
.jackpot-badge span strong {
  font-size: 1.3rem;
  display: block;
  color: var(--text-color);
}

.banner-center { text-align: center; }
.banner-center h4 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--text-muted-color);
  font-weight: 500;
}
.prize-info { display: flex; align-items: center; gap: 1rem; }
.prize-amount {
  font-family: var(--font-family-display);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-color);
}
.prize-amount small { font-size: 1.5rem; font-weight: 600; }

.rollover-tag {
  background-color: #f59e0b;
  color: #1e293b;
  padding: 6px 12px;
  font-weight: 700;
  font-size: 0.9rem;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.draw-info-box {
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1rem;
}
.draw-info-box p { margin: 0.5rem 0; font-size: 0.9rem; color: var(--text-muted-color); }
.draw-info-box p strong { color: var(--text-color); }
.draw-info-box .label { display: inline-block; width: 35px; font-weight: 700; }
.draw-info-box .label.kor { color: #60a5fa; }
.draw-info-box .label.usa { color: #f87171; }

.banner-countdown-wrapper {
  background-color: rgba(0, 0, 0, 0.1);
  padding: 0.8rem 0;
  margin-top: 1.5rem;
  font-size: 1rem;
  color: var(--text-muted-color);
}
.dark-mode .banner-countdown-wrapper {
  background-color: rgba(0, 0, 0, 0.2);
}
.banner-countdown-wrapper .container {
  justify-content: center;
  gap: 2rem;
}
.countdown-group {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.countdown-group strong { color: var(--text-color); }
.timer {
  font-family: var(--font-family-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--highlight-color);
}
.deadline-text { font-size: 0.9rem; }


/* =======================
   메인 콘텐츠
   ======================= */
.buy-main-content { padding: 3rem 0; background-color: var(--bg-color); }

.buy-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
  max-width: 1280px;
  padding: 0;
  width: 100%;
}

.buy-form { display: flex; flex-direction: column; gap: 2rem; }

.form-step {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.5rem;
}

.step-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}
.step-title h4 { margin: 0; font-size: 1.2rem; font-weight: 700; color: var(--text-color); }
.step-title h5 { margin: 0; font-size: 1.0rem; font-weight: 700; color: var(--text-color); }
.step-title select {
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--text-color);
  font-size: 0.9rem;
}

.grid-buttons { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.grid-buttons button {
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-muted-color);
  font-weight: 600;
}
.grid-buttons button:hover { color: var(--text-color); border-color: var(--primary-color); }
.grid-buttons button.active { background-color: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.grid-buttons.method { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }

.number-selection-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); gap: 1.5rem; }

.number-pad { display: grid; gap: 8px; }
.number-pad.white-ball { grid-template-columns: repeat(7, 1fr); }
.number-pad.mega-ball  { grid-template-columns: repeat(6, 1fr); }
.number-pad.power-ball { grid-template-columns: repeat(6, 1fr); }

.number-pad button {
  border: 1px solid var(--border-color);
  background-color: var(--surface-color);
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-color);
  font-weight: 600;
}
.number-pad button:hover { background-color: var(--bg-color); border-color: var(--primary-color); }
.number-pad button.selected {
  background-color: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
  box-shadow: 0 0 10px rgba(79, 70, 229, 0.5);
}
.number-pad.power-ball button.selected {
  background-color: #c62828;
  color: #fff;
  border-color: var(--primary-color);
  box-shadow: 0 0 10px rgba(79, 70, 229, 0.5);
}


/* =======================
   오른쪽 카트
   ======================= */
.game-cart {
  /*  background-color: var(--surface-color);
  border: 1px solid var(--border-color); 2026-02-19 삭제*/
  border-radius: var(--border-radius);
}

.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}
.cart-header h4 {
  margin: 0;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
}
.cart-header a { font-size: 0.9rem; color: #fff; }
/* .cart-header h4, .cart-header a 폰트 색상 변경 2026-02-19 */

/* =========================
   Game List (cart-list) 카드형 그리드 UI (핵심 개선)
   ========================= */
.cart-list{
  padding: 12px;
/*   border-bottom: 1px solid var(--border-color); 2026-02-19 삭제 */
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center; /* 카드가 중앙축에 안정적으로 */
}
.cart-list, .cart-summary {
  background-color: var(--surface-color);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  border-left: 1px solid var(--border-color);
}/* 2026-02-19 추가 */

/* 카드 */
.cart-list .list-item{
  width: 100%;
  max-width: 560px;
  margin: 0 auto;

  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas:
    "title reselect auto"
    "nums  nums     nums";
  gap: 10px 8px;

  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--surface-color);

  min-width: 0;
}

/* 기존 odd 배경은 카드형에선 불필요 */
.cart-list .list-item:nth-child(odd){
  background: var(--surface-color);
}

/* 타이틀 */
.cart-list .list-item > span{
  grid-area: title;
  font-weight: 800;
  color: var(--text-color);
  white-space: nowrap;
  min-width: 0;
}

/* 숫자 줄: 가운데 정렬로 좌측 쏠림 완화 */
.cart-list .list-item .numbers{
  grid-area: nums;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: 0;              /* 기존 margin-left:auto 영향 차단 */
  min-width: 0;
  justify-content: center;
}

/* 공 */
.num{
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(26px, 7.2vw, 32px);
  height: clamp(26px, 7.2vw, 32px);
  border-radius: 50%;
  background-color: var(--bg-color);
  font-size: clamp(12px, 3.1vw, 15px);
  font-weight: 800;
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

/* 메가(주황) */
.num.mega{
  background-color: #f59e0b;
  color: #fff;
  border: none;
}

/* 파워볼(빨강) */
.num.power{
  background-color: #ef4444;
  color: #fff;
  border: none;
}

/* 빈칸 */
.num.empty{
  background-color: var(--bg-color);
  border: 2px dashed var(--border-color);
}

/* 버튼 */
.btn-edit{
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-muted-color);
  font-size: 12px;
  font-weight: 800;
  padding: 7px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
  white-space: nowrap;
}
.btn-edit:hover{ background-color: var(--bg-color); color: var(--text-color); }

.cart-list .list-item .btn-edit[data-action="reselect"]{ grid-area: reselect; justify-self: end; align-self: start; }
.cart-list .list-item .btn-edit[data-action="edit"]{
  grid-area: auto;
  justify-self: end;
  align-self: start;
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* 편집/에러 강조 */
.list-item.editing{
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.list-item.error{
  border: 2px solid var(--highlight-color);
  animation: shake 0.5s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* 아주 작은 화면: 버튼을 2열로 내리고 숫자 왼쪽 정렬 */
@media (max-width: 380px){
  .cart-list .list-item{
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "title title"
      "reselect auto"
      "nums nums";
  }
  .cart-list .list-item .btn-edit{
    width: 100%;
    text-align: center;
    justify-self: stretch;
  }
  .cart-list .list-item .numbers{
    justify-content: flex-start;
  }
}


/* =======================
   결제/요약 영역
   ======================= */
.cart-summary { padding: 1.5rem; border-bottom: 1px solid var(--border-color); }

.summary-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; }
.summary-row:last-child { margin-bottom: 0; }
.summary-row > span { font-weight: 600; color: var(--text-color); }

.summary-row .value {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted-color);
}
.summary-row .value strong { font-size: 1.1rem; color: var(--text-color); font-weight: 700; }

.btn-charge {
  background-color: var(--text-muted-color);
  color: var(--surface-color);
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}

.summary-row.total span,
.summary-row.total .value strong {
  color: var(--primary-color);
  font-size: 1.3rem;
  font-weight: 700;
}

.cart-options {
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  border-bottom: 1px solid var(--border-color);
}
.cart-options label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-color);
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  font-size: 1rem;
}
.cart-options input[type="checkbox"] { display: none; }

.cart-options .checkbox-icon {
  width: 22px;
  height: 22px;
  border: 2px solid var(--text-muted-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: all 0.3s ease;
}
.cart-options i.fa-question-circle { color: var(--text-muted-color); }

.cart-options input[type="checkbox"]:checked + .checkbox-icon {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: #fff;
}
.cart-options input[type="checkbox"]:checked + .checkbox-icon + span { color: var(--primary-color); }
.cart-options label:hover { border-color: var(--primary-color); }

.cart-options label span {
  color: var(--text-color);
  transition: color .2s ease, opacity .2s ease;
}

.order-btn { width: calc(100% - 3rem); /* margin: 1.5rem; */ padding: 18px; font-size: 1.2rem; margin-top: 2rem; }
/* 주문버튼 위치 수정 2026-02-19 */


/* =======================
   토스트
   ======================= */
.toast-notification {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: rgba(30, 41, 59, 0.9);
  color: #fff;
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transition: transform 0.4s ease, opacity 0.4s ease;
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
  backdrop-filter: blur(5px);
}
.toast-notification.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}


/* =======================
   자동선택 안내
   ======================= */
.auto-selection-placeholder {
  display: none;
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem;
  background-color: var(--bg-color);
  border-radius: var(--border-radius);
  border: 1px dashed var(--border-color);
  color: var(--text-muted-color);
}
.auto-selection-placeholder i { font-size: 2rem; margin-bottom: 1rem; }
.auto-selection-placeholder p { font-size: 1.1rem; font-weight: 600; margin: 0; }

.number-selection-grid.auto-mode .form-step { display: none; }
.number-selection-grid.auto-mode .auto-selection-placeholder { display: block; }


/* =======================
   도움말 툴팁
   ======================= */
.help-tooltip {
  position: fixed;
  background-color: var(--surface-color);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 15px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.15);
  z-index: 10000;
  font-size: 0.9rem;
  max-width: 280px;
  text-align: left;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.help-tooltip.show { opacity: 1; transform: translateY(0); }
.help-tooltip::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background-color: var(--surface-color);
  border-top: 1px solid var(--border-color);
  border-left: 1px solid var(--border-color);
}


/* =======================
   즐겨찾기 번호 모달 리스트(기존 유지)
   ======================= */
.mynum-row{display:flex;align-items:center;gap:10px;padding:8px;border-bottom:1px solid var(--border-color);}
.mynum-row .nums{display:flex;gap:6px;margin-left:auto;}
.mynum-row .nums .ball{width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;border:1px solid var(--border-color);}
.mynum-row .nums .mega{background:#f59e0b;color:#fff;border:none;}

#mynumList .mynum-row{
  display:flex; align-items:center; gap:10px;
  padding:10px; border:1px solid var(--border-color);
  border-radius:8px; margin-bottom:8px; position:relative;
  background:var(--surface-color);
}
#mynumList .mynum-row .nums { display:flex; gap:6px; flex-wrap:wrap; }
#mynumList .mynum-row .ball{
  display:inline-flex; align-items:center; justify-content:center;
  width:28px; height:28px; border-radius:50%;
  border:1px solid var(--border-color); font-weight:700;
  color:var(--text-color); background:var(--bg-color); font-size:.9rem;
}
#mynumList .mynum-row .ball.mega{ background:#f59e0b; color:#fff; border:none; }
#mynumList .mynum-row .ball.power{ background:#ff5a5a; color:#fff; border:none; }
#mynumList .mynum-row.is-dup{ border-color:#f59e0b; background:rgba(245,158,11,.08); }
#mynumList .mynum-row .dup-badge{
  margin-left:6px; font-size:12px; line-height:1;
  background:#f59e0b; color:#1f2937; padding:3px 8px;
  border-radius:999px; font-weight:800;
}

/* 즐겨찾기 모달 최상단 */
#mynumModal{
  position: fixed;
  inset: 0;
  display: none;
  z-index: 2147483647;
  background: rgba(0,0,0,.45);
  align-items: center;
  justify-content: center;
}
body.modal-open { overflow: hidden; }


/* =======================
   FAQ(아코디언)
   ======================= */
.buy-faq-section{
  background: var(--bg-color);
  padding: 2.5rem 0 3rem;
}

.buy-faq{
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 1280px;
  margin: 0 auto;
}
.buy-faq__item{
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
}
.buy-faq__q{
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.buy-faq__qtext{
  font-weight: 600;
  color: var(--text-color);
  font-size: 1rem;
  line-height: 1.3;
}
.buy-faq__icon{
  color: var(--text-muted-color);
  transition: transform .2s ease;
}
.buy-faq__item.is-open .buy-faq__icon{ transform: rotate(180deg); }

.buy-faq__a{
  border-top: 1px solid var(--border-color);
  padding: 0 16px;
  overflow: hidden;
  max-height: 0;
  transition: max-height .25s ease;
}
.buy-faq__a p{
  margin: 12px 0 14px;
  color: var(--text-muted-color);
  line-height: 1.7;
  font-size: .95rem;
}


/* =======================
   모바일 오버플로우 방지(핵심)
   ======================= */
.buy-grid,
.buy-form,
.game-cart,
.form-step,
.step-title,
.cart-header {
  min-width: 0;
}

.step-title{
  flex-wrap: wrap;
  gap: 10px;
}
.step-title select{ max-width: 100%; }

.cart-header{
  flex-wrap: wrap;
  gap: 8px;
}

/* =======================
   반응형
   ======================= */
@media(max-width: 1200px){
  .buy-grid { grid-template-columns: 1fr; }
  .game-cart { margin-top: 2rem; }
  .number-pad.mega-ball { grid-template-columns: repeat(7, 1fr); }
  .number-pad.power-ball { grid-template-columns: repeat(7, 1fr); }
}

@media(max-width: 768px){
  .buy-banner .container { flex-direction: column; gap: 1.5rem; }

  .buy-form .grid-buttons{
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 8px;
  }
  .buy-form .grid-buttons button{
    padding: 10px 5px;
    font-size: 0.9rem;
  }
  .form-step{ padding: 0.7rem; }
  .grid-buttons.method{ grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .number-selection-grid{ grid-template-columns: 1fr; }

  .step-title{
    flex-direction: column;
    align-items: flex-start;
  }
  .step-title select{ width: 100%; }

  .cart-header > div{
    width: 100%;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
  }

  .buy-faq-section{ padding: 2rem 0 2.5rem; }
  .buy-faq__q{ padding: 12px 14px; }
  .buy-faq__qtext{ font-size: .98rem; }
}

/* 모바일 쏠림 해결: 컨테이너 좌우 패딩 복구 */
@media (max-width: 440px){
  .container{
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
}

@media (min-width: 769px){
  /* 1행: title | numbers | reselect | auto */
  .cart-list .list-item{
    grid-template-columns: auto 1fr auto auto;
    grid-template-areas: "title nums reselect auto";
    align-items: center;
  }

  /* 번호는 한 줄로, 우측 정렬(기존 느낌) */
  .cart-list .list-item .numbers{
    flex-wrap: nowrap;          /* 줄바꿈 금지 */
    justify-content: flex-end;  /* 우측 정렬 */
  }
}

/* =========================
   모바일: Game List 번호를 가로 꽉 차게(6칸 균등)
   ========================= */
@media (max-width: 768px){

  /* 카드가 중앙에서 안정적으로 보이게 */
  .cart-list{
    padding: 12px !important;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch; /* center 말고 stretch */
  }

  /* 모바일에서는 카드형 grid 레이아웃 */
  .cart-list .list-item{
    width: 100%;
    max-width: 560px;
    margin: 0 auto;

    display: grid;
    grid-template-columns: 1fr auto auto;
    grid-template-areas:
      "title reselect auto"
      "nums  nums     nums";
    gap: 10px 8px;

    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--surface-color);

    min-width: 0;
  }

  .cart-list .list-item > span{ grid-area: title; }

  .cart-list .list-item .btn-edit[data-action="reselect"]{ grid-area: reselect; }
  .cart-list .list-item .btn-edit[data-action="edit"]{ grid-area: auto; }

  /* 버튼은 동일 폭으로 */
  .cart-list .list-item .btn-edit{
    justify-self: stretch;
    width: 100%;
    text-align: center;
  }

  /* 핵심: 번호 6개를 그리드로 균등 분배 */
  .cart-list .list-item .numbers{
    grid-area: nums;
    width: 100%;
    margin-left: 0 !important; /* 기존 margin-left:auto 무력화 */

    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
  }

  /* 공 크기를 카드 폭에 맞춰 자동 확장 */
  .cart-list .list-item .num{
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    font-size: clamp(12px, 3.6vw, 15px);
  }
}

/* 아주 작은 화면은 간격만 살짝 줄이기 */
@media (max-width: 380px){
  .cart-list .list-item .numbers{ gap: 6px; }
}

/* =========================
   PC: 기존처럼 한 줄(기존 flex + 고정 공 크기)
   ========================= */
@media (min-width: 769px){
  .cart-list .list-item{
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 0;              /* 모바일 카드 border 제거 */
    background: initial;     /* nth-child 배경 규칙 그대로 사용 */
    border-radius: 8px;      /* 기존 값 */
    margin: 0;
    max-width: none;
  }

  .cart-list .list-item .numbers{
    display: flex;
    gap: 6px;
    margin-left: auto;
    width: auto;
  }

  .cart-list .list-item .num{
    width: 32px;
    height: 32px;
    aspect-ratio: auto;
    font-size: 0.95rem;
  }
}
