/* Iris: The Broken Arc — dusk-sky UI: glass, gold, and seven colours. */
:root {
  --ink: #eef1fb;
  --muted: #a7adc4;
  --gold: #f2c879;
  --gold-2: #d79a45;
  --rose: #ff8a72;
  --cyan: #8fe6ff;
  --panel: rgba(15, 17, 32, 0.88);
  --line: rgba(255, 255, 255, 0.13);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #080a14;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
#app { position: fixed; inset: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }

/* ---------- HUD ---------- */
.hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px 22px;
  background: linear-gradient(180deg, rgba(6, 8, 18, 0.72), rgba(6, 8, 18, 0));
  pointer-events: none; z-index: 5;
}
.hud[hidden] { display: none; }
.hud-left, .hud-mid, .hud-right { display: flex; align-items: center; gap: 10px; pointer-events: auto; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink); font-size: 13px; line-height: 1;
  cursor: pointer; backdrop-filter: blur(10px);
  transition: background .18s, transform .18s, border-color .18s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.14); border-color: rgba(242, 200, 121, .55); }
.icon-btn:active { transform: scale(.94); }
.hud-chap { display: flex; flex-direction: column; line-height: 1.15; }
.hud-act { font-size: 9.5px; letter-spacing: .18em; color: var(--gold); text-transform: uppercase; }
.hud-name { font-family: Georgia, "Times New Roman", serif; font-size: 15px; }
.hud-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06);
  font-size: 13px; backdrop-filter: blur(10px);
}
.hud-pill small { color: var(--muted); font-size: 10.5px; }
.mote-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
  background: radial-gradient(circle at 35% 35%, #fff, #ffd93d 45%, #ff9f43);
  box-shadow: 0 0 10px rgba(255, 217, 61, .8);
}
.hearts { display: flex; gap: 4px; }
.heart {
  width: 15px; height: 14px; position: relative; opacity: .95;
  filter: drop-shadow(0 0 6px rgba(255, 110, 110, .55));
}
.heart::before, .heart::after {
  content: ""; position: absolute; width: 9px; height: 13px;
  background: #ff6b6b; border-radius: 9px 9px 0 0;
}
.heart::before { left: 0; transform: rotate(-45deg); transform-origin: 0 100%; }
.heart::after { right: 0; transform: rotate(45deg); transform-origin: 100% 100%; }
.heart.dark::before, .heart.dark::after { background: rgba(255, 255, 255, .18); filter: none; }
.heart.dark { filter: none; }
.shards { display: flex; gap: 4px; }
.sd {
  width: 11px; height: 11px; transform: rotate(45deg);
  border: 1px solid rgba(255, 230, 170, .55);
  background: rgba(255, 255, 255, .06);
}
.sd.on { background: linear-gradient(135deg, #fff6d8, #ffd98a); border-color: #ffeab0; box-shadow: 0 0 10px rgba(255, 217, 138, .9); }
.hud-time { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.hud-time b { font-variant-numeric: tabular-nums; font-size: 15px; }
.hud-time small { font-size: 9px; letter-spacing: .16em; color: var(--muted); text-transform: uppercase; }
.progress {
  position: absolute; left: 0; right: 0; top: 0; height: 3px; z-index: 6;
  background: rgba(255, 255, 255, .07);
}
.progress[hidden] { display: none; }
.progress i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #ff5f5f, #ffd93d, #57d98a, #4aa8ff, #c06cff);
  box-shadow: 0 0 12px rgba(255, 217, 61, .7);
  transition: width .12s linear;
}
.toast {
  position: absolute; left: 50%; top: 74px; transform: translate(-50%, -8px);
  padding: 8px 16px; border-radius: 999px;
  background: rgba(10, 12, 24, .82); border: 1px solid rgba(242, 200, 121, .45);
  color: #ffe9bd; font-size: 12.5px; letter-spacing: .04em;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  backdrop-filter: blur(8px); z-index: 8;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- overlays ---------- */
.ov {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: 22px; overflow-y: auto;
  background: radial-gradient(120% 90% at 50% 0%, rgba(30, 24, 60, .55), rgba(4, 5, 12, .88));
  backdrop-filter: blur(7px);
  opacity: 0; pointer-events: none; transition: opacity .28s ease;
}
.ov.show { opacity: 1; pointer-events: auto; }
.sheet {
  width: min(560px, 100%);
  padding: 28px 30px 24px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background:
    linear-gradient(160deg, rgba(30, 32, 56, .92), rgba(11, 12, 24, .96)),
    radial-gradient(60% 40% at 80% 0%, rgba(242, 200, 121, .10), transparent);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .07);
  animation: rise .34s cubic-bezier(.2, .8, .2, 1);
}
.sheet.wide { width: min(760px, 100%); }
@keyframes rise { from { transform: translateY(14px) scale(.985); opacity: 0; } to { transform: none; opacity: 1; } }
.eyebrow {
  font-size: 9.5px; letter-spacing: .24em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 10px;
}
h1, h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400; margin: 0 0 10px; line-height: 1.08;
}
h2 { font-size: 27px; }
.lede { color: #c3c8dc; font-size: 13.5px; line-height: 1.62; margin: 0 0 20px; max-width: 46em; }
.muted { color: var(--muted); font-size: 12px; }

.logo {
  font-size: clamp(46px, 9vw, 74px);
  letter-spacing: .14em;
  margin: 6px 0 14px;
  background: linear-gradient(100deg, #ffd9a0, #fff6de 35%, #ffb38a 70%, #ff8ab8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 10px 40px rgba(255, 180, 120, .18);
}
.logo-sub {
  display: block; font-size: 11px; letter-spacing: .42em;
  color: #d9d3ea; -webkit-text-fill-color: #d9d3ea; margin-top: 8px;
}
.title-sheet { text-align: left; }
.title-foot {
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  margin-top: 18px; padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, .09);
  color: var(--muted); font-size: 11px; letter-spacing: .03em;
}
.title-foot span { display: inline-flex; align-items: center; gap: 6px; }
.link-btn {
  margin-top: 12px; background: none; border: 0; padding: 0;
  color: var(--cyan); font-size: 12.5px; cursor: pointer; letter-spacing: .02em;
}
.link-btn:hover { color: #d6f6ff; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn-row.col { flex-direction: column; align-items: stretch; }
.btn {
  appearance: none; cursor: pointer;
  padding: 12px 20px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .06);
  color: var(--ink); font-size: 13.5px; font-weight: 600; letter-spacing: .02em;
  transition: transform .16s, background .18s, border-color .18s, box-shadow .18s;
}
.btn:hover { background: rgba(255, 255, 255, .12); border-color: rgba(242, 200, 121, .5); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.big {
  padding: 14px 26px; font-size: 14.5px;
  background: linear-gradient(120deg, #f7d9a0, #f2c879 45%, #e3a95c);
  color: #241a10; border-color: transparent;
  box-shadow: 0 14px 34px rgba(226, 169, 92, .28), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.btn.big:hover { filter: brightness(1.05); box-shadow: 0 18px 40px rgba(226, 169, 92, .36); }
.btn.ghost { background: transparent; }
.btn.small { padding: 8px 14px; font-size: 12px; }
.hint { color: var(--muted); font-size: 11.5px; margin: 16px 0 0; letter-spacing: .02em; }

.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.close { width: 34px; height: 34px; }
.sheet-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }

/* ---------- chapter grid ---------- */
.grid-acts { max-height: min(58vh, 460px); overflow-y: auto; padding-right: 4px; }
.act-block { margin-bottom: 16px; }
.act-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.act-head b { font-family: Georgia, serif; font-size: 14px; letter-spacing: .04em; }
.act-head span { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.cells { display: grid; grid-template-columns: repeat(8, 1fr); gap: 7px; }
.cell {
  position: relative; aspect-ratio: 1;
  border-radius: 10px; border: 1px solid rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .04);
  color: var(--ink); cursor: pointer; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, border-color .15s, background .15s;
}
.cell:hover { transform: translateY(-2px); border-color: rgba(242, 200, 121, .6); background: rgba(255, 255, 255, .09); }
.cell.locked { color: rgba(255, 255, 255, .25); cursor: not-allowed; }
.cell.locked:hover { transform: none; border-color: rgba(255, 255, 255, .1); }
.cell.now { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(242, 200, 121, .45), 0 0 22px rgba(242, 200, 121, .25); }
.cell .st {
  position: absolute; left: 0; right: 0; bottom: 3px;
  display: flex; justify-content: center; gap: 1.5px;
}
.cell .st i { width: 4px; height: 4px; transform: rotate(45deg); background: rgba(255, 255, 255, .18); }
.cell .st i.on { background: #ffd98a; box-shadow: 0 0 5px rgba(255, 217, 138, .9); }
.cell.final { background: linear-gradient(160deg, rgba(255, 138, 114, .18), rgba(255, 255, 255, .04)); }

/* ---------- brief ---------- */
.brief-top { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 14px; }
.brief-no {
  font-family: Georgia, serif; font-size: 44px; line-height: .9;
  color: rgba(242, 200, 121, .5); min-width: 64px;
}
.brief-where { color: var(--muted); font-size: 12px; margin-top: 4px; letter-spacing: .03em; }
.brief-story {
  font-family: Georgia, serif; font-size: 15.5px; line-height: 1.7;
  color: #e6e2f2; margin: 0 0 18px;
  padding-left: 14px; border-left: 2px solid rgba(242, 200, 121, .55);
}
.brief-stats, .win-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin: 0 0 20px; padding: 12px 0;
  border-top: 1px solid rgba(255, 255, 255, .08);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brief-stats div, .win-stats div { display: flex; flex-direction: column; gap: 3px; }
.brief-stats b, .win-stats b { font-size: 16px; font-variant-numeric: tabular-nums; }
.brief-stats span, .win-stats span {
  font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.win-stats { grid-template-columns: repeat(3, 1fr); }

/* ---------- how ---------- */
.how-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.how-item {
  padding: 12px 14px; border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .035);
}
.how-item p { margin: 8px 0 0; font-size: 12px; line-height: 1.55; color: #b9bed2; }
kbd {
  display: inline-block; margin-right: 4px; padding: 3px 7px;
  border-radius: 6px; border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .08);
  font: 11px/1 ui-monospace, Menlo, monospace;
}
.rules { margin: 0 0 18px; padding-left: 18px; color: #c3c8dc; font-size: 12.5px; line-height: 1.7; }
.rules b { color: #f0e7d2; }

/* ---------- win ---------- */
.win-sheet { text-align: center; }
.win-sheet .lede { margin-left: auto; margin-right: auto; }
.win-sheet .btn-row { justify-content: center; }
.stars-big { display: flex; justify-content: center; gap: 10px; margin: 8px 0 14px; }
.stars-big i {
  width: 30px; height: 30px; transform: rotate(45deg);
  border: 1px solid rgba(255, 230, 170, .35);
  background: rgba(255, 255, 255, .04);
  animation: pop .5s backwards;
}
.stars-big i.on {
  background: linear-gradient(135deg, #fff9e6, #ffd98a 55%, #e8a94f);
  border-color: #ffeab0;
  box-shadow: 0 0 22px rgba(255, 217, 138, .65);
}
.stars-big i:nth-child(2) { animation-delay: .14s; }
.stars-big i:nth-child(3) { animation-delay: .28s; }
@keyframes pop { from { transform: rotate(45deg) scale(.4); opacity: 0; } to { transform: rotate(45deg) scale(1); opacity: 1; } }

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  .sheet { padding: 22px 20px 20px; border-radius: 18px; }
  h2 { font-size: 23px; }
  .brief-stats { grid-template-columns: repeat(2, 1fr); }
  .how-grid { grid-template-columns: 1fr; }
  .cells { grid-template-columns: repeat(6, 1fr); }
  .hud-name { font-size: 13px; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hud-time small, .hud-pill small { display: none; }
  .logo { letter-spacing: .10em; }
}
@media (max-width: 380px) {
  .hud { padding: 9px 10px 18px; }
  .icon-btn { width: 34px; height: 34px; }
  .hud-chap { display: none; }
  .cells { grid-template-columns: repeat(5, 1fr); }
}
@media (max-height: 560px) {
  .sheet { padding: 16px 20px 14px; max-height: 94vh; overflow-y: auto; }
  .logo { font-size: 40px; margin-bottom: 8px; }
  .lede { margin-bottom: 12px; font-size: 12.5px; }
  .brief-story { font-size: 13.5px; margin-bottom: 12px; }
  .brief-stats, .win-stats { margin-bottom: 12px; padding: 8px 0; }
  .hint { display: none; }
  .grid-acts { max-height: 44vh; }
}
