:root {
  color-scheme: dark;
  --bg: #08070c;
  --panel: rgba(22, 19, 32, .78);
  --panel-strong: #17131f;
  --text: #f8f4ff;
  --muted: #aaa2b8;
  --accent: #ff2e63;
  --accent-2: #8a4dff;
  --line: rgba(255, 255, 255, .1);
  --danger: #ff5964;
  --success: #55d6a0;
  --radius: 24px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 0%, rgba(138, 77, 255, .18), transparent 38%),
    radial-gradient(circle at 90% 90%, rgba(255, 46, 99, .14), transparent 35%),
    var(--bg);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .22;
  background-image: linear-gradient(rgba(255,255,255,.02) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(to bottom, black, transparent 75%);
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.topbar {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 26px rgba(255,46,99,.26);
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn, .ghost-btn, .soft-btn, .danger-btn, .primary-btn {
  border: 1px solid var(--line); cursor: pointer; border-radius: 14px; transition: .2s ease;
}
.icon-btn { width: 42px; height: 42px; background: rgba(255,255,255,.04); font-size: 18px; }
.ghost-btn, .soft-btn, .danger-btn, .primary-btn { padding: 11px 16px; font-weight: 700; }
.ghost-btn { background: transparent; }
.soft-btn { background: rgba(255,255,255,.06); }
.danger-btn { background: rgba(255,89,100,.1); color: #ff8991; border-color: rgba(255,89,100,.25); }
.primary-btn { background: linear-gradient(135deg, var(--accent), #d51f85); border-color: transparent; box-shadow: 0 10px 28px rgba(255,46,99,.22); }
button:hover:not(:disabled) { transform: translateY(-2px); border-color: rgba(255,255,255,.22); }
button:active:not(:disabled) { transform: translateY(0) scale(.98); }
button:disabled { cursor: not-allowed; opacity: .48; }

.game-shell {
  width: min(760px, calc(100% - 32px));
  min-height: calc(100vh - 164px);
  margin: 0 auto;
  padding: 20px 0 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.eyebrow { color: var(--muted); text-transform: uppercase; letter-spacing: .16em; font-size: 11px; font-weight: 800; }
.level-title { margin: 8px 0 6px; font-size: clamp(24px, 5vw, 38px); letter-spacing: -.04em; text-align: center; }
.level-title span { background: linear-gradient(90deg, #fff, #d4c6ff); background-clip: text; color: transparent; }
.remaining { margin: 0; color: var(--muted); font-size: 14px; }
.progress { width: min(420px, 88vw); height: 5px; margin-top: 16px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: inherit; transition: width .45s ease; }

.surprise-stage { position: relative; display: grid; place-items: center; width: 330px; height: 330px; margin: 28px 0 12px; }
.surprise-stage::before, .surprise-stage::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.07); }
.surprise-stage::before { inset: 18px; animation: breathe 3.2s ease-in-out infinite; }
.surprise-stage::after { inset: 0; border-style: dashed; animation: orbit 18s linear infinite; }
.surprise-button {
  position: relative; z-index: 2; width: 220px; height: 220px; border: 0; border-radius: 50%; cursor: pointer;
  background: radial-gradient(circle at 34% 28%, #ff809d, var(--accent) 38%, #951743 78%);
  box-shadow: 0 0 0 12px rgba(255,46,99,.08), 0 0 68px rgba(255,46,99,.42), inset 0 2px 4px rgba(255,255,255,.4), inset 0 -12px 24px rgba(48,0,18,.4);
  font-size: 29px; font-weight: 900; letter-spacing: -.04em; text-shadow: 0 2px 10px rgba(0,0,0,.34);
  transition: transform .25s ease, filter .25s ease;
  animation: pulse 2.5s ease-in-out infinite;
}
.surprise-button:hover:not(:disabled) { transform: scale(1.045); filter: saturate(1.12); }
.surprise-button.spinning { animation: spinButton 1.1s cubic-bezier(.5,.1,.2,1) infinite, glow 1s ease-in-out infinite alternate; }
.surprise-button .button-sub { display: block; margin-top: 5px; font-size: 10px; letter-spacing: .18em; text-transform: uppercase; opacity: .72; }
.game-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; }
.consent-note { max-width: 520px; margin: 24px auto 0; color: #888092; text-align: center; font-size: 12px; line-height: 1.6; }

.modal-backdrop {
  position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px;
  background: rgba(5,4,8,.78); backdrop-filter: blur(14px); animation: fade .25s ease;
}
.modal { width: min(470px, 100%); }
.reveal-card { perspective: 1200px; }
.card-inner {
  min-height: 470px; position: relative; transform-style: preserve-3d; transition: transform .8s cubic-bezier(.2,.8,.2,1);
  animation: cardEnter .85s cubic-bezier(.15,.82,.22,1) both;
}
.reveal-card.flipped .card-inner { transform: rotateY(0); }
.card-face {
  min-height: 470px; padding: 28px; border-radius: 30px; border: 1px solid rgba(255,255,255,.16);
  background: linear-gradient(145deg, rgba(40,31,54,.98), rgba(16,13,23,.98));
  box-shadow: 0 32px 90px rgba(0,0,0,.55), 0 0 60px color-mix(in srgb, var(--card-color, var(--accent)) 22%, transparent);
  display: flex; flex-direction: column; overflow: hidden;
}
.card-face::before { content: ""; position: absolute; inset: 0 0 auto; height: 5px; background: var(--card-color, var(--accent)); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card-badge { padding: 7px 10px; border-radius: 99px; background: color-mix(in srgb, var(--card-color) 15%, transparent); color: var(--card-color); font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.card-index { color: #7f778a; font-size: 12px; font-variant-numeric: tabular-nums; }
.card-content { flex: 1; display: grid; place-items: center; margin: 34px 0; text-align: center; font-size: clamp(25px, 6vw, 34px); font-weight: 800; line-height: 1.22; letter-spacing: -.035em; white-space: pre-line; }
.card-footer { display: grid; gap: 10px; }
.card-footer .primary-btn { min-height: 51px; }
.card-secondary { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.age-modal .modal { width: min(520px, 100%); padding: 34px; border-radius: 28px; border: 1px solid var(--line); background: #15111d; box-shadow: 0 30px 100px #000; text-align: center; }
.age-icon { width: 72px; height: 72px; margin: 0 auto 18px; border-radius: 22px; display: grid; place-items: center; background: rgba(255,46,99,.12); color: #ff6c91; font-size: 28px; font-weight: 900; }
.age-modal h2 { margin: 0 0 12px; font-size: 30px; }
.age-modal p { color: var(--muted); line-height: 1.65; }
.age-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(24,20,32,.96); box-shadow: 0 18px 50px #0008; color: var(--text); font-size: 14px; transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.page-shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 70px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 14px 0 28px; }
.page-heading h1 { margin: 6px 0 0; font-size: clamp(32px, 6vw, 54px); letter-spacing: -.055em; }
.page-heading p { margin: 8px 0 0; color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 26px; }
.stat { padding: 17px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.035); }
.stat-value { display: block; font-size: 27px; font-weight: 900; letter-spacing: -.04em; }
.stat-label { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.3; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); position: sticky; top: 10px; z-index: 5; backdrop-filter: blur(18px); }
.field { display: grid; gap: 7px; }
.field label { color: var(--muted); font-size: 12px; font-weight: 700; }
.input, .textarea, .select { width: 100%; color: var(--text); background: #100d16; border: 1px solid var(--line); border-radius: 12px; outline: none; transition: .2s; }
.input, .select { min-height: 43px; padding: 0 12px; }
.textarea { min-height: 130px; resize: vertical; padding: 12px; line-height: 1.5; }
.input:focus, .textarea:focus, .select:focus { border-color: rgba(138,77,255,.75); box-shadow: 0 0 0 3px rgba(138,77,255,.12); }
.toolbar .input { flex: 1; min-width: 210px; }
.cards-table { margin-top: 14px; display: grid; gap: 8px; }
.admin-card { display: grid; grid-template-columns: 44px minmax(220px, 1fr) 150px 90px 90px 126px; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.03); transition: .2s; }
.admin-card:hover { background: rgba(255,255,255,.05); }
.admin-card.inactive { opacity: .52; }
.drag-handle { color: #635b6e; cursor: grab; text-align: center; font-size: 19px; }
.admin-content { white-space: pre-line; line-height: 1.45; }
.admin-meta { color: var(--muted); font-size: 12px; }
.pill { display: inline-flex; width: fit-content; padding: 6px 9px; border-radius: 99px; background: rgba(138,77,255,.12); color: #bba7ff; font-size: 11px; font-weight: 800; }
.row-actions { display: flex; justify-content: end; gap: 5px; }
.mini-btn { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.04); cursor: pointer; }
.empty-state { padding: 70px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 20px; }
.dialog { border: 0; padding: 0; color: var(--text); background: transparent; }
.dialog::backdrop { background: rgba(4,3,7,.76); backdrop-filter: blur(9px); }
.dialog-box { width: min(560px, calc(100vw - 32px)); padding: 26px; border: 1px solid var(--line); border-radius: 24px; background: #17131f; box-shadow: 0 30px 100px #000; }
.dialog-box h2 { margin: 0 0 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.login-wrap { min-height: calc(100vh - 90px); display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 26px; background: var(--panel-strong); box-shadow: 0 30px 90px #0008; }
.login-card h1 { margin: 8px 0 8px; font-size: 32px; letter-spacing: -.04em; }
.login-card p { margin: 0 0 24px; color: var(--muted); line-height: 1.5; }
.login-card .primary-btn { width: 100%; margin-top: 12px; min-height: 48px; }
.login-hint { text-align: center; font-size: 11px; color: #736b7e; }
.history-list { display: grid; gap: 10px; }
.history-item { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.03); }
.history-number { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; background: rgba(138,77,255,.12); color: #bba7ff; font-weight: 900; }
.history-content { white-space: pre-line; line-height: 1.45; }
.history-time { color: var(--muted); font-size: 12px; text-align: right; }

.particle { position: fixed; z-index: 30; width: 8px; height: 14px; border-radius: 2px; pointer-events: none; animation: confetti 1.35s cubic-bezier(.1,.6,.25,1) forwards; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 12px rgba(255,46,99,.07), 0 0 55px rgba(255,46,99,.32), inset 0 2px 4px rgba(255,255,255,.4), inset 0 -12px 24px rgba(48,0,18,.4); } 50% { box-shadow: 0 0 0 20px rgba(255,46,99,.025), 0 0 82px rgba(255,46,99,.48), inset 0 2px 4px rgba(255,255,255,.4), inset 0 -12px 24px rgba(48,0,18,.4); } }
@keyframes breathe { 50% { transform: scale(1.06); opacity: .35; } }
@keyframes orbit { to { transform: rotate(360deg); } }
@keyframes spinButton { 0% { transform: rotate(0) scale(1); } 45% { transform: rotate(190deg) scale(.83); } 100% { transform: rotate(720deg) scale(1); } }
@keyframes glow { to { filter: hue-rotate(35deg) brightness(1.25); } }
@keyframes fade { from { opacity: 0; } }
@keyframes cardEnter { from { opacity: 0; transform: rotateY(-135deg) scale(.72); filter: blur(14px); } to { opacity: 1; transform: rotateY(0) scale(1); filter: blur(0); } }
@keyframes confetti { to { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 0; } }

@media (max-width: 860px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .admin-card { grid-template-columns: 34px 1fr auto; }
  .admin-card > .admin-meta:nth-of-type(2), .admin-card > .admin-meta:nth-of-type(3) { display: none; }
}
@media (max-width: 560px) {
  .brand-text { display: none; }
  .topbar { padding: 16px 0; }
  .game-shell { padding-top: 8px; min-height: calc(100vh - 110px); }
  .surprise-stage { width: 280px; height: 280px; margin-top: 18px; }
  .surprise-button { width: 188px; height: 188px; font-size: 26px; }
  .game-actions .soft-btn { flex: 1 1 130px; }
  .card-inner, .card-face { min-height: min(520px, calc(100vh - 40px)); }
  .card-face { padding: 23px; }
  .card-content { margin: 24px 0; }
  .page-heading { align-items: start; flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { position: static; }
  .toolbar > * { flex: 1 1 42%; }
  .toolbar .primary-btn { flex-basis: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .admin-card { grid-template-columns: 26px 1fr; }
  .row-actions { grid-column: 2; justify-content: start; }
  .history-item { grid-template-columns: 44px 1fr; }
  .history-time { grid-column: 2; text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
