:root {
  --ink: #5a4032;
  --paper: rgba(255, 248, 240, 0.94);
  --line: rgba(196, 140, 110, 0.38);
  --coral: #e07a68;
  --gold: #e2a84a;
  --shadow: 0 16px 40px rgba(120, 72, 40, 0.16);
  color: var(--ink);
  font-family: "Noto Sans KR", sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.45), transparent 28%),
    linear-gradient(180deg, #f8e7cf, #f3d7b4 48%, #e8c49a);
  min-height: 100%;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: "Jua", sans-serif; font-weight: 400; margin: 0; }
.hidden { display: none !important; }

#app { min-height: 100vh; padding: 22px 16px 32px; }
.narrow { width: min(440px, 100%); margin: 8vh auto 0; }
.wide { width: min(1080px, 100%); margin: 0 auto; }

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 26px 22px;
}
.mark {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 22px;
}
.eyebrow {
  margin: 10px 0 0;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--coral);
}
.lead { color: #7a5b48; }
label { display: grid; gap: 6px; margin: 16px 0; font-weight: 700; }
input {
  border: 1px solid var(--line);
  background: #fffaf3;
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--ink);
}
.primary, .ghost {
  border-radius: 999px;
  padding: 12px 16px;
  border: 1px solid transparent;
}
.primary { background: var(--coral); color: #fffaf3; font-weight: 700; }
.primary:disabled { opacity: 0.45; cursor: default; }
.ghost { background: transparent; border-color: var(--line); color: var(--ink); }

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 18px;
}
.scores { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pill {
  background: var(--paper);
  border-radius: 18px;
  padding: 8px 12px;
  box-shadow: var(--shadow);
  min-width: 92px;
}
.pill span { display: block; color: #8a6856; font-size: 12px; }
.pill strong { font-family: "Jua", sans-serif; font-size: 22px; font-weight: 400; }

.theme { margin: 18px 0 8px; }
.theme p { margin: 2px 0 8px; color: #7a5b48; }
.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.card {
  display: grid;
  gap: 6px;
  text-align: left;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid transparent;
  background: var(--paper);
  box-shadow: var(--shadow);
  color: inherit;
}
.card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 12px;
  background: #f3e6d4;
}
.card b { font-weight: 700; }
.card small { color: #8a6856; }
.card.locked { cursor: default; }
.lockart {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 12px;
  background: #f3e4d2;
  color: #b08974;
  font-family: "Jua", sans-serif;
  font-size: 22px;
}
.card.done { outline: 2px solid rgba(226, 168, 74, 0.85); }

.ranks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 22px;
}
.rank {
  background: var(--paper);
  border-radius: 22px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.rank ol { margin: 8px 0 0; padding-left: 18px; }
.rank li { padding: 3px 0; }
.rank li.mine { color: var(--coral); font-weight: 700; }
.muted { color: #8a6856; }

.play {
  width: min(760px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 10px;
}
.play-bar, .duel-bar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.timer { font-family: "Jua", sans-serif; font-size: 28px; }
.duel-bar {
  background: var(--paper);
  border-radius: 18px;
  padding: 8px 12px;
}
.meter { flex: 1; height: 10px; background: #f0dfcf; border-radius: 999px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--coral); width: 0; }
.stage { position: relative; width: min(100%, calc(100dvh - 210px)); margin: 0 auto; }
.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 22px;
  overflow: hidden;
  background: #f6ead8;
  box-shadow: var(--shadow);
  touch-action: none;
  user-select: none;
}
.tile {
  position: absolute;
  background-repeat: no-repeat;
  overflow: hidden;
}
.tile.lift { z-index: 4; filter: drop-shadow(0 12px 10px rgba(80, 40, 20, 0.28)); }
.tile.hot { outline: 3px solid rgba(224, 122, 104, 0.85); outline-offset: -3px; z-index: 3; }
.peek {
  justify-self: end;
  width: 72px;
  height: 72px;
  padding: 0;
  border-radius: 16px;
  border: 3px solid #fffaf3;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #fff;
}
.peek img { width: 100%; height: 100%; object-fit: cover; }
.preview {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(80, 48, 28, 0.35);
  z-index: 6;
}
.preview img { width: min(78vw, 460px); border-radius: 24px; box-shadow: var(--shadow); }
.mask {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(90, 56, 36, 0.28);
  padding: 18px;
  z-index: 7;
}
.mask .panel { width: min(420px, 100%); text-align: center; }
.delta { font-family: "Jua", sans-serif; font-size: 42px; margin: 8px 0; }
.delta.bad { color: #b85b5b; }
.actions { display: flex; gap: 8px; justify-content: center; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: #5a4032;
  color: #fffaf3;
  border-radius: 999px;
  padding: 10px 16px;
  z-index: 8;
}

@media (max-width: 800px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ranks { grid-template-columns: 1fr; }
  .top { align-items: flex-start; flex-direction: column; }
  .stage { width: min(100%, calc(100dvh - 230px)); }
}
