:root {
  --paper: #f6efe0;
  --paper-2: #efe4cc;
  --ink: #1f1a2b;
  --ink-soft: #5a4f62;
  --accent: #2f5fd0;
  --table: #2a2438;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--table);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; cursor: crosshair; }
.hidden { display: none !important; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
button { font-family: inherit; cursor: pointer; }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 10;
  background: radial-gradient(ellipse at center, rgba(42,36,56,0.05), rgba(30,24,42,0.35));
  animation: fade .35s ease both;
}
#title { background: radial-gradient(ellipse at 50% 60%, rgba(42,36,56,0.05), rgba(30,24,42,0.45)); }
@keyframes fade { from { opacity: 0; } }
.card {
  position: relative;
  width: min(460px, 100%);
  max-height: calc(100% - 8px); overflow-y: auto;
  padding: 26px 28px 22px;
  text-align: center;
  background:
    radial-gradient(circle at 18% 12%, rgba(255,255,255,0.7), rgba(255,255,255,0) 40%),
    radial-gradient(circle at 85% 90%, rgba(214,190,150,0.35), rgba(214,190,150,0) 45%),
    var(--paper);
  border-radius: 6px 10px 7px 12px;
  box-shadow: 0 2px 0 #d9c9a8, 0 18px 50px rgba(10,6,20,0.45), inset 0 0 40px rgba(170,140,95,0.18);
  animation: rise .45s cubic-bezier(.2,.9,.3,1.2) both;
}
.card.narrow { width: min(380px, 100%); }
@keyframes rise { from { transform: translateY(18px) rotate(-1deg); opacity: 0; } }
.logo {
  margin: 0; font-size: clamp(52px, 13vw, 84px); line-height: .95; font-style: italic; font-weight: 700;
  letter-spacing: -1px;
  background: linear-gradient(100deg, #2f5fd0 0%, #8a3fa8 38%, #e0452b 70%, #e6a417 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 rgba(31,26,43,0.12));
}
h2 { margin: 0 0 4px; font-size: 38px; font-style: italic; }
.tag { margin: 6px 0 16px; color: var(--ink-soft); font-size: 17px; font-style: italic; }
.muted { color: var(--ink-soft); margin: 4px 0 16px; font-style: italic; }
.big {
  display: block; width: 100%; margin: 14px 0 10px; padding: 14px 0;
  font-size: 24px; font-weight: 700; font-style: italic; letter-spacing: .5px;
  color: #fffaf0; border: 0; border-radius: 40px 34px 44px 30px;
  background: radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--accent) 70%, white), var(--accent) 60%);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 60%, black), 0 10px 22px rgba(20,10,30,0.25);
  transition: transform .12s ease, box-shadow .12s ease;
}
.big:hover { transform: translateY(-2px) rotate(-.5deg); }
.big:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 60%, black); }
.big:focus-visible, .ghost:focus-visible, .swatch:focus-visible { outline: 3px dashed var(--ink-soft); outline-offset: 3px; }
.ghost {
  background: transparent; border: 1.5px solid rgba(31,26,43,0.25); color: var(--ink);
  padding: 8px 16px; border-radius: 20px; font-size: 15px;
}
.ghost:hover { background: rgba(31,26,43,0.06); }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.row.small { margin-top: 12px; }
body:not(.inhub) .hubonly { display: none; }

.inks { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 4px 0 4px; }
.swatch {
  width: 34px; height: 34px; border-radius: 50% 46% 52% 44%; border: 0; padding: 0; position: relative;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.18), 0 2px 4px rgba(0,0,0,0.15);
  transition: transform .15s ease;
}
.swatch:hover { transform: scale(1.1) rotate(-6deg); }
.swatch.on { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--ink); }
.swatch.locked { filter: grayscale(.85) brightness(1.1); opacity: .45; cursor: not-allowed; }
.swatch.locked::after {
  content: attr(data-need); position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.inkname { font-size: 14px; color: var(--ink-soft); min-height: 18px; font-style: italic; }

.daily {
  margin: 4px 0 12px; padding: 9px 12px; border-radius: 8px;
  background: rgba(230,164,23,0.13); border: 1px dashed rgba(170,120,20,0.45);
  font-size: 14px; color: #6b4a10;
}
.daily b { font-style: italic; }
.daily.done { background: rgba(31,158,122,0.12); border-color: rgba(31,158,122,0.5); color: #135c48; }
.how { text-align: left; margin: 6px 0 8px; padding-left: 20px; font-size: 14.5px; line-height: 1.45; color: #3c3346; }
.how li { margin: 3px 0; }
.stats { font-size: 13.5px; color: var(--ink-soft); margin-top: 6px; }
.keys { font-size: 13px; color: var(--ink-soft); margin: 12px 0 0; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0 6px; }
.grid div { background: rgba(31,26,43,0.05); border-radius: 10px; padding: 10px 6px 6px; }
.grid span { display: block; font-size: 30px; font-weight: 700; font-style: italic; }
.grid label { font-size: 12.5px; color: var(--ink-soft); letter-spacing: .5px; text-transform: uppercase; }
.note { min-height: 20px; font-size: 14.5px; color: #135c48; margin: 8px 0 0; font-style: italic; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.panel {
  position: absolute; top: 12px; left: 12px; margin: 0; padding: 8px 10px; list-style: none;
  width: 210px; border-radius: 8px;
  background: rgba(246,239,224,0.86); box-shadow: 0 6px 18px rgba(10,6,20,0.25);
  font-size: 14px;
}
.panel li { display: flex; align-items: center; gap: 6px; padding: 2px 0; white-space: nowrap; }
.panel li.me { font-weight: 700; }
.panel .rk { width: 16px; color: var(--ink-soft); font-size: 12px; text-align: right; }
.panel .sw { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.panel .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.panel .tr { font-size: 11px; color: var(--ink-soft); font-style: italic; }
.panel .pc { font-variant-numeric: tabular-nums; }
.panel li.gap { justify-content: center; color: var(--ink-soft); padding: 0; line-height: .8; }
#feed { position: absolute; top: 60px; right: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; max-width: 60vw; }
.kill {
  padding: 5px 11px; border-radius: 14px; font-size: 14px;
  background: rgba(246,239,224,0.88); box-shadow: 0 3px 10px rgba(10,6,20,0.2);
  animation: slide .3s cubic-bezier(.2,.9,.3,1.3) both;
  transition: opacity .6s ease;
}
.kill.mine { background: #fffaf0; font-weight: 700; }
.kill.fade { opacity: 0; }
.kill i { font-style: normal; font-weight: 700; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
#me { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); text-align: center; color: #fffaf0; text-shadow: 0 2px 8px rgba(20,10,30,0.6); }
#pct { font-size: 42px; font-weight: 700; font-style: italic; line-height: 1; font-variant-numeric: tabular-nums; }
#pct.pop { animation: pop .4s ease; }
@keyframes pop { 40% { transform: scale(1.25); } }
#sub { font-size: 14px; opacity: .9; font-style: italic; }
#btns { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; pointer-events: auto; }
.icon {
  height: 38px; min-width: 38px; padding: 0 12px; border-radius: 19px; border: 0;
  background: rgba(246,239,224,0.88); color: var(--ink); font-size: 14px;
  box-shadow: 0 4px 12px rgba(10,6,20,0.25);
}
.icon.off { opacity: .6; text-decoration: line-through; }
.pauseglyph { display: inline-block; width: 10px; height: 12px; border-left: 3.5px solid var(--ink); border-right: 3.5px solid var(--ink); vertical-align: middle; }

@media (max-width: 640px) {
  .panel {
    width: 150px; font-size: 12.5px; padding: 6px 8px;
    top: max(12px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
  }
  .panel .tr { display: none; }
  #feed { top: 58px; max-width: calc(100vw - 190px); }
  .kill { font-size: 12.5px; }
  #me {
    left: 14px; right: auto; bottom: max(16px, env(safe-area-inset-bottom));
    transform: none; text-align: left; max-width: calc(100% - 120px);
  }
  #pct { font-size: 32px; }
  #sub { font-size: 13px; }
  .card { padding: 20px 18px 16px; }
  .how { font-size: 13.5px; }
  .inks { gap: 6px; }
  .swatch { width: 30px; height: 30px; }
  #btns { top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
}
@media (max-height: 520px) {
  .how { display: none; }
  .card { padding: 14px 18px; }
  .big { padding: 10px 0; margin: 8px 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition: none !important; }
}
