/* Студия Мастерсам: общий стиль (оранжевый Мастерсам + графит, как в мастер-классах) */
:root {
  --paper: #FFF9F1; --cream: #FFF0D9; --cream2: #FFF6EB; --sand: #F2D4AA;
  --orange: #FF8A00; --orange2: #FF6A00; --deep: #D95700;
  --graphite: #2B2D31; --graphite2: #3A3D43; --graphite3: #50545C; --ash: #C9CCD1;
  --ink: #202020; --muted: #605E59; --line: #E5DFD5; --white: #FFFFFF;
  --green: #2FA84F; --green-dark: #1F7A37; --red: #E5484D; --red-dark: #B42318; --gold: #FFD23F;
  --grad: linear-gradient(135deg, var(--orange), var(--orange2));
  --grad-btn: linear-gradient(135deg, #FF7A00, var(--deep));
  --shadow: 0 22px 48px -12px rgba(43, 45, 49, .28);
  --shadow-sm: 0 8px 20px -10px rgba(43, 45, 49, .3);
  --focus: 0 0 0 4px var(--white), 0 0 0 7px #1F6FEB;
  --font: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --r: 22px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--paper); color: var(--ink); font-family: var(--font); font-weight: 500; font-size: 18px; line-height: 1.4; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
canvas { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- верхняя полоса ---------- */
.bar { min-height: 64px; display: flex; align-items: center; gap: 14px; padding: 8px 20px; background: var(--graphite); color: var(--white); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.bar a { text-decoration: none; }
.bar .home { width: 46px; height: 46px; border-radius: 14px; background: var(--graphite2); display: grid; place-items: center; font-size: 24px; flex: none; }
.bar .home:hover { background: var(--graphite3); }
.bar .logo { font-weight: 800; color: var(--orange); letter-spacing: .05em; font-size: 20px; }
.bar-title { font-weight: 800; font-size: 20px; padding-left: 14px; border-left: 2px solid var(--graphite3); }
.bar nav { display: flex; gap: 6px; margin-left: 8px; }
.bar nav a { padding: 10px 16px; border-radius: 14px; font-weight: 800; color: var(--ash); }
.bar nav a:hover { background: var(--graphite2); color: var(--white); }
.bar nav a[aria-current="page"] { background: var(--graphite2); color: var(--white); box-shadow: inset 0 -3px 0 var(--orange); }
.bar .me { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.me-chip { display: flex; align-items: center; gap: 10px; padding: 4px 16px 4px 4px; border-radius: 999px; background: var(--graphite2); }
.ava { width: 40px; height: 40px; border-radius: 50%; background: var(--grad); display: inline-grid; place-items: center; font-size: 24px; flex: none; line-height: 1; }
.me-name { font-weight: 800; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .btn { padding: 9px 16px; font-size: 17px; }
.bar .btn.ghost { color: var(--white); border-color: var(--graphite3); }
@media (max-width: 760px) {
  .bar .logo, .bar-title, .me-name { display: none; }
  .bar nav a { padding: 8px 10px; }
}

/* ---------- кнопки ---------- */
.btn { border: 0; border-radius: 16px; padding: 12px 20px; min-height: 48px; font-size: 19px; font-weight: 800; cursor: pointer; background: var(--cream); color: var(--ink); display: inline-flex; align-items: center; gap: 8px; justify-content: center; text-decoration: none; transition: transform .1s, filter .15s; line-height: 1.2; }
.btn:hover { filter: brightness(.96); }
.btn:active { transform: translateY(2px) scale(.98); }
.btn.main { background: var(--grad-btn); color: var(--white); box-shadow: 0 10px 24px -10px rgba(255, 106, 0, .8); text-shadow: 0 1px 1px rgba(0, 0, 0, .18); }
.btn.dark { background: var(--graphite); color: var(--white); }
.btn.ghost { background: transparent; border: 2px solid var(--line); }
.btn.danger { background: var(--red-dark); color: var(--white); }
.btn.big { font-size: 23px; padding: 16px 30px; border-radius: 20px; min-height: 60px; }
.btn.icon { width: 48px; padding: 0; font-size: 22px; flex: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; box-shadow: none; transform: none; }
.on-dark .btn:not(.main):not(.danger) { background: var(--graphite2); color: var(--white); }
.on-dark .btn.ghost { background: transparent; border-color: var(--graphite3); }

/* ---------- раскладка ---------- */
main.page { max-width: 1180px; margin: 0 auto; padding: 30px 20px 70px; }
.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 40px; font-weight: 800; margin: 0; line-height: 1.1; }
.page-head h1 em, h1 em { font-style: normal; color: var(--orange2); }
.page-head .grow { flex: 1; }
.lead { font-size: 20px; color: var(--muted); margin: 0 0 24px; }
.panel { background: var(--white); border-radius: 28px; padding: 28px; box-shadow: var(--shadow); }
.sec { font-size: 26px; font-weight: 800; margin: 32px 0 14px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sec small { font-size: 16px; color: var(--muted); font-weight: 600; }
.note { font-size: 16px; color: var(--muted); }
.chip { display: inline-flex; gap: 6px; align-items: center; background: var(--cream); border-radius: 999px; padding: 4px 12px; font-size: 16px; font-weight: 700; white-space: nowrap; }
.chip.ok { background: #DDF3E3; color: var(--green-dark); }
.chip.warn { background: #FFE7E7; color: var(--red-dark); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 21px; grid-column: 1 / -1; }
.empty .em { font-size: 90px; line-height: 1.1; }
.err { color: var(--red-dark); font-weight: 800; min-height: 1.4em; margin: 10px 0 0; }

/* ---------- поля ввода ---------- */
.field { display: block; margin: 0 0 18px; }
.field > span { display: block; font-weight: 800; font-size: 20px; margin-bottom: 8px; }
.input { width: 100%; font-size: 24px; font-weight: 700; padding: 14px 18px; border-radius: 16px; border: 2px solid var(--line); background: var(--cream2); outline: none; }
.input:focus { border-color: var(--orange); box-shadow: 0 0 0 4px rgba(255, 138, 0, .2); }
select.input { font-size: 19px; padding: 10px 14px; cursor: pointer; }

/* ---------- карточки игр ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.card { background: var(--white); border-radius: var(--r); padding: 10px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-sm); position: relative; transition: transform .15s, box-shadow .15s; min-width: 0; }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
a.card, .card a.shot { text-decoration: none; color: inherit; }
.card .shot { display: block; border-radius: 14px; overflow: hidden; background: var(--cream); text-decoration: none; }
.card canvas.preview { width: 100%; height: auto; aspect-ratio: 24 / 14; image-rendering: pixelated; }
.card .t { font-size: 21px; font-weight: 800; padding: 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .a { display: flex; align-items: center; gap: 8px; padding: 0 6px; color: var(--muted); font-weight: 700; min-width: 0; }
.card .a span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .a .ava { width: 30px; height: 30px; font-size: 18px; }
.card .s { display: flex; gap: 6px; padding: 0 4px; flex-wrap: wrap; }
.card .acts { display: flex; gap: 8px; padding: 2px 4px 4px; flex-wrap: wrap; }
.card .acts .btn { padding: 8px 14px; min-height: 44px; font-size: 17px; }
.card .acts .grow { flex: 1; }
.card .badge { position: absolute; left: 18px; top: 18px; background: var(--orange2); color: #fff; font-weight: 800; font-size: 14px; padding: 4px 10px; border-radius: 999px; }
.card .badge.star { background: var(--graphite); color: var(--gold); }
.card.new { animation: pop .5s ease-out; }
.card.add { align-items: center; justify-content: center; text-align: center; border: 3px dashed var(--sand); background: var(--cream2); box-shadow: none; min-height: 240px; cursor: pointer; font-weight: 800; font-size: 22px; color: var(--ink); }
.card.add .em { font-size: 60px; }

/* тёмные страницы: Аркада и игра */
body.on-dark { background: var(--graphite); color: var(--white); }
.on-dark .card { background: var(--graphite2); box-shadow: none; }
.on-dark .card:hover { background: var(--graphite3); }
.on-dark .card .a, .on-dark .sec small, .on-dark .note, .on-dark .empty { color: var(--ash); }
.on-dark .chip { background: rgba(255, 255, 255, .1); color: var(--white); }
.on-dark .card .shot { background: var(--graphite); }
/* окна на тёмных страницах остаются светлыми */
.on-dark dialog.win .btn:not(.main):not(.danger) { background: var(--cream); color: var(--ink); }
.on-dark dialog.win .btn.ghost { background: transparent; border-color: var(--line); }
.on-dark dialog.win .note { color: var(--muted); }

/* переключатели («Новые / Любимые / Сложные») */
.seg { display: inline-flex; gap: 4px; background: var(--cream); padding: 4px; border-radius: 16px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; font-weight: 800; font-size: 17px; padding: 9px 15px; border-radius: 12px; cursor: pointer; min-height: 44px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--grad-btn); color: #fff; }
.on-dark .seg { background: var(--graphite2); }
.on-dark .seg button { color: var(--ash); }
.on-dark .seg button[aria-pressed="true"] { color: #fff; }

/* ---------- окно поверх страницы ---------- */
dialog.win { border: 0; padding: 0; background: transparent; max-width: min(640px, calc(100vw - 24px)); width: 100%; color: var(--ink); }
dialog.win::backdrop { background: rgba(43, 45, 49, .6); }
dialog.win.wide { max-width: min(960px, calc(100vw - 24px)); }
.win .box { text-align: center; background: var(--white); border-radius: 32px; padding: 30px 34px; box-shadow: var(--shadow); animation: pop .3s ease-out; max-height: calc(100vh - 40px); overflow: auto; }
.win .icon { font-size: 80px; line-height: 1; }
.win h2 { font-size: 32px; margin: 10px 0 8px; font-weight: 800; line-height: 1.15; }
.win p { font-size: 19px; color: var(--muted); margin: 0 0 6px; }
.win .row { display: flex; gap: 12px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.04); } 100% { transform: scale(1); opacity: 1; } }

/* правила Аркады */
.rules { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 10px; text-align: left; }
.rules li { display: flex; gap: 14px; align-items: center; background: var(--cream2); border-radius: 18px; padding: 12px 16px; font-size: 19px; font-weight: 700; }
.rules li .em { font-size: 36px; line-height: 1; flex: none; width: 44px; text-align: center; }

/* ---------- всплывающие подсказки ---------- */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 50; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast { background: var(--graphite); color: var(--white); padding: 14px 22px; border-radius: 18px; font-weight: 800; font-size: 18px; box-shadow: var(--shadow); animation: toast-in .25s ease-out; }
.toast.ok { background: var(--green-dark); }
.toast.error { background: var(--red-dark); }
@keyframes toast-in { from { transform: translateY(20px); opacity: 0; } }

/* ---------- значки и картинки-пароль ---------- */
.avas { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.avas button { height: 70px; border-radius: 18px; border: 0; background: var(--cream); font-size: 40px; cursor: pointer; transition: transform .1s; }
.avas button:hover { transform: scale(1.06); }
.avas button[aria-pressed="true"] { background: var(--grad); box-shadow: 0 0 0 4px var(--sand); transform: scale(1.06); }
.pics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 460px; margin: 0 auto; }
.pics button { aspect-ratio: 1; border-radius: 24px; border: 3px solid var(--line); background: var(--white); font-size: clamp(48px, 9vw, 76px); cursor: pointer; box-shadow: var(--shadow-sm); transition: transform .1s, background .15s; line-height: 1; }
.pics button:hover { background: var(--cream2); transform: translateY(-2px); }
.pics button.hit { animation: hit .25s ease-out; background: var(--cream); }
@keyframes hit { 50% { transform: scale(.9); } }
.slots { display: flex; gap: min(14px, 3vw); justify-content: center; margin: 4px 0 18px; }
.slots span { width: min(76px, 16vw); height: min(76px, 16vw); border-radius: 20px; border: 3px dashed var(--sand); display: grid; place-items: center; font-size: min(44px, 10vw); background: var(--cream2); }
.slots span.full { border-style: solid; border-color: var(--orange); background: var(--white); animation: pop .25s ease-out; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

/* ---------- победа: немного конфетти ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti span { position: absolute; top: -60px; font-size: 34px; animation: fall 1.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: .6; } }

/* ---------- таблицы учителя ---------- */
.list { display: grid; gap: 10px; }
.row-item { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--white); border-radius: 18px; padding: 12px 16px; box-shadow: var(--shadow-sm); }
.row-item .grow { flex: 1; min-width: 120px; }
.row-item .name { font-weight: 800; font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .confetti { display: none; }
}
@media (max-width: 720px) {
  .page-head h1 { font-size: 32px; }
  .avas { grid-template-columns: repeat(4, 1fr); }
  .win .box { padding: 24px 18px; }
  .panel { padding: 20px 16px; }
  main.page { padding-left: 16px; padding-right: 16px; }
}
