/* Wygląd nawiązuje do grafik gry: papier, ciemny kontur, twarde cienie. */
:root {
  --ink: #2b1d1a;
  --paper: #fbeed7;
  --paper-2: #f3dfbd;
  --line: #d6b888;
  --muted: #7b6253;
  --orange: #ef8a3c;
  --orange-2: #f7b267;
  --red: #c9463b;
  --green: #5f8f45;
  --night: #1d1a22;
  --lift: 0 3px 0 var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper-2); color: var(--ink); font: 15px/1.45 "Trebuchet MS", "Segoe UI", system-ui, sans-serif; }
body.play { background: var(--night); }
h1, h2, h3 { margin: 0 0 10px; line-height: 1.2; }
h2 { font-size: 19px; }
h3 { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
p { margin: 0 0 10px; }
a { color: #9a4a1c; }
small { display: block; color: var(--muted); font-size: 12px; }
code { background: var(--paper-2); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; font-size: 13px; }
canvas, img { image-rendering: pixelated; }
.center { text-align: center; }
.label { margin: 0 0 6px; font-weight: 600; }

/* --- przyciski i pola --- */

button { padding: 8px 13px; border: 2px solid var(--ink); border-radius: 4px; background: var(--paper); color: var(--ink); font: 600 14px/1.2 inherit; font-family: inherit; cursor: pointer; box-shadow: var(--lift); }
button:hover { background: #fff7e8; }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
button:disabled { opacity: 0.45; cursor: default; transform: none; box-shadow: var(--lift); }
button.primary { background: var(--orange); }
button.primary:hover { background: var(--orange-2); }
button.danger { background: var(--red); color: #fff; }
button.quiet { border-color: var(--line); box-shadow: none; font-weight: 400; }
button.big { width: 100%; padding: 12px; font-size: 17px; }
button[aria-pressed="true"]:not(.quiet) { background: var(--orange); }
:focus-visible { outline: 3px solid #2f6fb5; outline-offset: 2px; }
kbd { display: inline-block; min-width: 20px; padding: 1px 5px; border-radius: 3px; background: var(--ink); color: var(--paper); font: 600 12px/1.4 inherit; font-family: inherit; text-align: center; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }

label { display: block; margin-bottom: 12px; font-weight: 600; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; border: 2px solid var(--ink); border-radius: 4px; background: #fffaf0; color: var(--ink); font: inherit; font-weight: 400; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #a08a78; }
.inline { display: inline-flex; gap: 6px; align-items: center; margin-right: 14px; font-weight: 400; }
.inline input { width: auto; margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 0 12px; }
.row label { flex: 1 1 160px; }

.card { background: var(--paper); border: 2px solid var(--ink); border-radius: 6px; box-shadow: 4px 4px 0 var(--ink); padding: 18px; margin-bottom: 20px; overflow-x: auto; }
body:not(.play) .card { box-shadow: 4px 4px 0 var(--line); }

/* --- ekran startowy --- */

/* Tło: nocne niebo z gwiazdami i wzgórzami; karta wejścia ma postać po lewej, a części po prawej. */
body.play:has(#lobby:not([hidden])) {
  min-height: 100dvh;
  background:
    radial-gradient(1px 1px at 12% 18%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 31% 9%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 54% 22%, #ffe9a8 50%, transparent 51%), radial-gradient(1px 1px at 73% 12%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 88% 27%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 6% 41%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 94% 49%, #ffe9a8 50%, transparent 51%),
    radial-gradient(60% 26% at 22% 100%, #2f5d3a 99%, transparent 100%), radial-gradient(70% 22% at 78% 100%, #3b7146 99%, transparent 100%),
    linear-gradient(#1d1a3a, #3a2d5c 55%, #5a4a78);
  background-attachment: fixed;
}
#lobby { max-width: 900px; margin: 0 auto; padding: 28px 16px; }
.logo { margin-bottom: 18px; color: var(--paper); font-size: 38px; letter-spacing: 0.04em; text-align: center; text-shadow: 3px 3px 0 var(--ink); }
.logo small { margin-top: 4px; color: var(--orange-2); font-size: 15px; font-weight: 400; letter-spacing: 0.02em; text-shadow: 2px 2px 0 var(--ink); }
#message { max-width: 540px; margin-inline: auto; }
#join { display: grid; grid-template-columns: 250px minmax(0, 1fr); grid-template-areas: "head head" "stand parts" "fields parts" "go parts"; grid-template-rows: auto auto auto 1fr; gap: 0 24px; padding: 22px; overflow: visible; }
#join #wardrobe, #join .creator { display: contents; }
#joinheading { grid-area: head; font-size: 24px; margin-bottom: 14px; }
#join .creator-stand { grid-area: stand; margin-bottom: 16px; }
#join .creator-parts { grid-area: parts; min-width: 0; }
#joinfields { grid-area: fields; }
#joinfields small { font-weight: 400; }
#joingo { grid-area: go; align-self: start; }
#join .creator-tab { min-height: 40px; padding: 7px 12px; font-size: 14px; }
#join .creator-panel { height: 400px; padding: 6px; border: 2px solid var(--line); border-radius: 6px; background: #fffaf0; }
#join .creator-options { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
#join .creator-option { min-height: 0; padding: 8px 2px 6px; gap: 4px; font-size: 12px; }
#join .creator-option canvas { width: 52px; }
#join .creator-color { width: 46px; height: 46px; border-radius: 50%; }
#join .creator-view:not(.main) { width: 40px; }
/* Szeroki ekran: kategorie w pionowej liście po lewej, opcje obok. */
@media (min-width: 721px) {
  #join .creator-parts { display: grid; grid-template-columns: 136px minmax(0, 1fr); grid-template-areas: "tabs panel" "note note"; gap: 0 10px; align-content: start; }
  #join .creator-tabs { grid-area: tabs; flex-direction: column; flex-wrap: nowrap; margin: 0; }
  #join .creator-tab { min-height: 36px; padding: 6px 10px; text-align: left; }
  #join .creator-panel { grid-area: panel; height: 440px; }
  #join .creator-note { grid-area: note; }
}
/* Postać stoi na trawie; rozmiar płótna wynika z proporcji klatki (wardrobe.js). */
#wardrobe canvas, #wardrobe2 canvas { height: auto; }
.creator-scene { display: grid; place-items: end center; width: 100%; aspect-ratio: 1; overflow: hidden; padding-bottom: 9%; border: 2px solid var(--ink); border-radius: 8px;
  background: radial-gradient(32% 7% at 50% 88%, rgb(0 0 0 / 0.28) 99%, transparent 100%), linear-gradient(#bfe6f5 0 58%, #9ed06f 58% 62%, #84bf5c 62%); }
/* Wysokość z góry, szerokość z proporcji klatki, żeby wysoka postać mieściła się w scenie. */
#wardrobe .creator-scene .creator-view.main, #wardrobe2 .creator-scene .creator-view.main { width: auto; height: 80%; border: 0; border-radius: 0; background: none; }
.creator-shuffle { width: 100%; }
@media (max-width: 720px) {
  #join { grid-template-columns: 1fr; grid-template-areas: "head" "fields" "stand" "parts" "go"; grid-template-rows: none; padding: 16px; }
  #join .creator-stand { flex-direction: column; }
  #join .creator-turns { flex-direction: row; gap: 6px; }
  .creator-scene { max-width: 220px; }
  #join .creator-panel { height: 300px; }
  #joingo { margin-top: 14px; }
}
#lobby .center a { color: var(--orange-2); }
/* Kreator postaci i katalog mebli mają style w art.css. */
#lookdialog { width: min(520px, 94vw); font-size: 15px; }

/* --- gra --- */

#game { display: grid; height: 100vh; height: 100dvh; grid-template: "stage side" 1fr "bar bar" auto / 1fr 280px; }
#stage { grid-area: stage; position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--night); }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#stage header { position: absolute; top: 10px; left: 10px; max-width: calc(100% - 20px); display: flex; flex-wrap: wrap; gap: 2px 14px; padding: 6px 12px; background: var(--paper); border: 2px solid var(--ink); border-radius: 4px; box-shadow: var(--lift); pointer-events: none; }
#stage header span:empty { display: none; }
#info, #staffnote { color: var(--muted); }
#hint { position: absolute; left: 50%; top: 58px; transform: translateX(-50%); width: max-content; max-width: 90%; margin: 0; padding: 8px 14px; background: var(--orange-2); border: 2px solid var(--ink); border-radius: 4px; box-shadow: var(--lift); font-weight: 600; }
#banner { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; padding: 24px; background: rgb(29 26 34 / 0.62); text-align: center; }
#bannertext { max-width: 560px; margin: 0; padding: 18px 22px; background: var(--paper); border: 2px solid var(--ink); border-radius: 6px; box-shadow: 4px 4px 0 var(--ink); font-size: 19px; }
#bannerkeys { margin: 0; color: var(--paper); font-size: 14px; }
#bannerkeys:empty { display: none; }

#quiz { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(560px, 94%); padding: 12px 14px; background: var(--paper); border: 2px solid var(--ink); border-radius: 6px; box-shadow: 4px 4px 0 var(--ink); text-align: center; z-index: 2; }
#quiztext { margin: 0 0 10px; font-size: 19px; font-weight: 600; }
#quizchoices { display: flex; flex-wrap: wrap; gap: 8px; }
#quizchoices button { flex: 1 1 120px; padding: 10px; font-size: 18px; }
@media (pointer: coarse) { #quiz { bottom: auto; top: 60px; } }

#flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(transparent 50%, rgb(201 70 59 / 0.6)); }
#flash.on { animation: hurt 0.45s ease-out; }
@keyframes hurt { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #flash.on { animation: none; } }

#pad { position: absolute; left: 12px; bottom: 12px; display: none; grid-template-columns: repeat(3, 56px); grid-auto-rows: 52px; gap: 4px; user-select: none; }
#pad button { touch-action: none; opacity: 0.88; }
#pad button:nth-child(1) { grid-column: 2; grid-row: 1; }
#pad button:nth-child(2) { grid-column: 1; grid-row: 2; }
#pad button:nth-child(3) { grid-column: 2; grid-row: 2; }
#pad button:nth-child(4) { grid-column: 3; grid-row: 2; }
@media (pointer: coarse) {
  #game:not(.teacher) #pad, #game.teacher.steering #pad { display: grid; }
}

#game aside { grid-area: side; min-height: 0; overflow-y: auto; padding: 14px; background: var(--paper); border-left: 2px solid var(--ink); }
#game aside section { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px dashed var(--line); }
#game aside p { color: var(--muted); font-size: 13px; }
#game aside button { padding: 6px 10px; font-size: 13px; }
#game aside #roomcode { margin: 0 0 6px; color: var(--ink); font: 700 30px/1 ui-monospace, Consolas, monospace; letter-spacing: 0.12em; }
#hintform { display: flex; gap: 6px; }
#hintform input { margin: 0; }
#students { list-style: none; margin: 0; padding: 0; }
#students li { display: flex; gap: 10px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--paper-2); }
#students li.offline { opacity: 0.5; }
#students img, #myface { flex: none; width: 34px; height: 34px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 4px; }
#students span { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
#students small { font-weight: 400; }

#bar { grid-area: bar; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 12px; background: var(--paper); border-top: 2px solid var(--ink); }
#hud { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
#hearts { display: inline-flex; gap: 2px; }
.heart { width: 24px; height: 24px; background: url(/assets/heart.png) -96px 0 / 120px 24px; image-rendering: pixelated; }
.heart.empty { background-position: 0 0; }
#charge { font-weight: 600; }
#team { color: var(--muted); font-size: 13px; }
progress { width: 90px; height: 10px; border: 2px solid var(--ink); border-radius: 3px; background: var(--paper-2); accent-color: var(--green); }
progress::-webkit-progress-bar { background: var(--paper-2); }
progress::-webkit-progress-value { background: var(--green); }
progress::-moz-progress-bar { background: var(--green); }
#role { width: auto; margin: 0; padding: 6px 8px; }
#emotes { display: flex; gap: 4px; margin-left: auto; }
#emotes button { padding: 3px 6px; line-height: 0; box-shadow: none; border-color: var(--line); }
#emotes button:hover { border-color: var(--ink); }
.teacher #emotes, .teacher #act { display: none; }
.teacher #mute { margin-left: auto; }

@media (max-width: 760px) {
  #game { grid-template: "stage" auto "bar" auto "side" auto / 1fr; height: auto; min-height: 100dvh; }
  #stage { height: 62dvh; min-height: 320px; }
  #game aside { border-left: 0; border-top: 2px solid var(--ink); }
  #full { display: none; }
}

dialog { width: min(420px, 92vw); padding: 18px; border: 2px solid var(--ink); border-radius: 6px; background: var(--paper); color: var(--ink); box-shadow: 5px 5px 0 var(--ink); font-size: 19px; }
dialog::backdrop { background: rgb(29 26 34 / 0.6); }
#question { font-weight: 600; }
#screen { width: min(960px, 96vw); }
#player { aspect-ratio: 16 / 9; background: #000; border: 2px solid var(--ink); border-radius: 4px; overflow: hidden; }
#player iframe { width: 100%; height: 100%; border: 0; }
#toast { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); max-width: 92vw; padding: 9px 14px; background: var(--ink); color: var(--paper); border-radius: 4px; font-weight: 600; z-index: 10; }

/* --- panel i edytor --- */

#panel { max-width: 980px; margin: 0 auto; padding: 16px; }
#editor { max-width: 840px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 420px; margin: 48px auto; }
.top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 2px solid var(--ink); }
nav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.checks { margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; }
td { padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
td .buttons { margin: 0; }
td button, #live button:not(.primary) { padding: 5px 9px; font-size: 13px; }
#live h3 { font-size: 16px; letter-spacing: 0; text-transform: none; color: var(--ink); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tiles .card { margin: 0; padding: 12px 14px; }
.tiles strong { display: block; font-size: 30px; line-height: 1.1; }
.tiles span { color: var(--muted); font-size: 13px; }
#absent { font-size: 13px; }

#map { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; border: 2px solid var(--ink); border-radius: 4px; }
#mapbox { overflow-x: auto; }
/* Edytor: paleta kafli do dekoracji. */
#decor { margin: 12px 0; padding: 10px; border: 2px dashed var(--line); border-radius: 6px; }
#decor summary { cursor: pointer; font-weight: 700; }
#palettebox { max-height: 360px; overflow: auto; border: 2px solid var(--ink); border-radius: 4px; background: var(--line); }
#palette { display: block; image-rendering: pixelated; cursor: crosshair; touch-action: none; }
#mapstatus { margin-top: 8px; font-weight: 600; }
#errors { padding-left: 20px; color: var(--red); font-weight: 600; }
#errors:empty { display: none; }
#save { position: sticky; bottom: 0; display: flex; gap: 12px; align-items: center; padding: 10px 0; background: var(--paper-2); border-top: 2px solid var(--ink); }
.rule { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.rule select, .rule input { width: auto; margin: 0; padding: 6px 8px; }
.rule input[type="number"] { width: 72px; }
.rule button { padding: 4px 9px; }
.creature { margin-bottom: 12px; padding: 12px; border: 2px dashed var(--line); border-radius: 6px; }
.monster { float: right; width: 48px; height: 48px; margin-left: 10px; background-size: 192px 192px; background-repeat: no-repeat; image-rendering: pixelated; }

/* --- nagrody i baza --- */
.locks { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.swatch:disabled { opacity: 0.25; }
#banner.slim { inset: 58px 0 auto 0; padding: 0 12px; background: none; pointer-events: none; }
#banner.slim #bannertext { padding: 8px 14px; font-size: 14px; box-shadow: var(--lift); }
#banner.slim #bannerkeys { padding: 3px 10px; background: var(--ink); border-radius: 4px; font-size: 13px; }
#profiledialog, #rewarddialog, #shopdialog { width: min(480px, 94vw); font-size: 15px; }
#profilexp { width: 100%; height: 14px; }
.rewards { margin: 12px 0; padding: 0; list-style: none; }
.rewards li { padding: 7px 10px; margin-bottom: 4px; border: 2px solid var(--line); border-radius: 4px; color: var(--muted); }
.rewards li.got { border-color: var(--ink); background: var(--orange-2); color: var(--ink); }
#rewardlist li { color: var(--ink); font-weight: 600; }
#profilenote, #rewardnote, #shopgems { color: var(--muted); font-size: 13px; }
#shoplist { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; max-height: 50vh; overflow-y: auto; padding: 2px 2px 6px; }
#shoplist button { display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: flex-end; min-height: 96px; padding: 8px 4px; font-size: 12px; }
.furniture { display: block; background: url(/assets/element.png) 0 0 / 512px 480px no-repeat; image-rendering: pixelated; }

/* --- stacje --- */
#talk, #paintdialog { width: min(480px, 94vw); font-size: 15px; }
#duel, #petsdialog, #famedialog, #bout { width: min(480px, 94vw); font-size: 15px; }
#famelist { display: grid; gap: 6px; padding: 0; list-style: none; }
#famelist li { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: space-between; padding: 6px 8px; border: 2px solid var(--ink); border-radius: 4px; }
#boutscore { font-size: 24px; font-weight: 700; text-align: center; }
#bouttask { font-size: 19px; font-weight: 600; }
#shoprooms { display: grid; gap: 6px; margin-bottom: 12px; }
#shoprooms h3, #shopstyles h3 { width: 100%; margin: 0; }
#shopstyles { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
#shopstyles button { display: flex; gap: 6px; align-items: center; }
.swatch { display: block; width: 32px; height: 32px; border: 2px solid var(--ink); background: url(/assets/floor.png) 0 0 / 704px 544px no-repeat; image-rendering: pixelated; }
#shoprooms button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
.petface { display: inline-block; image-rendering: pixelated; background-repeat: no-repeat; }
/* --- pojedynek stworków: scena, ramka komunikatu, menu umiejętności --- */
#duel { width: min(560px, 96vw); padding: 12px; }
#dueltitle { margin: 0 0 8px; font-size: 17px; text-align: center; }
#duelstage { position: relative; aspect-ratio: 16 / 10; overflow: hidden; border: 2px solid var(--ink); border-radius: 6px;
  background:
    radial-gradient(34% 9% at 76% 47%, #6fae4e 98%, transparent 100%), radial-gradient(42% 12% at 26% 90%, #6fae4e 98%, transparent 100%),
    radial-gradient(30% 16% at 18% 44%, #8fcf8a 99%, transparent 100%), radial-gradient(40% 20% at 64% 44%, #7cc27c 99%, transparent 100%),
    linear-gradient(#aee0f4 0 20%, #cdeefa 20% 44%, #a6d977 44% 47%, #8cc763 47%); }
.duelmon { position: absolute; aspect-ratio: 1; background-repeat: no-repeat; background-size: 400% 400%; image-rendering: pixelated;
  animation: monwalk 0.7s steps(4) infinite, var(--act, monidle 1.4s ease-in-out infinite); }
.foe .duelmon { right: 15%; top: 13%; width: 18%; --dir: -1; --from: 160%; background-position-x: 0; }
.own .duelmon { left: 13%; bottom: 9%; width: 26%; --dir: 1; --from: -160%; background-position-x: 33.333%; }
.duelmon[data-act=swap] { --act: monenter 0.45s ease-out; }
.duelmon[data-act=tame] { --act: montame 0.9s ease-in forwards; }
@keyframes montame { 30% { translate: 0 -25%; scale: 1.15; } to { translate: -120% 150%; scale: 0.2; opacity: 0; } }
.duelpips { display: flex; gap: 3px; margin-top: 2px; }
.duelpips i { width: 8px; height: 8px; border: 2px solid var(--ink); border-radius: 50%; background: #58b84a; }
.duelpips i.on { background: var(--orange); }
.duelpips i.out { background: #5b4a44; }
#duelskills button.withface { grid-template-columns: 32px 1fr; column-gap: 8px; align-items: center; }
#duelskills button.withface .petface { grid-row: span 2; }
#petslist li.inteam { background: #fffaf0; box-shadow: inset 0 0 0 2px var(--orange); }
.duelmon[data-act=lunge] { --act: monlunge 0.45s ease-in-out; }
.duelmon[data-act=hit] { --act: monhit 0.5s steps(1); }
.duelmon[data-act=faint] { --act: monfaint 0.8s ease-in forwards; }
.own.rest .duelmon { filter: grayscale(1) brightness(0.8); }
#duelstage.enter .duelmon { --act: monenter 0.6s ease-out; }
#duelstage.enter::after { content: ""; position: absolute; inset: 0; background: #fff; animation: duelflash 0.5s steps(4) forwards; pointer-events: none; }
.duelplate { position: absolute; display: grid; gap: 1px; min-width: 42%; padding: 5px 8px; border: 2px solid var(--ink); border-radius: 6px; background: var(--paper); box-shadow: 3px 3px 0 rgb(43 29 26 / 0.35); font-size: 13px; line-height: 1.25; text-align: left; }
.foe .duelplate { left: 3%; top: 6%; }
.own .duelplate { right: 3%; bottom: 7%; }
.duelplate small { color: var(--muted); font-size: 11px; }
.duelbar { display: block; height: 8px; margin-top: 2px; border: 2px solid var(--ink); border-radius: 4px; background: #5b4a44; overflow: hidden; }
.duelbar i { display: block; height: 100%; background: #58b84a; transition: width 0.6s ease-out, background-color 0.3s; }
.duelbar i.mid { background: #e9b93a; }
.duelbar i.low { background: #d9463b; }
.duelfx { position: absolute; left: 50%; top: 50%; translate: -50% -50%; background-repeat: no-repeat; image-rendering: pixelated; animation: duelfx calc(var(--frames) * 70ms) steps(var(--frames)) forwards; }
.dueldmg { position: absolute; left: 50%; top: 0; translate: -50% 0; color: #fff; font-size: 22px; text-shadow: 2px 2px 0 var(--ink), -1px -1px 0 var(--ink); animation: dueldmg 0.9s ease-out forwards; }
@keyframes monwalk { to { background-position-y: 133.333%; } }
@keyframes monidle { 50% { translate: 0 -4%; } }
@keyframes monenter { from { translate: var(--from) 0; } }
@keyframes monlunge { 40% { translate: calc(var(--dir) * 70%) calc(var(--dir) * -45%); } }
@keyframes monhit { 0%, 40%, 80% { opacity: 0.15; translate: 6% 0; } 20%, 60% { opacity: 1; translate: -6% 0; } 100% { opacity: 1; } }
@keyframes monfaint { to { translate: 0 70%; opacity: 0; } }
@keyframes duelflash { to { opacity: 0; } }
@keyframes duelfx { to { background-position-x: var(--end); } }
@keyframes dueldmg { from { opacity: 1; } to { translate: -50% -140%; opacity: 0; } }
#duelnote { min-height: 3.1em; margin: 8px 0; padding: 8px 10px; border: 2px solid var(--ink); border-radius: 6px; background: #fffaf0; box-shadow: inset 0 0 0 2px var(--line); font-size: 15px; }
#duelskills { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#duelskills button { display: grid; gap: 1px; padding: 8px; text-align: left; }
#duelskills small { font-size: 11px; font-weight: 400; opacity: 0.8; }
#dueltask { font-size: 19px; font-weight: 600; }
/* Łamigłówki: punkty polecenia jako lista, kod kłódki jako rząd pól. */
.puzzlepoints { display: grid; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; counter-reset: point; font-size: 17px; }
.puzzlepoints li { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 2px solid var(--line); border-radius: 6px; background: #fffaf0; counter-increment: point; }
.puzzlepoints li::before { content: counter(point); flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: var(--paper); font-size: 14px; font-weight: 700; }
.codeslots { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 4px 0 12px; }
.codeslots span { display: grid; place-items: center; width: 48px; height: 48px; border: 2px dashed var(--line); border-radius: 6px; background: var(--paper-2); color: var(--muted); font-size: 16px; }
.codeslots span.filled { border: 2px solid var(--ink); background: #fffaf0; color: var(--ink); font-size: 24px; box-shadow: var(--lift); }
.codeslots span.next { border: 2px solid var(--orange); }
/* Pasek wytrzymałości w trybie akcji: zielony, obok serc. */
#stamina { width: 70px; height: 10px; vertical-align: middle; accent-color: var(--green); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (prefers-reduced-motion: reduce) { .duelmon { animation: none !important; } #duelstage.enter::after { display: none; } }
#petslist { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0; list-style: none; }
#petslist li { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; border: 2px solid var(--ink); border-radius: 4px; text-align: center; }
#petslist li.unknown { opacity: 0.5; }
#petslist li.unknown .petface { filter: brightness(0); }
#talkgreeting, #painthint { color: var(--muted); }
#talkquestion { font-size: 19px; font-weight: 600; }
#talkchoices { display: flex; flex-wrap: wrap; gap: 8px; }
#talkchoices button { flex: 1 1 120px; padding: 10px; font-size: 17px; }
#easel { display: block; width: 100%; height: auto; margin-bottom: 10px; border: 2px solid var(--ink); border-radius: 4px; touch-action: none; cursor: crosshair; }
#palette { margin-bottom: 6px; align-items: center; }
#palette .swatch { width: 30px; height: 30px; }

#puzzle { width: min(520px, 94vw); font-size: 15px; }
#puzzlequestion { font-size: 17px; font-weight: 600; white-space: pre-line; }
.puzzlerow { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.puzzlerow span { flex: 1; }
.puzzlerow select { width: auto; margin: 0; }
.puzzlerow button { padding: 5px 10px; box-shadow: none; }
#puzzlebody .code { margin: 0 0 8px; padding: 10px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 4px; font-size: 24px; text-align: center; letter-spacing: 0.2em; }

/* --- raport dla rodzica --- */
#report { max-width: 720px; margin: 0 auto; padding: 24px 16px; }
#report h1 { font-size: 30px; }
#report h2 { margin-top: 20px; }
#report li { margin-bottom: 4px; }
.kicker { margin: 0; color: var(--muted); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
#lesson, #footnote { color: var(--muted); }
#footnote { margin-top: 24px; font-size: 13px; }
@media print {
  body { background: #fff; }
  #print { display: none; }
  #report .card { border: 0; box-shadow: none; }
}

/* --- rozmowa i moderacja --- */
#students li { flex-wrap: wrap; }
#students li.calling { background: var(--orange-2); }
.tools { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
#game aside .tools button { padding: 3px 7px; font-size: 12px; box-shadow: none; }
#chatbox { margin-top: 16px; padding-top: 12px; border-top: 2px dashed var(--line); border-bottom: 0 !important; }
#chatlog { list-style: none; max-height: 220px; margin: 0 0 8px; padding: 6px; overflow-y: auto; background: #fffaf0; border: 2px solid var(--ink); border-radius: 4px; font-size: 13px; }
/* Powiększony czat prowadzącego: wszystkie wiadomości lekcji w dużym oknie nad mapą. */
#chatbox.wide { position: fixed; inset: 6vh 12vw; z-index: 30; display: flex; flex-direction: column; margin: 0; padding: 16px; border: 2px solid var(--ink) !important; border-radius: 6px; background: var(--paper); box-shadow: 5px 5px 0 var(--ink); }
#chatbox.wide #chatlog { flex: 1; max-height: none; font-size: 16px; }
#unlocktools { margin-top: 8px; }
#boards { margin-top: 8px; }
#grantdialog { width: min(560px, 94vw); font-size: 15px; }
#grantdialog h3 { margin: 10px 0 6px; }
#grantgear button { display: inline-flex; gap: 6px; align-items: center; }
#chatlog:empty::before { content: 'Jeszcze nikt nic nie napisał.'; color: var(--muted); }
#chatlog li { margin-bottom: 4px; overflow-wrap: anywhere; }
#chatlog li.private { color: #7a4a1e; }
#chatlog button { padding: 0 5px; font-size: 11px; }
#chatform select { margin: 0 0 6px; padding: 5px 8px; font-size: 13px; }
.send { display: flex; gap: 6px; }
.send input { margin: 0; padding: 6px 8px; }
#hand[aria-pressed="true"], #help[aria-pressed="true"] { background: var(--orange); }
.teacher #hand, .teacher #help { display: none; }

/* --- głos, kamerki, nagrywanie --- */
#tiles { position: absolute; top: 52px; left: 50%; transform: translateX(-50%); display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: calc(100% - 20px); pointer-events: none; z-index: 1; }
#tiles.hidden { display: none; }
.tile { position: relative; width: 112px; height: 84px; background: var(--ink); border: 3px solid var(--ink); border-radius: 6px; overflow: hidden; }
.tile.speaking { border-color: #6fd16b; }
.tile video { display: block; width: 100%; height: 100%; object-fit: cover; }
.tile span { position: absolute; left: 0; right: 0; bottom: 0; padding: 1px 4px; background: rgb(43 29 26 / 0.8); color: var(--paper); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#stage:has(.tile) #banner.slim { inset: 150px 0 auto 0; }
#stage:has(.tile) #hint { top: 150px; }
#recmark { color: var(--red); font-weight: 700; }
#mic[aria-pressed="true"], #cam[aria-pressed="true"] { background: var(--orange); }
@media (max-width: 760px) { .tile { width: 80px; height: 60px; } }

/* --- dotyk: gałka, mały ekran, wysuwany panel --- */
#stage, #bar { touch-action: manipulation; }
#canvas { touch-action: none; }
#stick { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: 14px; display: none; width: 124px; height: 124px; border: 2px solid var(--ink); border-radius: 50%; background: rgb(251 238 215 / 0.55); touch-action: none; user-select: none; z-index: 2; }
#stick i { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border: 2px solid var(--ink); border-radius: 50%; background: var(--orange); box-shadow: var(--lift); pointer-events: none; }
@media (pointer: coarse) {
  #game:not(.teacher) #stick, #game.teacher.steering #stick { display: block; }
  #quiz { left: auto; right: 10px; transform: none; width: min(420px, 62%); }
}
/* Przyciski widoczne tylko na wąskim ekranie. Tylko w grze: panel ma własną klasę .narrow dla wąskiej karty logowania. */
#game .narrow { display: none; }
#drawer.unread::after { content: ''; display: inline-block; width: 9px; height: 9px; margin-left: 6px; border-radius: 50%; background: var(--red); }

@media (max-width: 760px), (max-height: 520px) {
  /* Stała wysokość paska: przewijany w bok pasek inaczej rozpycha się na kilka rzędów. */
  #game { grid-template: "stage" minmax(0, 1fr) "bar" calc(60px + env(safe-area-inset-bottom)) / 1fr; height: 100dvh; min-height: 0; }
  #stage { height: auto; min-height: 0; }
  #game .narrow { display: inline-block; }
  /* Panel z drużyną i czatem wysuwa się z prawej zamiast zabierać miejsce mapie. */
  #game aside { position: fixed; top: 0; right: 0; bottom: 0; width: min(330px, 92vw); border-left: 2px solid var(--ink); border-top: 0; transform: translateX(105%); transition: transform 0.2s; z-index: 5; padding-bottom: 24px; }
  #game.drawer aside { transform: none; box-shadow: -6px 0 0 rgb(29 26 34 / 0.35); }
  @media (prefers-reduced-motion: reduce) { #game aside { transition: none; } }
  /* Dolny pasek w jednym rzędzie, przewijany w bok. */
  #bar { flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding: 6px max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); scrollbar-width: none; }
  #bar > * { flex: none; }
  #bar button { padding: 9px 11px; white-space: nowrap; }
  #myname, #full, #team, #xp { display: none; }
  #emotes { margin-left: 0; }
  #stage header { top: 6px; left: 6px; padding: 4px 8px; font-size: 12px; }
  #tiles { top: 40px; }
  #banner.slim { inset: 40px 0 auto 0; }
  #stage:has(.tile) #banner.slim { inset: 108px 0 auto 0; }
  #banner.slim #bannerkeys { display: none; }
  #lobby { padding: 12px; }
  dialog { max-height: 92dvh; overflow-y: auto; }
}

#touchact { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: 22px; display: none; min-width: 108px; padding: 18px 16px; font-size: 18px; z-index: 2; }
@media (pointer: coarse) { #game:not(.teacher) #touchact:not([hidden]) { display: block; } }

/* ekwipunek i klasy */
#geardialog { width: min(560px, 94vw); font-size: 15px; }
#geardialog h3 { margin: 12px 0 6px; font-size: 15px; }
#gearclasses { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gearclass { display: flex; flex-direction: column; gap: 3px; padding: 8px; text-align: left; font-size: 13px; }
.gearclass progress { width: 100%; height: 8px; }
.gearclass[aria-pressed="true"], .gearitem[aria-pressed="true"] { background: var(--orange-2); box-shadow: inset 0 0 0 2px var(--ink); }
.gearitems { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.gearitem { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; font-size: 13px; text-align: center; }
.gearitem small, .gearclass small { color: var(--muted); font-size: 11px; }
.gearitem.locked { background: var(--paper-2); border-style: dashed; color: var(--muted); }
.gearitem.locked .gearicon { filter: grayscale(1); opacity: 0.5; }
.gearicon { width: 36px; height: 36px; image-rendering: pixelated; }
#gearnote { min-height: 1.3em; margin: 8px 0 0; color: var(--muted); }
@media (max-width: 520px) { #gearclasses { grid-template-columns: 1fr; } }
.gearclass .perk { padding-top: 3px; border-top: 1px dashed var(--line); }
.gearclass .perk.got { color: var(--ink); }
