<!doctype html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="light">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src https://static.tildacdn.com; connect-src 'none'; form-action 'none'; base-uri 'none'; object-src 'none'">
<title>Командный старт · Anfigrafic</title>
<style>
:root {
--paper: #f8f3eb; --ink: #103d2a; --green: #145838; --lime: #d3ed43;
--muted: #526451; --line: #e4dace; --card: #fffcf7;
--shadow: 0 5px 8px #67472b12, 0 13px 24px #67472b08;
font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
color: var(--ink); background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; background: radial-gradient(ellipse at 75% 0, #fffaf4, transparent 52%), var(--paper); }
button, input, select { font: inherit; }
button, input, select { min-height: 48px; border: 1px solid #d7cbbd; border-radius: 14px; padding: 11px 16px; }
button { cursor: pointer; background: var(--card); color: var(--ink); font-weight: 650; }
button:hover { border-color: var(--green); }
.primary { background: linear-gradient(#216d49, #10492f); color: white; border: 1px solid #125238; box-shadow: inset 0 2px 2px #ffffff26, 0 3px 5px #183b2720; }
.primary:hover { background: #165b3a; }
:focus-visible { outline: 3px solid #b45b20; outline-offset: 4px; }
h2[tabindex="-1"]:focus { outline: none; }
input, select { width: 100%; min-width: 0; background: white; color: var(--ink); }
input[aria-invalid="true"] { border-color: #a73e29; }
.site-header, .shell { max-width: 1240px; margin-inline: auto; padding-inline: 28px; }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 24px 6px; }
.brand { font-weight: 850; font-size: clamp(19px, 3vw, 28px); letter-spacing: -1px; }
.badge { background: var(--lime); border-radius: 24px; font-size: 13px; font-weight: 800; padding: 7px 16px; white-space: nowrap; }
.shell { padding-bottom: 30px; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { font-size: clamp(36px, 5.4vw, 68px); line-height: 1.02; letter-spacing: -.055em; margin: 18px 0; max-width: 7.5em; }
h2 { font-size: clamp(23px, 2.5vw, 30px); line-height: 1.18; letter-spacing: -.025em; margin: 0 0 20px; }
h3 { font-size: 20px; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 8px; }
p { margin: 10px 0; }
.hero { position: relative; display: grid; align-items: center; grid-template-columns: .8fr 1.2fr; min-height: 320px; gap: 0; padding-top: 14px; }
.hero-copy { z-index: 1; padding-block: 22px; }
.hero-team { font-size: clamp(20px, 2.5vw, 28px); font-weight: 650; line-height: 1.2; margin-top: 20px; }
.hero-note { color: var(--muted); font-size: 14px; max-width: 26em; }
.hero-art { width: 100%; height: auto; display: block; }
.hero-compact { min-height: 0; grid-template-columns: 1fr auto; padding-bottom: 12px; }
.hero-compact h1 { font-size: clamp(32px, 4vw, 48px); max-width: none; }
.team-symbol { font-size: 100px; padding-inline: 24px; }
.tag { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.rolebar { display: flex; flex-wrap: wrap; gap: 6px; border-block: 1px solid var(--line); padding-block: 12px; margin: 6px 0 24px; }
.rolebar button { flex: 1 1 auto; min-width: 0; font-size: 14px; border-radius: 28px; border-color: transparent; background: transparent; box-shadow: none; }
.rolebar button[aria-pressed="true"] { background: var(--green); color: white; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-radius: 22px; background: #fffcf7; border: 1px solid white; box-shadow: var(--shadow); padding: 18px 6px; margin-bottom: 32px; }
.stat { padding-inline: 20px; border-right: 1px solid var(--line); font-weight: 650; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 7px; }
.stat:last-child { border-right: 0; }
.stat strong { font-size: 25px; }
.stat-icon { color: #7e9826; font-size: 29px; margin-right: 7px; line-height: 1; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 30px; align-items: start; }
.layout > *, .team-content, aside { min-width: 0; }
.section-row { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.section-row h2 { margin-bottom: 0; }
.team-picker { font-size: 12px; font-weight: 500; color: var(--muted); max-width: 260px; }
.team-picker select { margin-top: 5px; padding: 6px 12px; min-height: 40px; }
.members { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.member { min-width: 0; text-align: center; padding-top: 10px; border: 1px solid white; border-radius: 22px; background: linear-gradient(#fffaf3, #efe5d7); box-shadow: var(--shadow); overflow: hidden; }
.avatar { display: block; width: min(100%, 160px); height: auto; margin-inline: auto; }
.member-caption { background: #fcf7ef; padding: 12px 7px; min-height: 75px; display: grid; align-content: center; font-size: 14px; line-height: 1.2; gap: 5px; }
.member-symbol { display: grid; place-items: center; height: 116px; font-size: 60px; }
.route-section, .awards { margin-top: 34px; }
.route-section > .small { margin-top: -10px; margin-bottom: 18px; }
.station-list { display: grid; gap: 15px; }
.station { background: var(--card); border: 1px solid white; border-radius: 24px; padding: 16px 18px; display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; align-items: center; gap: 18px; box-shadow: var(--shadow); }
.station-art { width: 96px; height: 96px; object-fit: contain; }
.station-body { min-width: 0; border-left: 2px solid var(--line); padding-left: 20px; }
.station-body p { margin: 0 0 8px; }
.open-station { border-radius: 18px; min-width: 112px; padding-inline: 17px; }
.open-station span { margin-left: 14px; font-size: 25px; line-height: 0; }
.station-status { font-size: 12px; color: var(--muted); }
.station-status.complete { background: #e3edc4; color: #255032; border-radius: 18px; padding: 4px 10px; display: inline-block; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 24px; margin-bottom: 20px; }
.rating-card h2 { font-size: 23px; }
.rankrow { display: grid; grid-template-columns: 25px minmax(0, 1fr) auto; gap: 8px; align-items: center; border-top: 1px solid var(--line); padding: 16px 0; font-size: 14px; }
.rank-number { color: var(--muted); }
.active-team { font-weight: 750; }
.help-card { padding: 8px 12px; }
.help-card p { font-size: 14px; color: var(--muted); }
.small, .note { color: var(--muted); font-size: 13px; }
.note { margin-top: 18px; }
.medals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.medal { text-align: center; min-width: 0; margin: 0; }
.medal-image { display: block; width: min(100%, 160px); height: auto; margin: 0 auto 12px; }
/* Медали заменяются сразу: без переходов, фильтров и совмещения контуров. */
.medal figcaption { display: grid; gap: 6px; font-size: 14px; line-height: 1.3; }
.award-status { display: block; color: var(--muted); font-size: 12px; }
.earned .award-status { color: var(--green); font-weight: 700; }
.back { margin-bottom: 16px; }
.detail-art { width: 160px; height: 160px; object-fit: contain; float: right; margin: 0 0 12px 20px; }
.station-detail { display: flow-root; }
.station-detail .tag { display: block; margin-block: 4px 14px; }
.instruction { background: #eff1e1; border-radius: 14px; padding: 18px; margin-block: 18px; }
.staff-layout h2, .organizer-card h2 { margin-top: 12px; }
label { display: grid; gap: 7px; font-weight: 600; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-block: 24px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.message { min-height: 24px; color: var(--green); font-weight: 650; }
.scroll { overflow-x: auto; margin-top: 20px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; min-width: 560px; }
th, td { text-align: left; padding: 14px 10px; border-bottom: 1px solid var(--line); }
.footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 36px; border-top: 1px solid var(--line); padding-top: 22px; }
.footer p { color: var(--muted); font-size: 12px; max-width: 760px; }
.footer button { flex-shrink: 0; }
dialog { width: calc(100% - 32px); max-width: 440px; background: var(--card); color: var(--ink); border: 1px solid var(--line); padding: 26px; border-radius: 22px; box-shadow: var(--shadow); }
dialog::backdrop { background: #16372699; }
@media (max-width: 1000px) {
.layout { grid-template-columns: minmax(0, 1fr); }
aside { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.station { grid-template-columns: 112px minmax(0, 1fr) auto; }
.station-art { width: 112px; height: 112px; }
.hero { grid-template-columns: .8fr 1.2fr; min-height: 260px; }
.hero-compact { grid-template-columns: 1fr auto; min-height: 0; }
}
@media (max-width: 600px) {
.site-header, .shell { padding-inline: 16px; }.site-header { padding-top: 18px; }
.hero { grid-template-columns: 1fr; padding-top: 10px; }.hero-copy { padding-block: 12px 0; }
.hero h1 { max-width: none; font-size: 44px; }.hero-team { margin-top: 12px; }
.hero-art { max-width: 520px; margin-inline: auto; }.hero-note { margin-bottom: 0; }
.hero-compact { grid-template-columns: 1fr auto; min-height: 0; }.hero-compact h1 { font-size: 32px; }
.team-symbol { font-size: 56px; padding-inline: 8px; }
.tag { font-size: 10px; }.rolebar { margin-top: 14px; gap: 4px; }.rolebar button { font-size: 12px; padding: 9px 10px; }
.stats { padding: 14px 0; margin-bottom: 28px; }.stat { padding-inline: 8px; font-size: 11px; gap: 4px; }.stat strong { font-size: 21px; }.stat-icon { width: 100%; text-align: center; font-size: 23px; margin: 0 0 4px; }
.section-row { display: grid; }.team-picker { max-width: none; }
.members { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }.avatar { max-width: 140px; }.member-caption { min-height: 62px; }
.station { grid-template-columns: 72px minmax(0, 1fr); gap: 10px; padding: 16px; border-radius: 20px; }
.station-art { width: 72px; height: 86px; }.station-body { padding-left: 12px; }.station h3 { font-size: 19px; }
.open-station { grid-column: 2; width: 100%; min-width: 0; margin-top: 2px; }
.medals { gap: 8px; }.medal-image { max-width: 110px; }.medal figcaption { font-size: 12px; }.award-status { font-size: 11px; }
aside { grid-template-columns: 1fr; gap: 0; }.card { padding: 20px; }.detail-art { width: 108px; height: 108px; margin-left: 12px; }
.fields { grid-template-columns: 1fr; }.actions > button { width: 100%; }
.footer { align-items: flex-start; flex-direction: column; gap: 12px; }
}
</style>
</head>
<body>
<header class="site-header"><div class="brand" id="brand"></div><span class="badge" id="demoBadge"></span></header>
<main class="shell">
<section class="hero" id="hero" aria-labelledby="page-title"></section>
<nav class="rolebar" aria-label="Роль в демонстрации"><button id="role-team" data-role="team" type="button"></button><button id="role-staff" data-role="staff" type="button"></button><button id="role-organizer" data-role="organizer" type="button"></button></nav>
<div id="app"></div>
<footer class="footer"><p id="footerNote"></p><button id="reset" type="button"></button></footer>
</main>
<dialog id="resetDialog" aria-labelledby="resetTitle" aria-describedby="resetDescription"><h2 id="resetTitle"></h2><p id="resetDescription"></p><div class="actions"><button id="cancelReset" type="button" autofocus></button><button id="confirmReset" type="button" class="primary"></button></div></dialog>
<script>
'use strict';
// НАСТРОЙКИ ДЕМО. Тексты, команды, задания и пути к картинкам меняются здесь.
// CONFIG.teams — команды и составы; CONFIG.stations — существующие задания;
// CONFIG.initial — исходные баллы; CONFIG.ui — подписи; CONFIG.art — локальная графика.
const CONFIG = {
"teams": [
{
"id": "otter",
"name": "Выдры",
"icon": "🦦",
"members": [
"Весёлая выдра",
"Смелая выдра",
"Ловкая выдра",
"Быстрая выдра"
]
},
{
"id": "raccoon",
"name": "Еноты",
"icon": "🦝",
"members": [
"Весёлый енот",
"Смелый енот",
"Ловкий енот",
"Быстрый енот"
]
},
{
"id": "panda",
"name": "Панды",
"icon": "🐼",
"members": [
"Весёлая панда",
"Смелая панда",
"Ловкая панда",
"Быстрая панда"
]
}
],
"stations": [
{
"id": "target",
"name": "Точно в цель",
"kind": "Спортивное задание",
"place": "Зона А · площадка у старта",
"max": 10,
"text": "Команда выполняет 10 бросков мягкими мячами в мишень. Порядок участников определяет команда.",
"criteria": "Одно попадание — один балл. Итог вводит сотрудник станции."
},
{
"id": "route",
"name": "Собери маршрут",
"kind": "Логическая задача",
"place": "Зона Б · стол с карточками",
"max": 10,
"text": "Соберите маршрут из пяти карточек: старт, мост, парк, площадь, финиш. Мост расположен сразу после старта, парк — перед площадью.",
"criteria": "За каждую карточку на правильном месте — два балла. Пример решения: старт → мост → парк → площадь → финиш."
},
{
"id": "build",
"name": "Общая конструкция",
"kind": "Командное задание",
"place": "Зона В · творческая мастерская",
"max": 10,
"text": "За пять минут постройте из выданных деталей башню, которая простоит самостоятельно 10 секунд.",
"criteria": "Устойчивость — до 4 баллов, выполнение условий — до 4, участие всех членов команды — до 2. Подробные критерии сотрудник объясняет до старта."
}
],
"initial": {
"otter": {
"target": null,
"route": null,
"build": null
},
"raccoon": {
"target": 7,
"route": 6,
"build": null
},
"panda": {
"target": 5,
"route": null,
"build": null
}
}
};
CONFIG.ui = {
brand: 'anfigrafic / play', demoBadge: 'Демо · 0.1', pageTitle: 'Командный старт',
eyebrow: 'Корпоративные события / игровой маршрут',
heroIntro: 'Три станции. Одна команда. Общий результат.',
roleNav: 'Роль в демонстрации', roleTeam: '01 · Команда', roleStaff: '02 · Сотрудник станции', roleOrganizer: '03 · Организатор',
teamTitle: 'Команда «{team}»', teamView: 'Кабинет команды', teamSelect: 'Посмотреть другую демокоманду',
members: 'Паспорт команды', captain: 'Капитан', points: 'баллов', stations: 'станций', place: 'место',
route: 'Ваш маршрут', routeNote: 'Демо со свободным порядком станций',
notDone: 'Не пройдена', done: 'Пройдено · {score} / {max}', open: 'Открыть', back: '← Все станции',
result: 'Результат', waiting: 'ожидается', scoreOf: '{score} из {max}', tryStaff: 'Попробовать роль сотрудника',
stationNote: 'На мероприятии эту карточку открывает QR-код станции. Здесь используется кнопка перехода.',
awards: 'Награды команды', awardWaiting: 'Ещё не получена', awardEarned: 'Получена · {score} / {max}',
awardsNote: 'Медаль становится цветной после записи результата станции, включая ноль баллов.',
rating: 'Командный рейтинг', shortPoints: '{score} б.', ratingNote: 'Сумма баллов всех станций. При равенстве команды делят место.',
howTitle: 'Как попробовать', howNote: 'Откройте станцию, перейдите в роль сотрудника и внесите баллы. Вернитесь сюда, чтобы увидеть результат.',
staffView: 'Пульт сотрудника · демонстрация', staffTitle: 'Результат станции', stationLabel: 'Станция', teamLabel: 'Команда',
membersLabel: 'Состав', currentResult: 'Текущий результат', notEntered: 'ещё не внесён', currentPoints: '{score} баллов',
pointsLabel: 'Баллы · от 0 до {max}', pointsPlaceholder: 'Введите баллы',
confirmNote: 'Подтверждая, вы записываете результат команды «{team}» на станции «{station}». Повторная запись заменит предыдущие баллы.',
confirm: 'Подтвердить результат', returnTeam: 'Посмотреть как команда', emptyPoints: 'Введите баллы.', integerError: 'Введите целое число от 0 до {max}.',
saved: 'Готово: {station} · {team} · {score} баллов. Рейтинг обновлён в этой вкладке.',
demoOnly: 'Только демонстрация', staffNote: 'Баллы не отправляются на сервер. В рабочей версии сотрудник получит доступ только к назначенным станциям.',
organizerView: 'Обзор организатора · демонстрация', organizerTitle: 'Общая картина',
organizerIntro: 'Результаты всех команд по станциям. Прочерк означает, что результат ещё не внесён.',
total: 'Итого', placeColumn: 'Место', tableLabel: 'Результаты команд по станциям',
organizerNote: 'Настройки мероприятия, управление доступом и выгрузка появятся на следующих этапах. Этот прототип показывает прохождение и начисление баллов.',
enterResult: 'Внести результат', reset: 'Сбросить демо', resetTitle: 'Начать заново?', cancel: 'Отмена', resetConfirm: 'Сбросить',
resetDescription: 'Введённые баллы будут заменены исходными демонстрационными результатами.',
footerNote: 'Все команды и участники вымышлены. Изменения только в этой вкладке. После перезагрузки результаты сбрасываются. Роли в демо переключаются свободно.',
heroAlt: 'Четыре выдры в лесной диораме с мишенью и игровыми блоками'
};
CONFIG.art = {
hero: 'https://static.tildacdn.com/tila3163-3935-4039-b262-626466316362/team-start-hero.png',
// Портреты каждой команды идут в том же порядке, что и её участники.
avatars: {
otter: [
'https://static.tildacdn.com/tila6131-3864-4137-b264-616638643539/otter-glasses.png',
'https://static.tildacdn.com/tila3334-3732-4535-a562-663065643330/otter-wave.png',
'https://static.tildacdn.com/tila3161-3838-4464-a263-333264666439/otter-relaxed.png',
'https://static.tildacdn.com/tila6337-6136-4736-b434-386564353230/otter-cap.png'
],
raccoon: [
'https://static.tildacdn.com/tila6634-6163-4361-a531-646435313833/raccoon-glasses.png',
'https://static.tildacdn.com/tila3338-6534-4436-a337-643161356134/raccoon-wave.png',
'https://static.tildacdn.com/tila6332-6531-4130-b937-653935643234/raccoon-relaxed.png',
'https://static.tildacdn.com/tila3661-6233-4731-b063-373564383635/raccoon-cap.png'
],
panda: [
'https://static.tildacdn.com/tila6137-3233-4064-b935-376137373864/panda-glasses.png',
'https://static.tildacdn.com/tila3463-6563-4830-b037-613734646163/panda-wave.png',
'https://static.tildacdn.com/tila3561-6336-4461-b933-303838636434/panda-relaxed.png',
'https://static.tildacdn.com/tila3732-6463-4466-a138-613734616466/panda-cap.png'
]
},
stations: {
target: { image: 'https://static.tildacdn.com/tila6339-3064-4862-b431-373939373963/target-station.png', color: 'https://static.tildacdn.com/tila3164-6562-4839-b261-313230386237/target-medal-color.png', mono: 'https://static.tildacdn.com/tila6164-3333-4464-a533-643939666665/target-medal-mono.png' },
route: { image: 'https://static.tildacdn.com/tila6138-3830-4337-a532-323062666139/route-station.png', color: 'https://static.tildacdn.com/tila3462-6235-4430-b265-636434613462/route-medal-color.png', mono: 'https://static.tildacdn.com/tila3732-3033-4130-b738-333963623464/route-medal-mono.png' },
build: { image: 'https://static.tildacdn.com/tila3636-6330-4566-b933-666533646531/build-station.png', color: 'https://static.tildacdn.com/tila3430-3862-4439-a633-323065323037/build-medal-color.png', mono: 'https://static.tildacdn.com/tila3730-3534-4361-a434-356535306234/build-medal-mono.png' }
}
};
// КОНЕЦ НАСТРОЕК. Модель баллов сохранена; сообщение проверки берётся из CONFIG.ui.
function createModel(config){let scores=JSON.parse(JSON.stringify(config.initial));return {get scores(){return scores},set(team,station,value){const s=config.stations.find(x=>x.id===station);if(!config.teams.some(x=>x.id===team)||!s||!Number.isInteger(value)||value<0||value>s.max)throw Error(config.ui.integerError.replace('{max}',s?s.max:10));scores[team][station]=value},reset(){scores=JSON.parse(JSON.stringify(config.initial))},total(id){return Object.values(scores[id]).reduce((a,b)=>a+(b??0),0)},done(id){return Object.values(scores[id]).filter(x=>x!==null).length},ranking(){const rows=config.teams.map(t=>({...t,total:this.total(t.id)})).sort((a,b)=>b.total-a.total);return rows.map((x,i)=>({...x,rank:rows.findIndex(y=>y.total===x.total)+1}))}}}
const model = createModel(CONFIG);
let role = 'team', team = 'otter', station = null, staffTeam = 'otter', staffStation = 'target';
const app = document.querySelector('#app');
function escapeHTML(s) { return String(s).replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); }
function text(key, values = {}) { return CONFIG.ui[key].replace(/\{(\w+)\}/g, (_, name) => String(values[name] ?? '')); }
function label(key, values) { return escapeHTML(text(key, values)); }
function picture(src, alt, className, size) {
return `<img src="${escapeHTML(src)}" alt="${escapeHTML(alt)}" class="${className}" width="${size}" height="${size}" decoding="async">`;
}
function teamTitle(t) { return text('teamTitle', {team: t.name}); }
function options(items, selected) { return items.map(x => `<option value="${escapeHTML(x.id)}" ${x.id === selected ? 'selected' : ''}>${escapeHTML(x.name)}</option>`).join(''); }
function ranking() {
const activeTeam = role === 'staff' ? staffTeam : team;
return `<h2>${label('rating')}</h2>` + model.ranking().map(t => `<div class="rankrow ${t.id === activeTeam ? 'active-team' : ''}"><span class="rank-number">${t.rank}</span><span>${t.icon} ${escapeHTML(t.name)}</span><strong>${label('shortPoints', {score: t.total})}</strong></div>`).join('') + `<p class="note">${label('ratingNote')}</p>`;
}
function awardState(teamId, stationId) {
const score = model.scores[teamId][stationId];
const earned = score !== null;
return {earned, score, src: CONFIG.art.stations[stationId][earned ? 'color' : 'mono']};
}
function awards() {
return `<section class="awards" aria-labelledby="awards-title"><h2 id="awards-title">${label('awards')}</h2><div class="medals">${CONFIG.stations.map(s => {
const a = awardState(team, s.id);
const status = text(a.earned ? 'awardEarned' : 'awardWaiting', {score: a.score, max: s.max});
return `<figure class="medal ${a.earned ? 'earned' : ''}" data-award="${s.id}">${picture(a.src, s.name + ' — ' + status, 'medal-image', 144)}<figcaption><strong>${escapeHTML(s.name)}</strong><span class="award-status">${escapeHTML(status)}</span></figcaption></figure>`;
}).join('')}</div><p class="note">${label('awardsNote')}</p></section>`;
}
function renderHero() {
const t = CONFIG.teams.find(x => x.id === team);
const withOtters = role === 'team' && t.id === 'otter';
document.querySelector('#hero').className = `hero ${withOtters ? 'hero-otters' : 'hero-compact'}`;
document.querySelector('#hero').innerHTML = `<div class="hero-copy"><span class="tag">${label('eyebrow')}</span><h1 id="page-title">${label('pageTitle')}</h1><p class="hero-team">${role === 'team' ? escapeHTML(teamTitle(t)) : label(role === 'staff' ? 'staffView' : 'organizerView')}</p><p class="hero-note">${label('heroIntro')}</p></div>${withOtters ? `<img class="hero-art" src="${escapeHTML(CONFIG.art.hero)}" width="938" height="640" alt="${label('heroAlt')}" fetchpriority="high">` : role === 'team' ? `<span class="team-symbol" aria-hidden="true">${t.icon}</span>` : ''}`;
}
function focusElement(id) {
const target = document.getElementById(id) || document.getElementById('screen-title');
if (target) target.focus();
}
function render(focusId) {
// Старый DOM заменяется: явно возвращаем фокус к новому элементу.
document.querySelectorAll('[data-role]').forEach(b => b.setAttribute('aria-pressed', String(b.dataset.role === role)));
renderHero();
if (role === 'team') renderTeam(); else if (role === 'staff') renderStaff(); else renderOrganizer();
if (focusId) focusElement(focusId);
}
function renderTeam() {
const t = CONFIG.teams.find(x => x.id === team), s = CONFIG.stations.find(x => x.id === station);
const avatars = CONFIG.art.avatars[t.id] ?? [];
app.innerHTML = `<div class="stats" aria-label="${escapeHTML(teamTitle(t))}"><div class="stat"><span class="stat-icon" aria-hidden="true">★</span><strong>${model.total(team)}</strong> ${label('points')}</div><div class="stat"><span class="stat-icon" aria-hidden="true">⚑</span><strong>${model.done(team)} / ${CONFIG.stations.length}</strong> ${label('stations')}</div><div class="stat"><span class="stat-icon" aria-hidden="true">♜</span><strong>${model.ranking().find(x => x.id === team).rank}</strong> ${label('place')}</div></div>
<div class="layout"><div class="team-content">
<section class="team-passport"><div class="section-row"><h2 id="screen-title" tabindex="-1">${label('members')}</h2><label class="team-picker">${label('teamSelect')}<select id="teamSelect">${options(CONFIG.teams, team)}</select></label></div><div class="members">${t.members.map((m, i) => `<div class="member">${avatars[i] ? picture(avatars[i], m, 'avatar', 160) : `<span class="member-symbol" aria-hidden="true">${t.icon}</span>`}<div class="member-caption"><strong>${escapeHTML(m)}</strong>${i === 0 ? `<span class="small">${label('captain')}</span>` : ''}</div></div>`).join('')}</div></section>
<section class="route-section">${s ? `<button class="back" id="back" type="button">${label('back')}</button><div class="card station-detail">${picture(CONFIG.art.stations[s.id].image, s.name, 'detail-art', 192)}<span class="tag">${escapeHTML(s.kind)}</span><h2 id="station-title" tabindex="-1">${escapeHTML(s.name)}</h2><p class="small">${escapeHTML(s.place)}</p><p>${escapeHTML(s.text)}</p><div class="instruction">${escapeHTML(s.criteria)}</div><p>${label('result')}: <strong>${model.scores[team][s.id] === null ? label('waiting') : label('scoreOf', {score: model.scores[team][s.id], max: s.max})}</strong></p><button class="primary" id="tryStaff" type="button">${label('tryStaff')}</button><p class="note">${label('stationNote')}</p></div>` : `<h2 id="route-title" tabindex="-1">${label('route')}</h2><p class="small">${label('routeNote')}</p><div class="station-list">${CONFIG.stations.map(x => {
const score = model.scores[team][x.id];
return `<article class="station">${picture(CONFIG.art.stations[x.id].image, x.name, 'station-art', 112)}<div class="station-body"><h3>${escapeHTML(x.name)}</h3><p class="small">${escapeHTML(x.kind)}</p><span class="station-status ${score === null ? '' : 'complete'}">${score === null ? label('notDone') : label('done', {score, max: x.max})}</span></div><button class="primary open-station" type="button" data-station="${x.id}" aria-label="${label('open')} · ${escapeHTML(x.name)}">${label('open')} <span aria-hidden="true">›</span></button></article>`;
}).join('')}</div>`}</section>${awards()}</div>
<aside><section class="card rating-card">${ranking()}</section><section class="help-card"><span class="tag">${label('howTitle')}</span><p>${label('howNote')}</p></section></aside></div>`;
document.querySelector('#teamSelect').onchange = e => { team = e.target.value; render('teamSelect'); };
document.querySelectorAll('[data-station]').forEach(b => b.onclick = () => { station = b.dataset.station; render('station-title'); });
if (s) {
document.querySelector('#back').onclick = () => { station = null; render('route-title'); };
document.querySelector('#tryStaff').onclick = () => { staffTeam = team; staffStation = station; role = 'staff'; render('points'); };
}
}
function renderStaff() {
const s = CONFIG.stations.find(x => x.id === staffStation), t = CONFIG.teams.find(x => x.id === staffTeam), old = model.scores[staffTeam][staffStation];
app.innerHTML = `<div class="layout staff-layout"><section class="card"><span class="tag">${label('staffView')}</span><h2 id="screen-title" tabindex="-1">${label('staffTitle')}</h2><form id="scoreForm"><div class="fields"><label>${label('stationLabel')}<select id="staffStation">${options(CONFIG.stations, staffStation)}</select></label><label>${label('teamLabel')}<select id="staffTeam">${options(CONFIG.teams, staffTeam)}</select></label></div><p class="small">${label('membersLabel')}: ${t.members.map(escapeHTML).join(', ')}</p><div class="instruction">${escapeHTML(s.criteria)}</div><p>${label('currentResult')}: <strong>${old === null ? label('notEntered') : label('currentPoints', {score: old})}</strong></p><label>${label('pointsLabel', {max: s.max})}<input id="points" type="number" min="0" max="${s.max}" step="1" required inputmode="numeric" value="${old ?? ''}" placeholder="${label('pointsPlaceholder')}" aria-describedby="scoreNote message"></label><p class="note" id="scoreNote">${label('confirmNote', {team: t.name, station: s.name})}</p><div class="actions"><button class="primary" type="submit">${label('confirm')}</button><button type="button" id="returnTeam">${label('returnTeam')}</button></div><p class="message" id="message" role="status" aria-live="polite" aria-atomic="true"></p></form></section><aside><section class="card">${ranking()}</section><section class="help-card"><h3>${label('demoOnly')}</h3><p class="small">${label('staffNote')}</p></section></aside></div>`;
document.querySelector('#staffStation').onchange = e => { staffStation = e.target.value; render('staffStation'); };
document.querySelector('#staffTeam').onchange = e => { staffTeam = e.target.value; render('staffTeam'); };
document.querySelector('#returnTeam').onclick = () => { team = staffTeam; station = staffStation; role = 'team'; render('station-title'); };
document.querySelector('#scoreForm').onsubmit = e => {
e.preventDefault();
const raw = document.querySelector('#points').value;
try {
if (!raw.trim()) throw Error(text('emptyPoints'));
model.set(staffTeam, staffStation, Number(raw));
render('points');
document.querySelector('#message').textContent = text('saved', {station: s.name, team: t.name, score: Number(raw)});
} catch (err) {
document.querySelector('#message').textContent = err.message;
document.querySelector('#points').setAttribute('aria-invalid', 'true');
focusElement('points');
}
};
}
function renderOrganizer() {
app.innerHTML = `<section class="card organizer-card"><span class="tag">${label('organizerView')}</span><h2 id="screen-title" tabindex="-1">${label('organizerTitle')}</h2><p>${label('organizerIntro')}</p><div class="scroll" tabindex="0" role="region" aria-label="${label('tableLabel')}"><table><thead><tr><th scope="col">${label('teamLabel')}</th>${CONFIG.stations.map(s => `<th scope="col">${escapeHTML(s.name)}</th>`).join('')}<th scope="col">${label('total')}</th><th scope="col">${label('placeColumn')}</th></tr></thead><tbody>${model.ranking().map(t => `<tr><th scope="row">${t.icon} ${escapeHTML(t.name)}</th>${CONFIG.stations.map(s => `<td>${model.scores[t.id][s.id] ?? '—'}</td>`).join('')}<td><strong>${t.total}</strong></td><td>${t.rank}</td></tr>`).join('')}</tbody></table></div><p class="note">${label('organizerNote')}</p><button class="primary" id="goStaff" type="button">${label('enterResult')}</button></section>`;
document.querySelector('#goStaff').onclick = () => { role = 'staff'; render('points'); };
}
const staticText = {brand:'brand', demoBadge:'demoBadge', 'role-team':'roleTeam', 'role-staff':'roleStaff', 'role-organizer':'roleOrganizer', footerNote:'footerNote', reset:'reset', resetTitle:'resetTitle', resetDescription:'resetDescription', cancelReset:'cancel', confirmReset:'resetConfirm'};
for (const [id, key] of Object.entries(staticText)) document.getElementById(id).textContent = text(key);
document.querySelector('.rolebar').setAttribute('aria-label', text('roleNav'));
document.title = text('pageTitle') + ' · Anfigrafic';
document.querySelectorAll('[data-role]').forEach(b => b.onclick = () => { role = b.dataset.role; render('screen-title'); });
const resetDialog = document.querySelector('#resetDialog');
document.querySelector('#reset').onclick = () => resetDialog.showModal();
document.querySelector('#cancelReset').onclick = () => { resetDialog.close(); focusElement('reset'); };
document.querySelector('#confirmReset').onclick = () => {
model.reset(); role = 'team'; team = 'otter'; station = null; staffTeam = 'otter'; staffStation = 'target';
resetDialog.close(); render('teamSelect');
};
render();
</script>
<script>
const reportGameHeight = () => {
parent.postMessage({
type: 'anfigrafic-team-start-height',
height: Math.ceil(document.body.getBoundingClientRect().height)
}, '*');
};
new ResizeObserver(reportGameHeight).observe(document.body);
window.addEventListener('load', reportGameHeight);
</script>
</body>
</html>