@font-face {
  font-family: 'Urbanist';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(fonts/urbanist-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Urbanist';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(fonts/urbanist-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --violet: #6F00FF;
  --violet-600: #5A00D1;
  --violet-50: #F4EDFF;
  --violet-100: #E7D9FF;
  --lime: #F1FF51;
  --lime-600: #DDEB2E;
  --ink: #16101F;
  --muted: #6B6478;
  --line: #E8E4EE;
  --bg: #FFFFFF;
  --surface: #FAF8FD;
  --danger: #E5243B;
  --radius: 14px;
  --shadow: 0 10px 30px -12px rgba(43, 0, 99, .25);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Urbanist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.muted { color: var(--muted); margin: 0; }
.small { font-size: 14px; }
.error { color: var(--danger); min-height: 1.4em; margin: 0; font-weight: 600; }

/* Logo: a név "ar" része szövegkiemelővel */
.logo {
  font-weight: 800;
  font-size: 44px;
  letter-spacing: -0.04em;
  color: var(--violet);
  margin: 0;
  line-height: 1;
}
.logo mark {
  color: inherit;
  background: linear-gradient(transparent 52%, var(--lime) 52%, var(--lime) 92%, transparent 92%);
  padding: 0 .02em;
}
.logo.big { font-size: clamp(64px, 12vw, 160px); }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }
.center { align-items: center; justify-content: center; padding: 24px 16px; }

/* PIN */
.card { background: var(--bg); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.pin-card { width: min(380px, 100%); padding: 32px 28px 24px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.pin-dots { display: flex; gap: 10px; margin: 6px 0 4px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--violet-100); transition: .15s; }
.pin-dots i.on { background: var(--violet); border-color: var(--violet); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.keypad button {
  height: 60px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  font-size: 24px; font-weight: 700; transition: background .12s, transform .08s;
}
.keypad button:hover { background: var(--violet-50); }
.keypad button:active { transform: scale(.96); background: var(--violet-100); }
.keypad .k-sub { font-size: 16px; color: var(--muted); }

/* Szerep */
.role-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; width: min(720px, 100%); text-align: center; }
.roles { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: 100%; margin-top: 10px; }
.role {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-align: left;
  padding: 26px 24px; border-radius: 22px; border: 2px solid var(--line); background: var(--bg);
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.role .ic { width: 36px; height: 36px; color: var(--violet); margin-bottom: 6px; }
.role strong { font-size: 24px; font-weight: 800; }
.role span { color: var(--muted); }
.role:hover, .role:focus-visible { border-color: var(--violet); box-shadow: var(--shadow); }
.role:active { transform: scale(.98); }
.link { background: none; border: 0; color: var(--violet); font-weight: 700; padding: 8px; }
@media (max-width: 560px) { .roles { grid-template-columns: 1fr; } }

/* Gombok */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 700; white-space: nowrap; transition: background .12s, transform .08s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--violet); color: #fff; }
.btn.primary:hover { background: var(--violet-600); }
.btn.primary-soft { background: var(--violet-50); color: var(--violet); }
.btn.primary-soft:hover { background: var(--violet-100); }
.btn.ghost { background: var(--bg); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface); }
.btn.send { background: var(--violet); color: #fff; padding: 0 20px; box-shadow: inset 0 -3px 0 var(--lime); }
.btn.send:hover { background: var(--violet-600); }
.btn:disabled { opacity: .5; pointer-events: none; }

.tool {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--ink);
  transition: background .12s;
}
.tool:hover { background: var(--surface); }
.tool.active { background: var(--lime); border-color: var(--lime-600); }
.tool:disabled { opacity: .35; pointer-events: none; }

/* Rajzoló eszköztár */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); background: var(--bg); position: relative; z-index: 2;
}
.group { display: flex; align-items: center; gap: 4px; }
.spacer { flex: 1; }
.swatches button {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--line); margin: 0 2px; transition: transform .1s, box-shadow .1s;
}
.swatches button.active { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--violet); transform: scale(1.08); }
.sizes button { width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; }
.sizes button i { display: block; border-radius: 50%; background: var(--ink); }
.sizes button.active { background: var(--lime); }
.tv-group { padding-left: 10px; border-left: 1px solid var(--line); }
.tv-label { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 700; padding: 0 4px; }
.tv-label .ic { width: 18px; height: 18px; }

.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.segmented button { height: 36px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; font-weight: 700; color: var(--muted); }
.segmented button[aria-checked="true"] { background: var(--violet); color: #fff; }

/* Színpad: a kép és a rétegek pontosan fedik egymást */
.stage-area { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#draw-area { background: var(--surface); padding: 12px; }
.stage { position: relative; background: #fff; flex: none; }
#draw-stage { box-shadow: 0 0 0 1px var(--line), var(--shadow); border-radius: 4px; overflow: hidden; }
.stage .bg, .stage .layers, .stage .layers img, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage .bg { object-fit: fill; user-select: none; -webkit-user-drag: none; }
.stage .layers img { object-fit: fill; pointer-events: none; }
.stage canvas { touch-action: none; cursor: crosshair; }
#draw-layers.faded { opacity: .3; }

/* Kijelző */
#screen-display { background: #fff; }
#screen-display.cursorless { cursor: none; }
.idle { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; padding: 24px; }
.idle .muted { font-size: clamp(18px, 2.4vw, 32px); font-weight: 600; }
.display-menu {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 18px;
  background: rgba(255, 255, 255, .94); border: 1px solid var(--line); box-shadow: var(--shadow); transition: .2s;
}
.display-menu.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.status { display: inline-flex; align-items: center; gap: 8px; padding: 0 10px; font-weight: 700; }
.status i { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.status.online i { background: #19B66A; }

/* Modalok */
.modal {
  width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 22px 22px 26px;
  border: 0; border-radius: 24px; box-shadow: var(--shadow); color: var(--ink); overflow: auto;
}
.modal::backdrop { background: rgba(22, 16, 31, .4); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal h2 { margin: 0; font-size: 26px; font-weight: 800; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.tile {
  position: relative; aspect-ratio: 4 / 3; border-radius: 14px; border: 2px solid var(--line); background: var(--surface) center / cover no-repeat;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-weight: 700; color: var(--muted); padding: 0; overflow: hidden;
}
.tile:hover { border-color: var(--violet); }
.tile.current { border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-100); }
.tile.add { border-style: dashed; color: var(--violet); background-color: var(--violet-50); }
.tile.blank { background: #fff; }
.tile .ic { width: 28px; height: 28px; }
.tile .tag { position: absolute; left: 8px; bottom: 8px; background: var(--lime); color: var(--ink); font-size: 12px; padding: 2px 8px; border-radius: 99px; }
.tile.busy::after { content: ''; position: absolute; inset: 0; background: rgba(255, 255, 255, .7); }

.setting { padding: 18px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.setting:first-of-type { border-top: 0; }
.setting h3 { margin: 0; font-size: 18px; font-weight: 800; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice label { display: flex; gap: 10px; padding: 14px; border: 2px solid var(--line); border-radius: 14px; cursor: pointer; }
.choice label:has(input:checked) { border-color: var(--violet); background: var(--violet-50); }
.choice input { accent-color: var(--violet); margin-top: 3px; }
.choice span { display: flex; flex-direction: column; color: var(--muted); font-size: 14px; }
.choice b { color: var(--ink); font-size: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.row input { flex: 1 1 140px; height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 18px; letter-spacing: .2em; }
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.lib .tile { aspect-ratio: 1; }
.lib .del {
  position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: 0;
  background: #fff; color: var(--danger); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}
.lib .del .ic { width: 16px; height: 16px; }
@media (max-width: 560px) { .choice { grid-template-columns: 1fr; } }

.toast {
  position: fixed; left: 50%; top: 20px; transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 700; transition: .2s; z-index: 10;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: var(--violet); box-shadow: inset 0 -3px 0 var(--lime); }
.toast.err { background: var(--danger); }
