/* 코스피 7400 운세 — E 컨셉 (한국 운세 / 한지+인장) */

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  padding: 32px 16px 48px;
  font-family: 'Nanum Myeongjo', 'Gowun Batang', serif;
  color: #1a1a1a;
  background:
    radial-gradient(circle at 30% 20%, rgba(183,28,28,.06) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(200,169,81,.08) 0%, transparent 40%),
    repeating-linear-gradient(0deg, rgba(0,0,0,.015) 0 1px, transparent 1px 4px),
    #f3ead4;
}

.page {
  max-width: 520px; margin: 0 auto;
  background:
    repeating-linear-gradient(45deg, rgba(0,0,0,.012) 0 2px, transparent 2px 5px),
    #f5ecd2;
  border: 1px solid #d8c89e;
  box-shadow: 0 1px 0 #e2d5a8 inset, 0 20px 50px rgba(60,30,10,.12);
  padding: 28px;
  position: relative;
}

.page::before {
  content: "壽福";
  position: absolute; top: 10px; right: 18px;
  font-size: 80px; color: rgba(183,28,28,.06); font-weight: 800;
  line-height: 1; pointer-events: none;
}

/* 광고 */
.ad {
  border: 1px dashed #b89770;
  min-height: 96px;
  padding: 10px;
  text-align: center;
  color: #8a6a3e;
  font-size: 12px;
  letter-spacing: .15em;
  margin-bottom: 18px;
  background: rgba(255,253,245,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ad--inline { margin-top: -2px; }
.ad--result { margin: 16px 0 0; }
.ad[data-ad-state="live"] {
  border-style: solid;
  padding: 0;
  background: transparent;
}
.ad .adsbygoogle {
  width: 100%;
  min-height: 90px;
}

/* 헤더 */
.header {
  text-align: center; padding: 8px 0 14px;
  border-bottom: 2px solid #1a1a1a; margin-bottom: 18px;
}
.header::after {
  content: ""; display: block; height: 1px; background: #1a1a1a; margin-top: 4px;
}
.title {
  font-size: 28px; font-weight: 800; letter-spacing: .12em; color: #1a1a1a;
}
.title .red { color: #b71c1c; }
.sub {
  font-size: 13px; color: #5a4a30; letter-spacing: .25em; margin-top: 6px;
}

/* 메인 */
.scroll {
  position: relative;
  border: 2px solid #1a1a1a; padding: 30px 18px; text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(183,28,28,.08), transparent 60%),
    #fdf6dd;
  margin-bottom: 16px;
}
.scroll::before, .scroll::after {
  content: ""; position: absolute; left: 8px; right: 8px; height: 1px; background: #1a1a1a;
}
.scroll::before { top: 8px; }
.scroll::after { bottom: 8px; }

.question {
  font-size: 22px; font-weight: 700; line-height: 1.7; letter-spacing: .05em;
}
.question b { color: #b71c1c; }

.dice-stage {
  display: flex; align-items: center; justify-content: center;
  height: 160px; margin: 14px auto 8px;
  perspective: 600px;
}

.dice {
  width: 110px; height: 110px;
  background: #1a1a1a; color: #f5ecd2;
  border-radius: 18px;
  display: grid; grid-template-columns: repeat(3, 1fr); padding: 18px; gap: 6px;
  box-shadow: 0 8px 0 #b71c1c;
  transform: rotate(-6deg);
  transition: transform .25s ease;
}
.dice.rolling {
  animation: dice-roll 1.2s cubic-bezier(.4,1.6,.6,1);
}
.dice.popped {
  animation: dice-pop .35s ease;
}
.dice span {
  background: #f5ecd2; border-radius: 50%;
}
.dice .hide { background: transparent; }

@keyframes dice-roll {
  0%   { transform: rotate(-6deg) translateY(0)   scale(1); }
  20%  { transform: rotate(140deg) translateY(-50px) scale(1.05); }
  40%  { transform: rotate(360deg) translateY(-15px) scale(1); }
  60%  { transform: rotate(540deg) translateY(-30px) scale(.95); }
  80%  { transform: rotate(680deg) translateY(-5px) scale(1); }
  100% { transform: rotate(720deg) translateY(0)   scale(1); }
}

@keyframes dice-pop {
  0%   { transform: rotate(-6deg) scale(1); }
  50%  { transform: rotate(-6deg) scale(1.12); }
  100% { transform: rotate(-6deg) scale(1); }
}

.roll-btn {
  display: inline-block;
  margin-top: 8px; padding: 14px 36px;
  background: #b71c1c; color: #fdf6dd;
  border: 2px solid #1a1a1a;
  font-family: inherit; font-size: 18px; font-weight: 700; letter-spacing: .35em;
  cursor: pointer;
  box-shadow: 4px 4px 0 #1a1a1a;
  transition: transform .1s ease, box-shadow .1s ease;
}
.roll-btn:hover  { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 #1a1a1a; }
.roll-btn:active { transform: translate(2px, 2px);   box-shadow: 2px 2px 0 #1a1a1a; }
.roll-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: 4px 4px 0 #1a1a1a; }

.pool-foot {
  text-align: center; margin-top: 18px; font-size: 12px;
  color: #5a4a30; letter-spacing: .2em;
}

.status-line {
  min-height: 20px;
  margin-top: 12px;
  font-size: 12px;
  color: #8a6a3e;
  letter-spacing: .08em;
}
.status-line.error { color: #b71c1c; font-weight: 700; }
.status-line.ok { color: #5a4a30; }

.history-panel {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed #b89770;
  text-align: left;
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #5a4a30;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .18em;
}
.history-clear {
  flex: 0 0 auto;
  border: 1px solid #b89770;
  background: rgba(255,253,245,.45);
  color: #8a6a3e;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  padding: 4px 8px;
}
.history-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 1px solid #d8c89e;
  background: #fff7df;
  color: #1a1a1a;
  cursor: pointer;
  font-family: inherit;
  padding: 9px 10px;
  text-align: left;
}
.history-item:hover { border-color: #1a1a1a; }
.history-item b { font-size: 14px; }
.history-item span {
  min-width: 58px;
  color: #8a6a3e;
  font-size: 11px;
  letter-spacing: .08em;
  text-align: right;
}

/* 결과 */
.result {
  border: 2px solid #1a1a1a; padding: 22px 18px;
  background: #fdf6dd;
  position: relative;
  scroll-margin-top: 28px;
  animation: fadeUp .45s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.seal {
  position: absolute; top: -16px; right: -10px;
  width: 80px; height: 80px;
  background: #b71c1c;
  border-radius: 8px;
  color: #fdf6dd;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; line-height: 1.25; text-align: center; letter-spacing: .12em;
  transform: rotate(-8deg);
  box-shadow: 0 4px 0 rgba(0,0,0,.18);
  border: 3px double #fdf6dd;
}

.stock-row {
  display: flex; justify-content: space-between; align-items: end;
  padding-bottom: 12px; border-bottom: 1px solid #1a1a1a;
  gap: 12px;
}
.stock-name { font-size: 26px; font-weight: 800; letter-spacing: .04em; }
.stock-meta { font-size: 12px; color: #5a4a30; letter-spacing: .12em; margin-top: 4px; }
.price-box { flex: 0 0 auto; text-align: right; }
.price-now  { font-size: 24px; font-weight: 800; }
.price-diff { font-size: 13px; font-weight: 700; }
.price-diff.up   { color: #b71c1c; }
.price-diff.down { color: #1565c0; }

.lines {
  display: grid; grid-template-columns: repeat(2,1fr); gap: 14px;
  padding: 14px 0; border-bottom: 1px dashed #b89770;
}
.lines .l { font-size: 12px; color: #5a4a30; letter-spacing: .15em; margin-bottom: 4px; }
.lines .v { font-size: 16px; font-weight: 700; }
.lines .v.up   { color: #b71c1c; }
.lines .v.down { color: #1565c0; }

.chart-card {
  margin-top: 14px; padding: 12px; background: #fff7df; border: 1px solid #b89770;
}
.chart-meta {
  display: flex; justify-content: space-between;
  font-size: 11px; color: #5a4a30; letter-spacing: .15em; margin-bottom: 6px;
}

.fortune {
  margin-top: 16px; padding: 14px 16px;
  background: #1a1a1a; color: #fdf6dd;
  line-height: 1.7; font-size: 14px;
}
.fortune .h {
  color: #ffd54f; font-size: 12px; letter-spacing: .25em; margin-bottom: 6px;
}
.fortune-line {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed rgba(253,246,221,.25);
  font-style: italic; color: #ffe9a8;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.share-btn,
.reroll-btn {
  display: block; width: 100%; padding: 12px;
  background: transparent; color: #1a1a1a;
  border: 2px solid #1a1a1a;
  font-family: inherit; font-size: 14px; font-weight: 700; letter-spacing: .25em;
  cursor: pointer;
  transition: background .15s ease;
}
.share-btn {
  background: #1a1a1a;
  color: #fdf6dd;
}
.share-btn:hover,
.reroll-btn:hover { background: #b71c1c; color: #fdf6dd; }
.share-btn:disabled,
.reroll-btn:disabled { opacity: .5; cursor: not-allowed; }

/* 푸터 */
.foot {
  margin-top: 24px; padding: 14px;
  font-size: 11px; color: #8a6a3e; line-height: 1.6; text-align: center;
  border-top: 1px dashed #b89770;
}
.foot p { margin: 0; }
.foot p + p { margin-top: 8px; }
.foot a { color: inherit; text-underline-offset: 3px; }

.policy {
  border: 2px solid #1a1a1a;
  padding: 22px 18px;
  background: #fdf6dd;
  line-height: 1.8;
}
.policy h1 {
  margin: 0 0 12px;
  font-size: 24px;
  letter-spacing: .08em;
}
.policy h2 {
  margin: 22px 0 8px;
  font-size: 16px;
  letter-spacing: .08em;
}
.policy p,
.policy li {
  color: #3d3322;
  font-size: 14px;
}
.policy ul {
  padding-left: 18px;
}
.policy a {
  color: #8a1b1b;
  text-underline-offset: 3px;
}
.policy-back {
  display: inline-block;
  margin-bottom: 16px;
  color: #8a1b1b;
  font-size: 13px;
  font-weight: 700;
  text-underline-offset: 3px;
}

@media (max-width: 460px) {
  body { padding: 16px 10px 32px; }
  .page { padding: 20px 14px; }
  .title { font-size: 23px; letter-spacing: .08em; }
  .question { font-size: 19px; }
  .roll-btn { width: 100%; padding-inline: 12px; letter-spacing: .22em; }
  .stock-row {
    align-items: start;
    flex-direction: column;
  }
  .price-box {
    width: 100%;
    text-align: left;
  }
  .result-actions { grid-template-columns: 1fr; }
  .share-btn,
  .reroll-btn { letter-spacing: .18em; }
}
