:root {
  color-scheme: dark;
  --ink: #f8efe6;
  --muted: #cdbfb5;
  --soft: rgba(248, 239, 230, 0.08);
  --panel: rgba(22, 23, 30, 0.88);
  --panel-strong: rgba(31, 33, 42, 0.96);
  --line: rgba(248, 239, 230, 0.16);
  --gold: #d8b75f;
  --rose: #d9778c;
  --teal: #69c8bd;
  --violet: #9b8bd3;
  --shadow: rgba(0, 0, 0, 0.34);
  font-family:
    Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 18%, rgba(217, 119, 140, 0.2), transparent 24rem),
    radial-gradient(circle at 88% 10%, rgba(105, 200, 189, 0.18), transparent 22rem),
    linear-gradient(135deg, #141419 0%, #282129 44%, #152426 100%);
}

button,
textarea,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(19rem, 26rem) minmax(22rem, 1fr) minmax(16rem, 22rem);
  gap: 1rem;
  width: min(98rem, calc(100vw - 2rem));
  min-height: 100vh;
  margin: 0 auto;
  padding: 1rem 0;
}

.reader-panel,
.table-panel,
.history-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 1.25rem 3.5rem var(--shadow);
  backdrop-filter: blur(18px);
}

.reader-panel {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 1.25rem;
  border-radius: 0.5rem;
}

.reader-copy {
  display: grid;
  gap: 0.75rem;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 12ch;
  font-size: clamp(2.35rem, 5vw, 4.35rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  font-size: 1.02rem;
}

.intro {
  color: var(--muted);
  line-height: 1.65;
}

.daily-oracle {
  border: 1px solid rgba(216, 183, 95, 0.32);
  border-radius: 0.5rem;
  padding: 0.8rem;
  color: #f4ddb0;
  background: rgba(216, 183, 95, 0.1);
  line-height: 1.45;
}

.controls,
.field {
  display: grid;
  gap: 0.7rem;
}

.field span,
legend {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.field b {
  float: right;
  color: var(--gold);
  font-weight: 900;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

textarea {
  width: 100%;
  min-height: 6.25rem;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.85rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

textarea:focus {
  border-color: rgba(216, 183, 95, 0.72);
  box-shadow: 0 0 0 0.2rem rgba(216, 183, 95, 0.12);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

.emotion-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.emotion-button,
.primary-button,
.secondary-button,
.spread-option,
.tone-option,
.icon-button {
  cursor: pointer;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    opacity 160ms ease;
}

.emotion-button {
  display: grid;
  grid-template-columns: 1.9rem 1fr;
  align-items: center;
  min-height: 4.15rem;
  border-radius: 0.5rem;
  padding: 0.58rem;
  text-align: left;
}

.emotion-mark {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--emotion-color);
  color: #171418;
  font-weight: 900;
}

.emotion-copy {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
  padding-left: 0.45rem;
}

.emotion-label {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 900;
}

.emotion-hint {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.25;
}

.emotion-button:hover,
.spread-option:hover,
.tone-option:hover,
.primary-button:hover,
.secondary-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  border-color: rgba(248, 239, 230, 0.36);
}

.emotion-button.is-selected,
.spread-option:has(input:checked),
.tone-option:has(input:checked) {
  border-color: var(--gold);
  background: rgba(216, 183, 95, 0.16);
}

.spread-row,
.tone-row {
  display: grid;
  gap: 0.6rem;
}

.spread-row {
  grid-template-columns: repeat(2, 1fr);
}

.tone-row {
  grid-template-columns: repeat(3, 1fr);
}

.spread-option,
.tone-option {
  display: grid;
  place-items: center;
  min-height: 2.65rem;
  border-radius: 0.5rem;
  font-weight: 900;
}

.spread-option input,
.tone-option input {
  position: absolute;
  opacity: 0;
}

.primary-button,
.secondary-button {
  min-height: 3rem;
  border-radius: 0.5rem;
  font-weight: 900;
}

.primary-button {
  background: linear-gradient(135deg, #d8b75f, #d9778c);
  color: #171418;
}

.secondary-button {
  padding: 0 0.95rem;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.table-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  overflow: hidden;
  min-height: 42rem;
  border-radius: 0.5rem;
  padding: 1.25rem;
}

.sky-stage {
  position: relative;
  height: 14rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    radial-gradient(circle at 50% 30%, rgba(216, 183, 95, 0.2), transparent 12rem),
    linear-gradient(180deg, rgba(9, 12, 19, 0.32), rgba(9, 12, 19, 0.82));
  background-size:
    2.4rem 2.4rem,
    2.4rem 2.4rem,
    auto,
    auto;
}

.moon {
  position: absolute;
  left: 50%;
  top: 2rem;
  width: 7rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 34%, #fff7de 0 0.45rem, transparent 0.5rem),
    radial-gradient(circle at 65% 63%, rgba(30, 30, 40, 0.18) 0 0.6rem, transparent 0.65rem),
    #e3ca79;
  box-shadow: 0 0 3rem rgba(216, 183, 95, 0.55);
  transform: translateX(-50%);
}

.orbit {
  position: absolute;
  left: 50%;
  top: 50%;
  border: 1px solid rgba(248, 239, 230, 0.16);
  border-radius: 50%;
  transform: translate(-50%, -50%) rotate(-18deg);
}

.orbit-one {
  width: 18rem;
  height: 7rem;
}

.orbit-two {
  width: 25rem;
  height: 10rem;
}

.star {
  position: absolute;
  width: 0.42rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 1rem var(--ink);
}

.star-one {
  left: 18%;
  top: 30%;
}

.star-two {
  right: 21%;
  top: 22%;
}

.star-three {
  right: 34%;
  bottom: 24%;
}

.reading-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 0 0.55rem;
}

.reading-status {
  min-height: 2.7rem;
  color: var(--muted);
  line-height: 1.45;
}

.ritual-strip {
  min-height: 2.3rem;
  margin-bottom: 0.7rem;
  border-left: 3px solid var(--teal);
  padding: 0.4rem 0 0.4rem 0.75rem;
  color: #d9eee9;
  line-height: 1.45;
}

.card-table {
  display: grid;
  grid-template-columns: repeat(3, minmax(9.2rem, 1fr));
  align-items: stretch;
  gap: 0.85rem;
}

.card-table.is-shuffling .tarot-card {
  animation: shuffle 520ms ease both;
}

.tarot-card {
  position: relative;
  min-height: 27.5rem;
  perspective: 60rem;
}

.card-inner {
  position: absolute;
  inset: 0;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  transform-style: preserve-3d;
  transition: transform 620ms cubic-bezier(0.22, 0.8, 0.26, 1);
}

.tarot-card.is-revealed .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.85rem;
  overflow: hidden;
  border: 1px solid rgba(248, 239, 230, 0.2);
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: left;
  backface-visibility: hidden;
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.25);
}

.card-back {
  place-items: center;
  text-align: center;
  background:
    linear-gradient(45deg, rgba(216, 183, 95, 0.18) 25%, transparent 25% 50%, rgba(216, 183, 95, 0.18) 50% 75%, transparent 75%),
    radial-gradient(circle at 50% 30%, rgba(105, 200, 189, 0.18), transparent 7rem),
    linear-gradient(135deg, #26353a, #312030);
  background-size: 2rem 2rem, auto, auto;
}

.card-back-symbol {
  display: grid;
  place-items: center;
  width: 7rem;
  aspect-ratio: 1;
  border: 1px solid rgba(248, 239, 230, 0.34);
  border-radius: 50%;
  color: var(--gold);
  font-size: 3.1rem;
  font-weight: 900;
}

.card-back-text {
  color: var(--muted);
  font-weight: 900;
}

.card-front {
  grid-template-rows: auto minmax(6rem, 1fr) auto auto;
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 50% 32%, rgba(255, 255, 255, 0.5), transparent 8rem),
    linear-gradient(160deg, #f6eddd, #bfb1a2);
  color: #231f20;
}

.card-role {
  display: block;
  color: #775f33;
  font-size: 0.78rem;
  font-weight: 900;
}

.card-name {
  display: block;
  margin-top: 0.2rem;
  font-size: 1.45rem;
  line-height: 1.15;
}

.card-subtitle {
  display: block;
  color: #6a5d55;
  font-size: 0.8rem;
  font-weight: 800;
}

.card-art {
  display: grid;
  place-items: center;
  min-height: 8.5rem;
  border: 1px solid rgba(35, 31, 32, 0.16);
  border-radius: 0.5rem;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.44), transparent 48%),
    var(--accent);
  color: rgba(35, 31, 32, 0.72);
  font-size: 4.4rem;
  font-weight: 900;
}

.keyword-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.keyword-row span {
  border: 1px solid rgba(35, 31, 32, 0.16);
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
  color: #453d38;
  font-size: 0.76rem;
  font-weight: 900;
}

.card-message {
  color: #453d38;
  font-size: 0.92rem;
  line-height: 1.6;
}

.history-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 24rem;
  border-radius: 0.5rem;
  padding: 1rem;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  font-size: 1.25rem;
}

.history-list {
  display: grid;
  align-content: start;
  gap: 0.7rem;
  overflow: auto;
}

.history-item {
  display: grid;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
}

.history-item strong {
  font-size: 0.9rem;
}

.history-item p,
.history-item small {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.empty-history {
  color: var(--muted);
  line-height: 1.5;
}

@keyframes shuffle {
  0% {
    transform: translateX(0) rotate(0deg);
  }

  35% {
    transform: translateX(-0.9rem) rotate(-2deg);
  }

  70% {
    transform: translateX(0.9rem) rotate(2deg);
  }

  100% {
    transform: translateX(0) rotate(0deg);
  }
}

@media (max-width: 74rem) {
  .app-shell {
    grid-template-columns: minmax(18rem, 25rem) 1fr;
  }

  .history-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 54rem) {
  .app-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  h1 {
    max-width: 18ch;
  }

  .table-panel {
    min-height: auto;
  }

  .card-table {
    grid-template-columns: 1fr;
  }

  .tarot-card {
    min-height: 25rem;
  }
}

@media (max-width: 34rem) {
  .app-shell {
    width: min(100vw - 1rem, 34rem);
    padding: 0.5rem 0;
  }

  .reader-panel,
  .table-panel,
  .history-panel {
    padding: 0.85rem;
  }

  .emotion-grid,
  .tone-row {
    grid-template-columns: 1fr;
  }

  .reading-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}
