/* Угадай аниме — стили. Палитра взята с фонового изображения:
   глубокий фиолетовый, сиреневый, розовые лепестки сакуры и сияние луны. */
:root {
  --bg: #0d0720;
  --bg2: #1a1033;
  --card: rgba(26, 15, 52, .74);
  --card-solid: #1d1238;
  --border: rgba(176, 130, 255, .28);
  --text: #f1eaff;
  --muted: #a99bcb;
  --accent: #ff7eb6;          /* сакура */
  --accent2: #8b5cf6;         /* сиреневый */
  --moon: #f2c9ff;            /* свет луны */
  --ok: #4fe3a5;
  --bad: #ff6a85;
  --gold: #ffd36e;
  --radius: 16px;
  --shadow: 0 10px 34px rgba(5, 0, 20, .55);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text); line-height: 1.55;
  background:
    radial-gradient(700px 420px at 6% 2%, rgba(242, 201, 255, .16), transparent 62%),      /* сияние луны */
    linear-gradient(rgba(10, 5, 26, .34), rgba(12, 6, 30, .62)),                           /* затемнение для читаемости */
    url("../img/bg.webp") center top / cover no-repeat fixed;
  background-color: var(--bg);
}
@media (max-width: 800px) {
  body { background-image:
    radial-gradient(500px 300px at 6% 2%, rgba(242, 201, 255, .16), transparent 62%),
    linear-gradient(rgba(10, 5, 26, .34), rgba(12, 6, 30, .62)),
    url("../img/bg-small.webp"); }
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 2rem; margin: .4em 0 .3em; line-height: 1.2; }
h2 { font-size: 1.25rem; margin: 0 0 .8em; }
code { background: rgba(139, 92, 246, .22); padding: 1px 7px; border-radius: 6px; font-size: .92em; }
.container { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 20px; position: relative; z-index: 1; }
main.container { flex: 1; padding-top: 28px; padding-bottom: 40px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: .85rem; }
.inline { display: inline; margin: 0; }

/* Падающие лепестки сакуры (позиция/скорость задаёт petals.js; отключаются при prefers-reduced-motion) */
.petals { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.petals span {
  position: absolute; top: -30px; left: 0; width: 11px; height: 8px;
  background: radial-gradient(circle at 30% 30%, #ffc2de, #ff7eb6); border-radius: 80% 0 80% 0; opacity: 0;
  will-change: transform, opacity;
}
@keyframes fall {
  0% { transform: translate3d(0, -4vh, 0) rotate(0deg); opacity: 0; }
  8% { opacity: .75; }
  50% { transform: translate3d(calc(var(--drift, 40px) * .6), 55vh, 0) rotate(calc(var(--spin, 400deg) * .5)); }
  100% { transform: translate3d(var(--drift, -40px), 108vh, 0) rotate(var(--spin, 420deg)); opacity: .15; }
}
@media (prefers-reduced-motion: reduce) { .petals { display: none; } }

/* Шапка */
.topbar { background: rgba(13, 7, 32, .72); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 62px; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.25rem; color: var(--text); letter-spacing: .2px; display: flex; align-items: center; gap: 10px; }
.brand:hover { text-decoration: none; }
.brand-moon { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff, var(--moon) 45%, #c58cff); box-shadow: 0 0 16px 3px rgba(242, 201, 255, .55); }
.nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.nav a { color: var(--text); opacity: .85; }
.nav a:hover { opacity: 1; text-decoration: none; color: var(--accent); }
.nav a.btn { color: #fff; opacity: 1; }
.nav-user { display: flex; align-items: center; gap: 8px; }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }
.link-btn:hover { color: var(--accent); }

/* Аватары */
.avatar { border-radius: 50%; object-fit: cover; flex: none; display: inline-block; vertical-align: middle; }
.avatar-sm { width: 30px; height: 30px; }
.avatar-md { width: 48px; height: 48px; }
.avatar-lg { width: 112px; height: 112px; }
.avatar-letter { display: inline-grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.avatar-sm.avatar-letter { font-size: .9rem; }
.avatar-md.avatar-letter { font-size: 1.3rem; }
.avatar-lg.avatar-letter { font-size: 3rem; }
.avatar-lg { box-shadow: 0 0 0 4px rgba(255, 126, 182, .35), 0 0 28px rgba(139, 92, 246, .5); }
.player { display: inline-flex; align-items: center; gap: 10px; }

/* Кнопки */
.btn {
  display: inline-block; border: 0; cursor: pointer; font: inherit; font-weight: 700;
  color: #fff; padding: 11px 24px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 6px 20px rgba(255, 126, 182, .28);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.1); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn-small { padding: 7px 16px; font-size: .9rem; }
.btn-big { padding: 14px 34px; font-size: 1.1rem; }
.btn-block { width: 100%; }
.btn-ghost { background: rgba(26, 15, 52, .4); border: 2px solid var(--border); box-shadow: none; color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); }

/* Карточки и сетки */
.card { background: var(--card); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); margin-bottom: 22px; }
.grid3, .grid4 { display: grid; gap: 18px; margin-bottom: 22px; }
.grid3 { grid-template-columns: repeat(3, 1fr); }
.grid4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid3 .card, .grid4 .card { margin: 0; }
.stat { text-align: center; padding: 18px 12px; }
.stat-num { font-size: 2rem; font-weight: 800; background: linear-gradient(135deg, var(--moon), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.hero { text-align: center; padding: 34px 0 26px; }
.hero-kicker { display: inline-block; padding: 4px 16px; border-radius: 99px; border: 1px solid var(--border); background: rgba(26, 15, 52, .55); color: var(--moon); font-size: .9rem; margin-bottom: 8px; }
.hero h1 { font-size: 2.6rem; background: linear-gradient(135deg, #fff, var(--moon) 45%, var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: 0 0 40px rgba(242, 201, 255, .25); }
.lead { font-size: 1.1rem; color: #ddd2f6; max-width: 640px; margin: 0 auto 1.4em; }
.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; align-items: center; }
.hero form { margin: 0; }

.rules h2 { font-size: 1.4rem; }
.rules-list { margin: 0; padding-left: 1.3em; }
.rules-list li { margin: .55em 0; }

/* Flash-сообщения */
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; border: 1px solid var(--border); background: var(--card); backdrop-filter: blur(8px); }
.flash-success { border-color: var(--ok); background: rgba(79, 227, 165, .12); }
.flash-error { border-color: var(--bad); background: rgba(255, 106, 133, .13); }

/* Формы */
.form-card { max-width: 420px; margin: 20px auto; }
.form-card h1 { margin-top: 0; font-size: 1.7rem; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .92rem; }
input[type=text], input[type=password], .field input {
  width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: rgba(13, 7, 32, .6); color: var(--text); font: inherit;
}
input[type=file] { width: 100%; padding: 8px; border-radius: 12px; border: 1px dashed var(--border); background: rgba(13, 7, 32, .45); color: var(--muted); font: inherit; }
input[type=file]::file-selector-button { margin-right: 12px; padding: 6px 14px; border: 0; border-radius: 99px; color: #fff; font-weight: 600; cursor: pointer; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
input:focus { outline: 2px solid var(--accent2); border-color: transparent; }
.field-error { color: var(--bad); font-size: .85rem; margin-top: 4px; }

/* Игра */
.play { max-width: 760px; margin: 0 auto; }
.play-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); margin-bottom: 10px; flex-wrap: wrap; }
.play-head strong { color: var(--text); }
.progress, .timer { height: 8px; background: rgba(13, 7, 32, .7); border-radius: 99px; overflow: hidden; }
.progress { margin-bottom: 14px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); border-radius: 99px; transition: width .4s; }
.timer { height: 6px; }
.timer-bar { height: 100%; width: 100%; background: var(--ok); border-radius: 99px; }
.timer-bar.danger { background: var(--bad); }
.timer-row { display: flex; justify-content: space-between; align-items: center; margin: 6px 0 8px; font-size: .88rem; }
.bonus-chip { padding: 3px 12px; border-radius: 99px; background: rgba(26, 15, 52, .8); border: 1px solid var(--border); color: var(--muted); transition: all .2s; }
.bonus-chip strong { color: var(--text); }
.bonus-chip.fast { border-color: var(--gold); color: var(--gold); background: rgba(255, 211, 110, .12); box-shadow: 0 0 16px rgba(255, 211, 110, .25); }
.bonus-chip.fast strong { color: var(--gold); }
.bonus-chip.hinted:not(.fast) { border-color: var(--accent2); }

.frames { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 10px 0 16px; }
.frames.two { grid-template-columns: 1fr 1fr; }
.frame { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; border-radius: var(--radius); box-shadow: 0 14px 40px rgba(0, 0, 0, .6), 0 0 0 1px var(--border); background: #000; }

.hints { margin-bottom: 14px; padding: 12px 14px; border-radius: 14px; background: rgba(26, 15, 52, .6); border: 1px solid var(--border); }
.hints-title { font-weight: 600; font-size: .92rem; margin-bottom: 8px; }
.hint-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.hint-btn { font: inherit; font-size: .88rem; font-weight: 600; padding: 6px 14px; border-radius: 99px; cursor: pointer; color: var(--text); background: rgba(139, 92, 246, .18); border: 1px solid var(--accent2); transition: all .12s; }
.hint-btn:hover:not(:disabled) { background: rgba(139, 92, 246, .4); transform: translateY(-1px); }
.hint-btn:disabled { opacity: .45; cursor: default; }
.hint-out { display: grid; gap: 4px; margin-top: 8px; font-size: .95rem; }
.hint-out > div[hidden] { display: none; }
.hint-out .mask { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 2px; font-size: 1.05rem; color: var(--moon); }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.option {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  padding: 14px 16px; border-radius: 14px; font: inherit; font-weight: 600; color: var(--text);
  background: var(--card); backdrop-filter: blur(6px); border: 2px solid var(--border); cursor: pointer;
  transition: border-color .12s, transform .12s, background .12s;
}
button.option:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-2px); background: rgba(52, 30, 100, .8); }
button.option:disabled { cursor: default; }
button.option.removed { opacity: .28; text-decoration: line-through; }
.option-key { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: rgba(13, 7, 32, .7); color: var(--muted); font-size: .85rem; }
.option-static { cursor: default; opacity: .75; }
.option-static.is-correct { border-color: var(--ok); background: rgba(79, 227, 165, .14); opacity: 1; }
.option-static.is-wrong { border-color: var(--bad); background: rgba(255, 106, 133, .14); opacity: 1; }
.is-correct .option-key { background: var(--ok); color: #06251a; }
.is-wrong .option-key { background: var(--bad); color: #fff; }
.feedback { text-align: center; padding: 18px 22px; }
.feedback h2 { margin-bottom: .3em; }
.feedback p { margin: .3em 0 1em; }
.fb-ok { border-color: var(--ok); }
.fb-bad { border-color: var(--bad); }

/* Результат */
.big-score { font-size: 4.5rem; font-weight: 900; line-height: 1.1; background: linear-gradient(135deg, var(--gold), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.badge { display: inline-block; padding: 6px 16px; border-radius: 99px; font-weight: 700; margin-bottom: 8px; }
.badge-gold { background: rgba(255, 211, 110, .15); color: var(--gold); border: 1px solid var(--gold); }
.review { list-style: none; margin: 0; padding: 0; }
.review li { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.review li:last-child { border-bottom: 0; }
.review img { width: 44px; height: 62px; object-fit: cover; border-radius: 6px; }
.review-text { flex: 1; display: flex; flex-direction: column; }
.review-pts { font-weight: 800; font-size: 1.1rem; }
.review .ok .review-pts { color: var(--ok); }
.review .bad .review-pts { color: var(--bad); }

/* Таблицы */
.table-card { padding: 18px 8px 8px; overflow-x: auto; }
.table-card h2 { padding: 0 16px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .85rem; padding: 10px 16px; text-transform: uppercase; letter-spacing: .5px; }
.table td { padding: 10px 16px; border-top: 1px solid var(--border); }
.table .num { text-align: right; }
.table tr.me td { background: rgba(139, 92, 246, .18); }
.place { font-weight: 800; font-size: 1.15rem; width: 56px; }

/* Режимы на главной */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 22px; }
.mode-card { text-align: center; margin: 0; display: flex; flex-direction: column; align-items: center; }
.mode-card h2 { margin-bottom: .1em; font-size: 1.6rem; }
.mode-sub { color: var(--moon); font-weight: 600; margin-bottom: .6em; }
.mode-card .mode-desc { flex: 1; max-width: 360px; }
.mode-icon { font-size: 2.4rem; }
.mode-img {
  width: 140px; height: 140px; object-fit: cover; border-radius: 18px;
  border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(5, 0, 20, .45);
  margin-bottom: .6em;
}
.mode-hard { border-color: rgba(255, 126, 182, .6); background: linear-gradient(160deg, rgba(60, 24, 80, .78), var(--card)); }
.mode-wide {
  display: flex; flex-direction: row; align-items: center; gap: 28px;
  text-align: left; margin-bottom: 22px; min-height: 180px; padding: 22px 28px;
}
.mode-wide .mode-wide-img {
  flex: none; width: 140px; height: 140px; object-fit: cover; border-radius: 18px;
  border: 1px solid rgba(255, 211, 110, .45);
  box-shadow: 0 8px 24px rgba(5, 0, 20, .45);
}
.mode-wide .mode-wide-body { flex: 1; min-width: 0; }
.mode-wide .mode-wide-body h2 { margin: 0 0 .35em; font-size: 1.6rem; }
.mode-wide .mode-desc { max-width: none; margin: 0 0 1em; }
.mode-wide form { display: inline-block; margin: 0 14px 0 0; vertical-align: middle; }
.mode-wide .muted.small { display: inline-block; margin: 0; vertical-align: middle; }
.mode-marathon { border-color: rgba(255, 211, 110, .45); background: linear-gradient(120deg, rgba(50, 32, 18, .55), var(--card)); }
.mode-pill { display: inline-block; padding: 2px 12px; border-radius: 99px; font-size: .82rem; font-weight: 600; background: rgba(13, 7, 32, .7); border: 1px solid var(--border); color: var(--text); }
.mode-pill.mode-hard { border-color: var(--accent); color: #ffd0e5; background: rgba(255, 126, 182, .14); }
.mode-pill.mode-marathon { border-color: var(--gold); color: var(--gold); background: rgba(255, 211, 110, .12); }
.hero .mode-pill { margin-bottom: 10px; }

/* Профиль */
.profile-card { display: flex; align-items: center; gap: 24px; }
.profile-card h1 { margin: 0; }
.profile-card p { margin: 4px 0 0; }
.edit-card h2 { margin-bottom: 1em; }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.edit-form label { display: block; margin-bottom: 6px; }
.edit-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* Вкладки */
.tabs { display: flex; gap: 10px; margin: 8px 0 14px; flex-wrap: wrap; }
.tab { padding: 9px 20px; border-radius: 99px; border: 2px solid var(--border); color: var(--text); font-weight: 600; background: var(--card); }
.tab:hover { text-decoration: none; border-color: var(--accent); }
.tab.active { background-origin: border-box; background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; color: #fff; }

/* Ввод названия и автодополнение */
.ac { position: relative; margin-bottom: 14px; }
.ac-input { width: 100%; padding: 15px 18px; font: inherit; font-size: 1.1rem; color: var(--text); background: var(--card); border: 2px solid var(--border); border-radius: 14px; }
.ac-input:focus { outline: none; border-color: var(--accent2); box-shadow: 0 0 0 4px rgba(139, 92, 246, .25); }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 40; margin: 0; padding: 6px; list-style: none; background: #24143f; border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 16px 40px rgba(0, 0, 0, .6); max-height: 340px; overflow-y: auto; }
.ac-list[hidden] { display: none; }
.ac-item { display: flex; flex-direction: column; padding: 9px 12px; border-radius: 9px; cursor: pointer; }
.ac-item.active { background: rgba(139, 92, 246, .38); }
.ac-title { font-weight: 600; }
.ac-alias { font-size: .82rem; color: var(--muted); }
.ac-item mark { background: none; color: var(--accent); font-weight: 800; }
.text-actions { display: flex; gap: 12px; justify-content: center; margin-bottom: 10px; }

.footer { border-top: 1px solid var(--border); padding: 18px 0; color: var(--muted); font-size: .85rem; text-align: center; background: rgba(13, 7, 32, .5); position: relative; z-index: 1; }

@media (max-width: 720px) {
  .grid3 { grid-template-columns: 1fr 1fr; }
  .modes, .edit-grid { grid-template-columns: 1fr; }
  .mode-wide { flex-direction: column; text-align: center; min-height: 0; gap: 16px; }
  .mode-wide form, .mode-wide .muted.small { display: block; margin: 8px auto 0; }
  .options { grid-template-columns: 1fr; }
  .frames.two { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.9rem; }
  .big-score { font-size: 3.4rem; }
  .profile-card { flex-direction: column; text-align: center; }
}
