/* Respawnle — neon / cyberpunk theme */
:root {
  --bg: #07070c;
  --panel: #0e0f18;
  --panel2: #151726;
  --line: rgba(0, 240, 255, .22);
  --text: #eef0ff;
  --muted: #8a8fae;
  --cyan: #00f0ff;
  --yellow: #fcee0a;
  --red: #ff2a6d;
  --green: #1ff28a;
  --gray: #1b1d2b;
  --gray-text: #9599b8;
  --head: "Chakra Petch", system-ui, sans-serif;
  --body: "Barlow", system-ui, sans-serif;
  --cut: 12px;
  --clip: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
  --clip-sm: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 7px 100%, 0 calc(100% - 7px));
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background-color: var(--bg);
  background-image:
    radial-gradient(1000px 500px at 85% -10%, rgba(255, 42, 109, .16), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(0, 240, 255, .12), transparent 60%),
    linear-gradient(rgba(0, 240, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, .045) 1px, transparent 1px);
  background-size: auto, auto, 40px 40px, 40px 40px;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------- top bar ---------- */
.topbar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  max-width: 760px; margin: 0 auto; padding: 18px 16px 10px;
}
.topbar-side { display: flex; gap: 8px; }
.topbar-side.right { justify-content: flex-end; }
.logo {
  position: relative; margin: 0;
  font-family: var(--head); font-weight: 700; font-style: italic;
  font-size: clamp(24px, 6.4vw, 40px); letter-spacing: .04em; line-height: 1;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(0, 240, 255, .45);
}
.logo span { color: var(--yellow); text-shadow: 0 0 18px rgba(252, 238, 10, .45); }
.logo::before, .logo::after {
  content: attr(data-text); position: absolute; inset: 0; pointer-events: none; opacity: 0;
}
.logo::before { color: var(--red); animation: glitch 6s infinite steps(1); }
.logo::after { color: var(--cyan); animation: glitch 6s .08s infinite steps(1) reverse; }
@keyframes glitch {
  0%, 92%, 100% { opacity: 0; transform: none; clip-path: none; }
  93% { opacity: .9; transform: translate(-3px, 1px); clip-path: inset(10% 0 55% 0); }
  95% { opacity: .9; transform: translate(3px, -1px); clip-path: inset(60% 0 8% 0); }
  97% { opacity: .9; transform: translate(-2px, 0); clip-path: inset(35% 0 35% 0); }
}
@media (prefers-reduced-motion: reduce) { .logo::before, .logo::after { animation: none; } }

.icon-btn {
  width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel2); color: var(--cyan); border: 0;
  clip-path: var(--clip-sm);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--cyan); color: #000; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px 48px; }

.panel {
  background: linear-gradient(180deg, rgba(21, 23, 38, .92), rgba(14, 15, 24, .92));
  clip-path: var(--clip);
  box-shadow: inset 0 0 0 1px var(--line);
  backdrop-filter: blur(4px);
}

.archive-banner {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--yellow); color: #000; padding: 8px 14px; margin: 6px 0 10px;
  font-family: var(--head); font-weight: 600; font-size: 14px;
  clip-path: var(--clip-sm);
}
.archive-banner .link-btn { color: #000; }

/* ---------- HUD ---------- */
.hud { padding: 14px 16px 16px; margin: 8px 0 14px; }
.hud-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.puzzle-no { font-family: var(--head); font-weight: 600; font-size: 14px; color: var(--muted); letter-spacing: .08em; }
.hud-actions { display: flex; gap: 8px; }
.lives { display: flex; align-items: center; gap: 12px; }
.segs { flex: 1; display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.seg {
  height: 10px; background: var(--cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, .55);
  transform: skewX(-20deg);
  transition: background .3s, box-shadow .3s;
}
.seg.low { background: var(--red); box-shadow: 0 0 10px rgba(255, 42, 109, .6); }
.seg.used { background: #24263a; box-shadow: none; }
.seg-label { font-family: var(--head); font-weight: 700; font-size: 20px; min-width: 52px; text-align: right; }
.seg-label small { font-size: 13px; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--head); font-weight: 700; font-size: 15px; letter-spacing: .06em; text-transform: uppercase;
  background: var(--cyan); color: #000; border: 0;
  padding: 13px 26px; clip-path: var(--clip-sm);
  transition: transform .1s, filter .15s, background .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.small { font-size: 12px; padding: 8px 14px; }
.btn.ghost { background: var(--panel2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.btn.ghost:hover:not(:disabled) { background: #20233a; }
.btn:disabled { background: #191b29; color: #555a78; box-shadow: none; }
.hint-btn.ready { background: var(--red); color: #fff; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { filter: brightness(1.35) drop-shadow(0 0 10px rgba(255, 42, 109, .9)); } }
.link-btn { background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; color: var(--cyan); font-size: inherit; }

/* ---------- search ---------- */
.search { position: relative; margin: 0 0 18px; }
.search-ic { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--cyan); pointer-events: none; z-index: 1; }
#search-input {
  width: 100%; padding: 16px 18px 16px 48px;
  background: rgba(10, 11, 18, .95); color: var(--text);
  border: 0; outline: none; clip-path: var(--clip);
  box-shadow: inset 0 0 0 1px var(--line);
  font-family: var(--body); font-size: 18px; font-weight: 500;
  transition: box-shadow .15s;
}
#search-input::placeholder { color: #6a6f90; }
#search-input:focus { box-shadow: inset 0 0 0 2px var(--cyan); }
#search-input:disabled { opacity: .55; }
.search-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px);
  list-style: none; margin: 0; padding: 6px;
  background: #0d0e17; box-shadow: 0 0 0 1px var(--line), 0 18px 40px rgba(0, 0, 0, .6);
  max-height: 340px; overflow-y: auto;
}
.search-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; font-size: 16px; font-weight: 500; }
.search-list li .yr { margin-left: auto; color: var(--muted); font-family: var(--head); font-size: 13px; }
.search-list li.active, .search-list li:hover { background: rgba(0, 240, 255, .1); color: var(--cyan); box-shadow: inset 3px 0 0 var(--cyan); }
.search-list li.none { color: var(--muted); cursor: default; background: none; box-shadow: none; }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 26px 18px; color: var(--muted); }
.empty-title { font-family: var(--head); font-weight: 700; font-size: 20px; color: var(--text); margin: 0 0 6px; text-transform: uppercase; letter-spacing: .06em; }
.empty p { margin: 0; }
.dot { display: inline-block; width: 10px; height: 10px; vertical-align: middle; margin: 0 2px 0 6px; transform: skewX(-20deg); }
.dot.green { background: var(--green); } .dot.yellow { background: var(--yellow); } .dot.gray { background: #3a3d55; }

/* ---------- hints ---------- */
.hint-box {
  position: relative; padding: 12px 16px 12px 18px; margin-bottom: 12px;
  background: linear-gradient(90deg, rgba(255, 42, 109, .16), rgba(255, 42, 109, .03));
  clip-path: var(--clip-sm);
  box-shadow: inset 3px 0 0 var(--red);
}
.hint-box h4 { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; font-family: var(--head); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--red); }
.hint-box p { margin: 0; font-size: 17px; font-weight: 500; }

/* ---------- guess cards ---------- */
.guesses { display: flex; flex-direction: column; gap: 14px; }
.card {
  display: grid; grid-template-columns: 96px 1fr; column-gap: 14px; padding: 14px;
  grid-template-areas: "cover title" "cover body"; grid-template-rows: auto 1fr;
  background: linear-gradient(180deg, rgba(21, 23, 38, .95), rgba(13, 14, 22, .95));
  clip-path: var(--clip);
  box-shadow: inset 0 0 0 1px var(--line);
}
.card > .cover { grid-area: cover; }
.card-title { grid-area: title; min-width: 0; }
.card-body { grid-area: body; min-width: 0; }
.card-title .chiprow { margin-top: 0; }
.card.win { box-shadow: inset 0 0 0 2px var(--green), inset 0 0 40px rgba(31, 242, 138, .12); }
.cover {
  width: 96px; height: 128px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--head); font-weight: 700; font-size: 22px; color: #fff; letter-spacing: .04em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .5);
  background-size: cover; background-position: center;
  clip-path: var(--clip-sm);
}
.card h3 { margin: 0 0 10px; font-family: var(--head); font-weight: 700; font-size: 19px; line-height: 1.2; }
.card.win h3 { color: var(--green); }

.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 10px 0 4px; }
.tile {
  grid-column: span 2;
  background: var(--gray); color: var(--gray-text);
  padding: 8px 8px 9px; min-height: 60px;
  display: flex; flex-direction: column; justify-content: center;
  clip-path: var(--clip-sm);
}
.tile.wide { grid-column: span 3; }
.tile .lbl { font-family: var(--head); font-weight: 600; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; opacity: .75; margin-bottom: 2px; }
.tile .val { font-size: 15px; font-weight: 600; line-height: 1.2; color: var(--text); word-break: break-word; }
.tile .val.num { font-family: var(--head); font-size: 20px; font-weight: 700; }
.chiprow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.chiprow .lbl { font-family: var(--head); font-weight: 600; font-size: 10px; letter-spacing: .12em; color: var(--muted); width: 82px; flex: none; }
.chip {
  background: var(--gray); color: var(--gray-text); font-size: 14px; font-weight: 600;
  padding: 3px 10px; clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}

.tile.green, .chip.green { background: var(--green); color: #00150a; box-shadow: 0 0 14px rgba(31, 242, 138, .35); }
.tile.yellow, .chip.yellow { background: var(--yellow); color: #181600; }
.tile.green .val, .tile.yellow .val { color: inherit; }
.tile.green .lbl, .tile.yellow .lbl { opacity: .7; }
.tile.na .val { color: #5f6382; }

.flip { animation: flip .45s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes flip {
  0% { opacity: 0; transform: perspective(400px) rotateX(-80deg); }
  100% { opacity: 1; transform: none; }
}

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(3, 3, 8, .78); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  position: relative; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  background: linear-gradient(180deg, #151726, #0c0d15);
  clip-path: var(--clip);
  box-shadow: inset 0 0 0 1px var(--line), inset 0 3px 0 var(--yellow);
  padding: 28px 24px 24px;
}
.modal .close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; }
.modal h2 { font-family: var(--head); font-weight: 700; font-size: 24px; text-transform: uppercase; letter-spacing: .05em; margin: 0 0 14px; color: var(--yellow); }
.modal h2.win { color: var(--green); font-size: 34px; text-align: center; text-shadow: 0 0 20px rgba(31, 242, 138, .5); }
.modal h2.lose { color: var(--red); font-size: 34px; text-align: center; text-shadow: 0 0 20px rgba(255, 42, 109, .5); }
.modal h5 { font-family: var(--head); font-weight: 600; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--cyan); margin: 22px 0 8px; }
.modal p, .modal li { font-size: 16px; }
.modal ul { padding-left: 20px; margin: 6px 0; }
.modal li { margin-bottom: 4px; }
.answer-name { font-family: var(--head); font-weight: 700; font-size: 22px; text-align: center; margin: 10px 0 2px; }
.cover.answer-cover { margin: 0 auto 8px; width: 132px; height: 176px; font-size: 32px; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.stat-row > div { background: var(--panel2); padding: 10px 4px; clip-path: var(--clip-sm); }
.stat-row .n { font-family: var(--head); font-weight: 700; font-size: 26px; line-height: 1.1; }
.stat-row .t { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.dist { display: flex; flex-direction: column; gap: 4px; }
.dist-row { display: flex; align-items: center; gap: 8px; font-family: var(--head); font-size: 13px; }
.dist-row .k { width: 18px; text-align: right; color: var(--muted); }
.dist-row .bar { background: #24263a; padding: 0 8px; min-width: 26px; text-align: right; font-weight: 700; line-height: 20px; transform: skewX(-12deg); }
.dist-row .bar.me { background: var(--green); color: #00150a; }
.countdown { font-family: var(--head); font-weight: 700; font-size: 30px; color: var(--yellow); text-align: center; letter-spacing: .06em; }
.share-wrap { text-align: center; margin-top: 18px; }

.hint-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 6px; }
.hint-opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  background: var(--panel2); border: 0; padding: 16px 10px;
  clip-path: var(--clip-sm); box-shadow: inset 0 0 0 1px var(--line);
  transition: background .15s, box-shadow .15s;
}
.hint-opt:hover { background: rgba(255, 42, 109, .14); box-shadow: inset 0 0 0 1px var(--red); }
.hint-opt .ic { color: var(--red); }
.hint-opt .ic svg { width: 24px; height: 24px; }
.hint-opt .t { font-family: var(--head); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; }
.hint-opt .d { font-size: 13px; color: var(--muted); }

.archive-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.archive-list button {
  width: 100%; display: flex; justify-content: space-between; gap: 8px;
  background: var(--panel2); border: 0; padding: 10px 12px; font-size: 15px; text-align: left;
  clip-path: var(--clip-sm);
}
.archive-list button:hover { background: #20233a; color: var(--cyan); }
.archive-list .st { font-family: var(--head); font-weight: 700; font-size: 12px; letter-spacing: .06em; align-self: center; }
.st.won { color: var(--green); } .st.lost { color: var(--red); } .st.playing { color: var(--yellow); }

.legend { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.legend span { padding: 3px 12px; font-weight: 600; font-size: 14px; clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%); }
.legend .green { background: var(--green); color: #00150a; }
.legend .yellow { background: var(--yellow); color: #181600; }

.toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%); z-index: 200;
  background: var(--cyan); color: #000; font-family: var(--head); font-weight: 700; font-size: 14px;
  text-transform: uppercase; letter-spacing: .06em; padding: 10px 18px; clip-path: var(--clip-sm);
}

.foot { text-align: center; color: var(--muted); font-size: 14px; margin-top: 32px; }

@media (max-width: 560px) {
  .card { grid-template-columns: 64px 1fr; column-gap: 12px; row-gap: 4px; padding: 12px; grid-template-areas: "cover title" "body body"; }
  .cover { width: 64px; height: 86px; font-size: 16px; }
  .card h3 { font-size: 16px; margin-bottom: 8px; }
  .card-title .chiprow .lbl { display: none; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile, .tile.wide { grid-column: span 1; }
  .tile:nth-child(3) { grid-column: span 2; }
  .card-body .chiprow .lbl { width: 100%; }
  .hint-grid { grid-template-columns: 1fr; }
  .hint-opt { flex-direction: row; text-align: left; padding: 12px 14px; }
  .hint-opt .d { margin-left: auto; }
  .stat-row .n { font-size: 22px; }
}

/* global stats */
#global-stats .stat-row { margin-bottom: 10px; }
#global-stats .stat-row .n { color: var(--cyan); }
.dist.global .bar { background: #1b2a3a; }
.dist.global .bar.lost { background: rgba(255, 42, 109, .35); }
.muted.small { font-size: 14px; }
