:root {
  --ink: #10151d;
  --muted: #64707e;
  --line: #dce3e8;
  --paper: #f7f8f5;
  --surface: #ffffff;
  --accent: #e74c2f;
  --accent-dark: #bd321d;
  --mint: #20aa94;
  --sun: #f2bb48;
  --navy: #203b62;
  --shadow: 0 16px 40px rgb(16 21 29 / 8%);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.shell { min-height: 100vh; display: flex; flex-direction: column; }
.site-header, main, footer { width: min(1160px, calc(100% - 40px)); margin: 0 auto; }
.site-header { height: 76px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: 0; }
.brand-logo { width: 34px; height: 34px; max-width: 34px; max-height: 34px; display: block; flex: 0 0 34px; object-fit: contain; object-position: center; background: #1b1c22; border-radius: 6px; }
.nav { display: flex; gap: 24px; font-size: 14px; color: var(--muted); }
.nav a:hover { color: var(--ink); }
main { flex: 1; padding-bottom: 72px; }
main:focus { outline: none; }
footer { padding: 22px 0 28px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

.boot-loading { min-height: 360px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); text-align: center; }
.boot-loading strong { color: var(--ink); font-size: 17px; }
.boot-loading span:last-child { font-size: 13px; }
.boot-spinner { width: 30px; height: 30px; border: 3px solid #dce3e8; border-top-color: var(--accent); border-radius: 50%; animation: boot-spin .8s linear infinite; }
@keyframes boot-spin { to { transform: rotate(360deg); } }

.hero { position: relative; overflow: hidden; min-height: 325px; padding: 58px; background: var(--ink); color: white; }
.hero::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgb(16 21 29 / .95) 0%, rgb(16 21 29 / .75) 46%, rgb(16 21 29 / .25) 100%); }
.hero-art { position: absolute; inset: 0; background: radial-gradient(circle at 82% 38%, #d9a752 0 5%, transparent 5.5%), radial-gradient(circle at 67% 68%, #d65a35 0 13%, transparent 13.5%), linear-gradient(125deg, #263b61 2%, #11263d 46%, #264d62 100%); opacity: .96; }
.hero-art::after { content: ""; position: absolute; width: 240px; height: 240px; top: 47px; right: 118px; border: 32px solid rgb(255 255 255 / .14); border-left-color: transparent; border-radius: 50%; transform: rotate(-30deg); }
.hero-content { position: relative; z-index: 1; max-width: 600px; }
.eyebrow { margin: 0 0 11px; color: #f8c75c; font-family: "Space Grotesk", "Noto Sans SC", sans-serif; font-weight: 700; font-size: 13px; letter-spacing: .06em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 14px; font-size: 42px; line-height: 1.22; letter-spacing: 0; }
.hero p:last-child { color: rgb(255 255 255 / .72); margin-bottom: 0; font-size: 16px; }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 52px 0 18px; }
.section-head h2 { margin: 0; font-size: 24px; letter-spacing: 0; }
.section-head p { margin: 0; font-size: 14px; color: var(--muted); }
.library-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.library-card { position: relative; min-height: 208px; padding: 24px; display: flex; flex-direction: column; justify-content: space-between; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.library-card:hover { transform: translateY(-3px); border-color: var(--ink); box-shadow: var(--shadow); }
.library-index { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 50%; background: #eef1f2; color: var(--navy); font: 700 15px "Space Grotesk", sans-serif; }
.library-card:nth-child(2) .library-index { background: #e9f6f3; color: var(--mint); }
.library-card:nth-child(3) .library-index { background: #fff4d8; color: #b77803; }
.library-card:nth-child(4n) .library-index { background: #fbeae7; color: var(--accent); }
.library-card h3 { margin: 24px 0 7px; font-size: 18px; line-height: 1.4; }
.library-card p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.card-foot { display: flex; align-items: center; justify-content: space-between; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.card-arrow { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); }

.search-panel { margin-top: 52px; padding: 32px; border-radius: 7px; background: #e4ecea; display: grid; grid-template-columns: 1fr minmax(260px, 1.45fr); align-items: center; gap: 32px; }
.search-panel h2 { margin-bottom: 7px; font-size: 24px; }
.search-panel p { margin-bottom: 0; color: #4e615e; font-size: 14px; }
.search-box { position: relative; }
.search-box svg { position: absolute; width: 20px; height: 20px; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); fill: none; stroke: currentColor; stroke-width: 1.8; }
.search-box input { width: 100%; height: 54px; padding: 0 18px 0 48px; border: 1px solid #bfcfca; border-radius: 5px; background: #fff; outline: none; color: var(--ink); }
.search-box input:focus { border-color: var(--mint); box-shadow: 0 0 0 3px rgb(32 170 148 / .14); }
.search-results { grid-column: 1 / -1; display: grid; gap: 7px; }
.search-result { padding: 13px 15px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-radius: 4px; background: rgb(255 255 255 / .68); font-size: 14px; }
.search-result span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.empty-result { color: #4e615e; font-size: 14px; }

.crumb { display: inline-flex; align-items: center; gap: 8px; margin: 14px 0 26px; color: var(--muted); font-size: 14px; }
.crumb svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.catalog-header { display: flex; justify-content: space-between; gap: 28px; padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.catalog-header h1 { margin: 0 0 8px; font-size: 32px; color: var(--ink); }
.catalog-header p { margin: 0; color: var(--muted); font-size: 14px; }
.library-announcement { margin: 20px 0; padding: 17px 20px; display: flex; align-items: flex-start; gap: 18px; border: 1px solid #e3d9b5; border-left: 4px solid var(--sun); background: #fffaf0; border-radius: 5px; }
.announcement-kicker { flex: none; padding-top: 2px; color: #9b6b0b; font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.library-announcement h2 { margin: 0 0 5px; font-size: 16px; line-height: 1.4; }
.library-announcement p { margin: 0; color: #6d6250; font-size: 13px; line-height: 1.65; white-space: pre-wrap; }
.catalog-tools { margin: 22px 0; display: flex; gap: 10px; }
.catalog-tools .search-box { flex: 1; }
.catalog-tools input { height: 48px; background: var(--surface); border-color: var(--line); }
.catalog-list { display: grid; gap: 18px; }
.game-group { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.game-group h3 { margin: 0; padding: 10px 16px; background: #f1f4f4; font: 700 13px "Space Grotesk", "Noto Sans SC", sans-serif; color: #41505f; }
.game-items { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.game-row { min-height: 43px; padding: 10px 16px; display: flex; align-items: center; gap: 9px; border-top: 1px solid #edf0f2; border-right: 1px solid #edf0f2; font-size: 14px; line-height: 1.45; }
.game-row:first-of-type { border-top: 0; }
.game-row:nth-child(3n) { border-right: 0; }
.new-dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--accent); }
.hot-badge { flex: none; padding: 2px 5px; border-radius: 3px; color: #9b341f; background: #fbe7e3; font-size: 10px; font-weight: 800; }
.no-games { margin: 32px 0; color: var(--muted); text-align: center; }

.message-section { margin-top: 50px; padding-top: 30px; border-top: 1px solid var(--line); }
.message-section h2 { margin-bottom: 5px; font-size: 22px; }
.message-section > p { color: var(--muted); font-size: 14px; }
.message-form { display: grid; grid-template-columns: 180px 1fr auto; gap: 10px; margin: 20px 0 28px; }
.field, textarea { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 4px; outline: none; }
.field { height: 46px; padding: 0 13px; }
textarea { min-height: 46px; padding: 11px 13px; resize: vertical; }
.field:focus, textarea:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgb(32 59 98 / .12); }
.primary-button, .secondary-button, .danger-button { min-height: 46px; padding: 0 18px; border: 0; border-radius: 4px; font-weight: 700; }
.primary-button { color: #fff; background: var(--accent); }
.primary-button:hover { background: var(--accent-dark); }
.secondary-button { color: var(--ink); background: #e9eef0; }
.danger-button { color: #a92718; background: #fbe7e3; }
.message-list { display: grid; gap: 10px; }
.message { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; }
.message-head { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 7px; }
.message-author { font-weight: 700; font-size: 14px; }
.message-time { color: var(--muted); font-size: 12px; }
.message p { margin: 0; color: #3e4855; font-size: 14px; line-height: 1.75; white-space: pre-wrap; }

.admin-page { max-width: 1000px; }
.admin-title { margin: 20px 0 6px; font-size: 32px; }
.admin-subtitle { color: var(--muted); font-size: 14px; }
.login-card { width: min(440px, 100%); margin-top: 38px; padding: 28px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; }
.login-card h2 { margin-bottom: 8px; font-size: 22px; }
.login-card p { color: var(--muted); font-size: 14px; }
.login-card form { display: grid; gap: 11px; margin-top: 20px; }
.login-card .primary-button { width: 100%; }
.hint { color: var(--muted); font-size: 12px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0; }
.admin-settings { display: grid; grid-template-columns: minmax(210px, .7fr) minmax(0, 1.3fr); gap: 28px; margin-top: 28px; padding: 22px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; }
.admin-settings h2 { margin: 0 0 6px; font-size: 18px; }
.admin-settings p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.admin-settings form { display: grid; gap: 11px; }
.admin-settings label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.admin-settings textarea { min-height: 88px; }
.admin-library { margin-bottom: 16px; padding: 22px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; }
.admin-library-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.admin-library h2 { margin: 0 0 5px; font-size: 18px; }
.admin-library p { margin: 0; color: var(--muted); font-size: 13px; }
.admin-library form { display: flex; gap: 9px; margin-top: 16px; }
.admin-library form .field { flex: 1; }
.admin-library .edit-library { display: grid; grid-template-columns: 1fr 1fr; }
.edit-library textarea { grid-column: 1 / -1; width: 100%; }
.edit-library button { justify-self: start; }
.batch-games { display: grid; grid-template-columns: 1fr auto; align-items: end; }
.batch-games textarea { min-height: 112px; }
.admin-game-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.admin-game-filter { width: min(280px, 100%); height: 38px; }
.admin-games { max-height: 520px; overflow: auto; margin-top: 10px; border-top: 1px solid var(--line); }
.admin-game { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center; padding: 9px 0; border-bottom: 1px solid #edf0f2; }
.admin-game .field { height: 38px; }
.small-button { height: 38px; padding: 0 11px; border: 0; border-radius: 4px; color: #32414c; background: #edf1f2; font-size: 12px; font-weight: 700; }
.small-button.pin-game.active { color: #9b341f; background: #fbe7e3; }
.small-button.delete { color: #a92718; background: #fbe7e3; }
.message-admin { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding: 10px 0 0; color: var(--muted); font-size: 13px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: rgb(16 21 29 / .48); }
.modal { width: min(470px, 100%); padding: 26px; border-radius: 6px; background: var(--surface); box-shadow: 0 24px 70px rgb(16 21 29 / .24); }
.modal h2 { margin-bottom: 16px; font-size: 21px; }
.modal form { display: grid; gap: 11px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.notice { position: fixed; z-index: 20; right: 22px; bottom: 22px; max-width: min(360px, calc(100% - 44px)); padding: 12px 15px; border-radius: 4px; color: #fff; background: var(--ink); box-shadow: var(--shadow); font-size: 14px; }

@media (max-width: 900px) {
  .library-grid { grid-template-columns: repeat(2, 1fr); }
  .game-items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .game-row:nth-child(3n) { border-right: 1px solid #edf0f2; }
  .game-row:nth-child(2n) { border-right: 0; }
}
@media (max-width: 620px) {
  .site-header, main, footer { width: min(100% - 28px, 1160px); }
  .site-header { height: 64px; }
  .brand { font-size: 18px; }
  .brand-logo { width: 30px; height: 30px; max-width: 30px; max-height: 30px; flex-basis: 30px; }
  .nav { gap: 15px; font-size: 13px; }
  .hero { min-height: 300px; margin-left: -14px; margin-right: -14px; padding: 42px 27px; }
  .hero-art::after { right: -66px; top: 84px; }
  h1 { font-size: 31px; }
  .section-head { margin-top: 35px; align-items: flex-start; flex-direction: column; gap: 8px; }
  .library-grid { grid-template-columns: 1fr; gap: 10px; }
  .library-card { min-height: 170px; }
  .library-card h3 { margin-top: 16px; }
  .search-panel { margin-top: 35px; padding: 24px 18px; grid-template-columns: 1fr; gap: 18px; }
  .search-results { grid-column: auto; }
  .search-result { align-items: flex-start; flex-direction: column; gap: 4px; }
  .catalog-header { flex-direction: column; gap: 12px; }
  .catalog-header h1, .admin-title { font-size: 27px; }
  .library-announcement { flex-direction: column; gap: 7px; padding: 14px 15px; }
  .catalog-tools { margin: 17px 0; }
  .game-items { grid-template-columns: 1fr; }
  .game-row, .game-row:nth-child(2n), .game-row:nth-child(3n) { border-right: 0; }
  .message-form { grid-template-columns: 1fr; }
  .message-form textarea { min-height: 92px; }
  footer { align-items: flex-start; flex-direction: column; gap: 6px; }
  .admin-library { padding: 16px; }
  .admin-settings { grid-template-columns: 1fr; gap: 16px; padding: 16px; }
  .admin-library-top { align-items: stretch; flex-direction: column; }
  .admin-library form { flex-wrap: wrap; }
  .admin-library .edit-library { grid-template-columns: 1fr; }
  .edit-library textarea { grid-column: auto; }
  .edit-library button { width: 100%; }
  .batch-games { grid-template-columns: 1fr; }
  .batch-games button { width: 100%; }
  .admin-game-tools { align-items: stretch; flex-direction: column; }
  .admin-game-filter { width: 100%; }
  .admin-game { grid-template-columns: 1fr auto auto; }
  .admin-game .field { grid-column: 1 / -1; }
}
