@font-face {
  font-family: 'Macondo';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/macondo-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('assets/fonts/ibm-plex-sans-normal-400-600-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('assets/fonts/ibm-plex-mono-normal-500-latin.woff2') format('woff2');
}

:root {
  --bg: #0a0708;
  --line: #3a2a22;
  --line-strong: #6e5340;
  --text: #f1e4c8;
  --text-2: #d3c2a2;
  --muted: #a8957a;
  --gold-1: #97701e;
  --gold-2: #cda345;
  --gold-3: #b58a2f;
  --gold: #d6ad4f;
  --velvet: #6b1d2c;
  --hit: #d6ad4f;
  --hit-ink: #1c1206;
  --near: #8a2c3e;
  --near-ink: #fbe9e4;
  --miss: #1a1311;
  --fancy: 'Macondo', 'Palatino Linotype', Georgia, serif;
  --sans: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column; position: relative;
  background:
    radial-gradient(70% 45% at 50% 105%, rgba(255, 170, 70, .13), rgba(255, 140, 50, .04) 45%, transparent 75%),
    radial-gradient(60% 40% at 15% 30%, rgba(90, 110, 70, .05), transparent 60%),
    radial-gradient(50% 35% at 85% 55%, rgba(80, 120, 140, .05), transparent 60%),
    linear-gradient(rgba(10, 7, 8, .42), rgba(10, 7, 8, .58) 50%, rgba(10, 7, 8, .82)),
    url("assets/map.webp") center top / cover no-repeat fixed,
    var(--bg);
  color: var(--text); font-family: var(--sans); font-size: 16px; line-height: 1.5;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 60; opacity: .07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 240 240' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(80% 70% at 50% 45%, transparent 45%, rgba(10, 7, 8, .35) 78%, rgba(10, 7, 8, .7) 100%);
}
body > * { position: relative; z-index: 1; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mono { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0; }

.curtain {
  height: 12px; position: relative; z-index: 2;
  background: linear-gradient(180deg, #e4c15a, #c9a040 55%, #a97f2a);
  box-shadow: inset 0 -1px 0 rgba(255, 230, 160, .25);
}
.curtain::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 17px;
  background: radial-gradient(circle at 20px 0, #c9a040 0 12.5px, #c4572a 12.5px 15px, rgba(18, 9, 5, .75) 15px 16px, transparent 16.5px) 0 0 / 40px 17px repeat-x;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .45));
}

.top__inner { max-width: 720px; margin: 0 auto; padding: 24px 16px 8px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.logo img { width: auto; height: 46px; flex-shrink: 0; filter: drop-shadow(0 0 12px rgba(214, 173, 79, .3)); }
.logo span { font-family: var(--fancy); font-size: 34px; line-height: 1; color: var(--gold); text-shadow: 0 0 18px rgba(214, 173, 79, .25); }
.top__actions { display: flex; gap: 8px; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line-strong); border-radius: 50%; background: rgba(20, 16, 14, .7); cursor: pointer; font-family: var(--fancy); font-size: 20px; color: var(--gold); }
.icon-btn:hover { border-color: var(--gold); }

.game { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 14px 16px 40px; display: flex; flex-direction: column; gap: 16px; }
.modes { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line-strong); border-radius: 999px; align-self: flex-start; background: rgba(20, 16, 14, .7); }
.mode { min-height: 40px; padding: 0 18px; border: 0; border-radius: 999px; background: transparent; cursor: pointer; font-family: var(--fancy); font-size: 17px; color: var(--text-2); }
.mode.is-on { background: linear-gradient(130deg, var(--gold-1), var(--gold-2) 65%, var(--gold-3)); color: var(--hit-ink); }
.mode span { font-family: var(--mono); font-size: 12px; }
.intro { margin: 0; color: var(--text); text-shadow: 0 1px 12px rgba(0, 0, 0, .9); font-family: var(--fancy); font-size: 21px; line-height: 1.3; }

.guess { display: flex; align-items: center; gap: 12px; position: relative; z-index: 5; }
.guess__box { flex: 1; position: relative; }
.guess input { width: 100%; height: 54px; padding: 0 18px; border: 1px solid var(--line-strong); border-radius: 10px; background: linear-gradient(rgba(24, 19, 16, .96), rgba(16, 12, 10, .98)); color: var(--text); font: inherit; font-size: 17px; outline: none; box-shadow: inset 0 1px 0 rgba(255, 220, 160, .05); }
.guess input::placeholder { color: var(--muted); }
.guess input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(214, 173, 79, .15); }
.guess__count { font-family: var(--mono); font-size: 13px; color: var(--muted); white-space: nowrap; }
.suggest { position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px; list-style: none; max-height: 320px; overflow-y: auto; background: #1a120f; border: 1px solid var(--gold-3); border-radius: 10px; box-shadow: 0 16px 40px rgba(0, 0, 0, .7); }
.suggest li { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li:hover { background: rgba(138, 44, 62, .45); }
.suggest img { width: 36px; height: 36px; border-radius: 3px; flex-shrink: 0; }
.suggest .s__t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--fancy); font-size: 18px; }
.suggest .s__r { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; padding-left: 8px; }
.suggest .s__m { color: var(--gold); }
.suggest .s__none { color: var(--muted); cursor: default; }

.hint { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 1px dashed var(--gold-3); border-radius: 10px; background: rgba(20, 16, 14, .7); color: var(--text-2); font-size: 15px; }
.hint b { font-family: var(--fancy); font-weight: 400; font-size: 26px; line-height: 1; color: var(--gold); min-width: 22px; text-align: center; }

.board { position: relative; padding: 18px 16px 20px; border-radius: 6px; background: linear-gradient(rgba(20, 16, 14, .85), rgba(15, 12, 10, .95)); border: 2px solid var(--gold-3); box-shadow: inset 0 0 0 5px #1b1310, inset 0 0 0 6px rgba(205, 163, 69, .45), 0 18px 50px rgba(0, 0, 0, .55); }
.board::before { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: 4px; opacity: .28;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='90'%3E%3Cg fill='%23cda345'%3E%3Cpath d='M14 8l1.4 3.6 3.6 1.4-3.6 1.4L14 18l-1.4-3.6L9 13l3.6-1.4z'/%3E%3Cpath d='M66 52l1 2.6 2.6 1-2.6 1-1 2.6-1-2.6-2.6-1 2.6-1z'/%3E%3Ccircle cx='48' cy='20' r='1.1'/%3E%3Ccircle cx='25' cy='70' r='1.1'/%3E%3Ccircle cx='80' cy='14' r='.9'/%3E%3Ccircle cx='8' cy='44' r='.9'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 90px 90px;
  padding: 10px; -webkit-mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); }
.board--empty { display: none; }
.board__head, .tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.board__head { padding-bottom: 8px; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: center; }
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column-reverse; gap: 14px; }
.row { display: flex; flex-direction: column; gap: 6px; }
.row__song { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row__song img { width: 28px; height: 28px; border-radius: 3px; flex-shrink: 0; }
.row__song span { font-family: var(--fancy); font-size: 21px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row--win .row__song span { color: var(--gold); text-shadow: 0 0 14px rgba(214, 173, 79, .4); }
.tile { min-height: 58px; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 6px; background: var(--miss); border: 1px solid var(--line); text-align: center; font-size: 13px; font-weight: 500; line-height: 1.15; overflow-wrap: anywhere; color: var(--text-2); }
.tile--hit { background: linear-gradient(130deg, var(--gold-1), var(--gold-2) 60%, var(--gold-3)); border-color: var(--gold-2); color: var(--hit-ink); font-weight: 600; }
.tile--near { background: linear-gradient(160deg, #a23649, var(--near) 55%, #6b1d2c); border-color: #a23649; color: var(--near-ink); }
.tile .arr { font-size: 15px; line-height: 1; }
.tile__img { width: 30px; height: 30px; border-radius: 3px; }
.tile__name { font-size: 11px; }
.row--new .tile { animation: flip .5s ease both; }
.row--new .tile:nth-child(2) { animation-delay: .08s; }
.row--new .tile:nth-child(3) { animation-delay: .16s; }
.row--new .tile:nth-child(4) { animation-delay: .24s; }
.row--new .tile:nth-child(5) { animation-delay: .32s; }
.row--new .tile:nth-child(6) { animation-delay: .4s; }
@keyframes flip { from { transform: rotateX(90deg); opacity: 0; } to { transform: none; opacity: 1; } }

.result { padding: 20px; border-radius: 6px; background: linear-gradient(rgba(24, 19, 16, .96), rgba(16, 12, 10, .98)); border: 2px solid var(--gold-3); box-shadow: inset 0 0 0 5px #1b1310, inset 0 0 0 6px rgba(205, 163, 69, .45); display: flex; flex-direction: column; gap: 16px; }
.result__top { display: flex; gap: 16px; align-items: center; }
.mirror { position: relative; flex-shrink: 0; width: 104px; aspect-ratio: 488 / 1000; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .55)); }
.mirror__cover { position: absolute; left: 22.3%; top: 40.4%; width: 56.5%; height: 45.7%; object-fit: cover; }
.mirror::after { content: ""; position: absolute; left: 22.3%; top: 40.4%; width: 56.5%; height: 45.7%; background: linear-gradient(135deg, rgba(255, 255, 255, .16), transparent 38%, transparent 70%, rgba(255, 255, 255, .06)); pointer-events: none; }
.mirror__frame { position: absolute; inset: 0; width: 100%; height: 100%; }
.result__label { font-family: var(--mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.result__title { font-family: var(--fancy); font-weight: 400; font-size: 34px; line-height: 1.05; margin: 4px 0; overflow-wrap: anywhere; color: var(--gold); }
.result__meta { color: var(--text-2); font-size: 14px; }
.result__btns { display: flex; flex-wrap: wrap; gap: 10px; }
.result__next { font-family: var(--mono); font-size: 13px; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 22px; border: 0; border-radius: 999px; font-family: var(--fancy); font-size: 18px; text-decoration: none; cursor: pointer; }
.btn--gold { background: linear-gradient(130deg, var(--gold-1), var(--gold-2) 65%, var(--gold-3)); color: var(--hit-ink); box-shadow: 0 0 18px rgba(214, 173, 79, .2); }
.btn--gold:hover { filter: brightness(1.08); }
.btn--velvet { background: linear-gradient(160deg, #a23649, var(--velvet)); color: var(--text); }
.btn--velvet:hover { filter: brightness(1.12); }
.btn--ghost { border: 1px solid var(--line-strong); background: transparent; color: var(--text); }
.btn--ghost:hover { border-color: var(--gold); }

.foot { border-top: 1px solid var(--line); background: rgba(10, 7, 8, .78); }
.foot p { max-width: 720px; margin: 0 auto; padding: 20px 16px 28px; font-size: 13px; color: var(--muted); }
.foot a { color: var(--text-2); text-underline-offset: 3px; }
.foot p.foot__art { padding-top: 0; margin-top: -16px; font-size: 12px; color: var(--muted); opacity: .85; }

.modal { width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 2px solid var(--gold-3); border-radius: 8px; background: linear-gradient(#1a130f, #120d0b); color: var(--text); box-shadow: inset 0 0 0 5px #1b1310, inset 0 0 0 6px rgba(205, 163, 69, .4), 0 30px 80px rgba(0, 0, 0, .8); }
.modal::backdrop { background: rgba(5, 3, 3, .78); }
.modal__inner { padding: 22px 24px 26px; display: flex; flex-direction: column; gap: 14px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; }
.modal h2 { margin: 0; font-family: var(--fancy); font-weight: 400; font-size: 32px; color: var(--gold); }
.modal p { margin: 0; color: var(--text-2); }
.modal .btn { align-self: flex-start; }
.legend { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; color: var(--text-2); font-size: 15px; }
.legend li { display: grid; grid-template-columns: 76px 1fr; gap: 8px; align-items: baseline; }
.legend b { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--gold); }
.keys { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 6px; background: rgba(0, 0, 0, .35); border: 1px solid var(--line); font-size: 14px; color: var(--text-2); }
.keys span { display: flex; align-items: center; gap: 10px; }
.sw { width: 18px; height: 18px; border-radius: 4px; flex-shrink: 0; border: 1px solid var(--line); }
.sw--hit { background: var(--hit); }
.sw--near { background: var(--near); }
.sw--miss { background: var(--miss); }
.arrow { width: 18px; flex-shrink: 0; font-size: 13px; color: var(--text); white-space: nowrap; }
.nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.nums div { display: flex; flex-direction: column; gap: 2px; }
.nums b { font-family: var(--fancy); font-weight: 400; font-size: 36px; line-height: 1; color: var(--gold); }
.nums span { font-size: 12px; color: var(--muted); }
.dist { display: flex; flex-direction: column; gap: 4px; }
.dist div { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 13px; }
.dist i { display: block; min-width: 26px; padding: 2px 8px; border-radius: 3px; background: var(--miss); border: 1px solid var(--line); font-style: normal; text-align: right; }
.dist i.is-today { background: var(--hit); border-color: var(--gold-2); color: var(--hit-ink); }
.small { font-size: 13px; }
.modal--share { width: min(560px, calc(100vw - 24px)); }
.share__img { display: flex; justify-content: center; min-height: 200px; border-radius: 6px; background: rgba(0, 0, 0, .35); }
.share__img img { display: block; width: auto; max-width: 100%; max-height: 46vh; border-radius: 6px; }
.share__img img:not([src]) { visibility: hidden; }
.share__text { margin: 0; padding: 12px 14px; border-radius: 6px; background: rgba(0, 0, 0, .35); border: 1px solid var(--line); font-family: var(--mono); font-size: 14px; line-height: 1.35; color: var(--text-2); white-space: pre-wrap; }
.share__btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.share__btns .btn { width: 100%; }

.toast { position: fixed; left: 50%; top: 90px; transform: translateX(-50%); padding: 10px 20px; border-radius: 999px; background: linear-gradient(130deg, var(--gold-1), var(--gold-2) 65%, var(--gold-3)); color: var(--hit-ink); font-family: var(--fancy); font-size: 17px; z-index: 70; box-shadow: 0 8px 24px rgba(0, 0, 0, .6); }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
[hidden] { display: none !important; }

@media (max-width: 520px) {
  .curtain { height: 9px; }
  .logo span { font-size: 30px; }
  .logo img { height: 38px; }
  .intro { font-size: 19px; }
  .board { padding: 14px 10px 16px; }
  .tile { min-height: 52px; font-size: 11.5px; padding: 4px 2px; border-radius: 5px; }
  .tile__name { display: none; }
  .tile__img { width: 34px; height: 34px; }
  .board__head { font-size: 9px; letter-spacing: .02em; }
  .board__head, .tiles { gap: 4px; }
  .result__title { font-size: 28px; }
  .mirror { width: 84px; }
  .result__btns .btn { flex: 1 1 auto; }
  .nums b { font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  .row--new .tile, .shake { animation: none; }
}
