:root {
  --void-1: #101534;
  --void-2: #070914;
  --void-3: #04050b;
  --ink: #dfe6f5;
  --thread: #96acea;
  --ember: #ffbb7a;
  --gold: #ffe19a;
  --danger: #ff8c8c;
  --panel: rgba(10, 12, 26, .55);
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; overflow: hidden; }

body {
  background: radial-gradient(ellipse at 50% 42%, var(--void-1) 0%, var(--void-2) 58%, var(--void-3) 100%);
  color: var(--ink);
  font-family: var(--serif);
  font-style: italic;
}

canvas { position: fixed; inset: 0; display: block; touch-action: none; cursor: grab; }
canvas.drag { cursor: grabbing; }
canvas.select-mode { cursor: crosshair; }

/* ---------- Logo / Markenname ---------- */
#brand {
  position: fixed; top: calc(18px + env(safe-area-inset-top, 0px)); left: 20px;
  display: flex; align-items: center; gap: 8px; pointer-events: none; opacity: .85;
}
#brand svg { width: 22px; height: 22px; fill: var(--ink); opacity: .8; }
#brand svg .band { fill: var(--ember); opacity: .9; }
#brand span { font-size: 1.15rem; letter-spacing: .04em; }

/* ---------- Mehrfachauswahl-Umschalter ---------- */
#select-toggle {
  position: fixed; top: calc(18px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  font-family: var(--serif); font-style: italic; font-size: .82rem; color: rgba(223, 230, 245, .55);
  background: var(--panel); border: 1px solid rgba(150, 172, 234, .22); border-radius: 999px;
  padding: 7px 16px; cursor: pointer; backdrop-filter: blur(6px); z-index: 4;
}
#select-toggle[aria-pressed="true"] { color: #1a1408; background: var(--ember); border-color: var(--ember); }

/* ---------- Leerer Raum ---------- */
#hint {
  position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none;
  text-align: center; padding: 24px; font-size: clamp(1.15rem, 3.2vw, 2rem); color: rgba(223, 230, 245, .38);
}
#hint[hidden] { display: none; }

/* ---------- Status-Zeile ---------- */
#status {
  position: fixed; top: calc(20px + env(safe-area-inset-top, 0px)); right: 20px;
  max-width: min(42vw, 300px); text-align: right; font-size: .8rem;
  color: rgba(223, 230, 245, .45); pointer-events: none;
}
#status:empty { display: none; }

/* ---------- Popover: Bearbeiten / Löschen ---------- */
#word-pop { position: fixed; transform: translate(-50%, 10px); z-index: 5; display: flex; gap: 6px; }
#word-pop[hidden] { display: none; }
#word-pop button {
  font-family: var(--serif); font-style: italic; font-size: .82rem; border-radius: 999px; padding: 7px 14px;
  cursor: pointer; backdrop-filter: blur(6px); border: 1px solid rgba(150, 172, 234, .3);
  color: var(--ink); background: rgba(18, 22, 42, .82);
}
#edit-btn:hover { border-color: var(--thread); }
#delete-btn { color: #ffd7d7; background: rgba(60, 14, 20, .82); border-color: rgba(255, 140, 140, .35); }
#delete-btn:hover { background: rgba(80, 18, 26, .9); }

/* ---------- Bearbeiten-Feld ---------- */
.floating-input {
  position: fixed; transform: translate(-50%, -50%); z-index: 6;
  font-family: var(--serif); font-style: italic; font-size: 1.05rem; text-align: center;
  color: var(--ink); background: rgba(14, 17, 34, .92); border: 1px solid var(--ember);
  border-radius: 999px; padding: 6px 14px; width: min(220px, 60vw); outline: 0;
}
.floating-input[hidden] { display: none; }

/* ---------- Sammel-Leiste ---------- */
#bulk-bar {
  position: fixed; top: calc(64px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; background: var(--panel);
  border: 1px solid rgba(150, 172, 234, .22); border-radius: 999px; padding: 8px 10px 8px 16px;
  font-size: .85rem; backdrop-filter: blur(6px); z-index: 4;
}
#bulk-bar[hidden] { display: none; }
#bulk-bar button {
  font-family: var(--serif); font-style: italic; font-size: .82rem; border-radius: 999px; padding: 6px 14px;
  cursor: pointer; border: 1px solid rgba(150, 172, 234, .3); background: rgba(18, 22, 42, .82); color: var(--ink);
}
#bulk-delete { color: #ffd7d7; background: rgba(60, 14, 20, .82); border-color: rgba(255, 140, 140, .35); }
#bulk-delete:hover { background: rgba(80, 18, 26, .9); }

/* ---------- Formular ---------- */
form {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  width: min(500px, calc(100vw - 28px)); display: flex; flex-direction: column; gap: 8px;
}

.row { display: flex; gap: 8px; align-items: center; }
.row.main { position: relative; }

input, select {
  flex: 1; min-width: 0; background: var(--panel); border: 1px solid rgba(150, 172, 234, .22); outline: 0;
  color: var(--ink); font: inherit; border-radius: 999px; padding: 11px 16px;
  backdrop-filter: blur(6px); transition: border-color .25s;
}
select { appearance: none; -webkit-appearance: none; }
.row.main input { font-size: 1.1rem; }
.row.secondary input, .row.secondary select { font-size: .84rem; padding: 9px 14px; opacity: .9; }
.row.secondary select { flex: 1.3; }
.row.cluster-form input { font-size: .82rem; padding: 8px 12px; opacity: .9; }

input::placeholder { color: rgba(223, 230, 245, .38); }
input:focus, select:focus { border-color: var(--ember); }
input:focus-visible, select:focus-visible { outline: 1px solid var(--ember); outline-offset: 1px; }
input:disabled, select:disabled { opacity: .5; }

option { background: #12142a; color: var(--ink); font-style: normal; }

#dice, #send, #new-cluster-btn, #cancel-cluster-btn, #create-cluster-btn {
  flex: 0 0 auto; border-radius: 999px; border: 1px solid rgba(150, 172, 234, .22);
  background: var(--panel); color: var(--ink); cursor: pointer; backdrop-filter: blur(6px);
  font-family: var(--serif); font-style: italic;
}
#dice, #send, #new-cluster-btn {
  width: 42px; height: 42px; border-radius: 50%; font-size: 1.1rem; display: grid; place-items: center;
}
#dice:hover, #send:hover, #new-cluster-btn:hover { border-color: var(--ember); }
#send { font-style: normal; padding-left: 2px; }
#new-cluster-btn { font-style: normal; font-size: 1.3rem; padding-bottom: 2px; }
#create-cluster-btn { padding: 8px 14px; font-size: .82rem; }
#create-cluster-btn:hover { border-color: var(--gold); }
#cancel-cluster-btn {
  width: 34px; height: 34px; border-radius: 50%; font-size: 1rem; display: grid; place-items: center; padding: 0;
}

#msg { text-align: center; font-size: .9rem; color: var(--ember); opacity: 0; transition: opacity .3s; }
#msg.show { opacity: .9; }

/* ---------- Smartphone ---------- */
@media (max-width: 520px) {
  #brand { left: 14px; top: calc(12px + env(safe-area-inset-top, 0px)); }
  #brand span { font-size: 1rem; }
  #brand svg { width: 18px; height: 18px; }
  #select-toggle { font-size: .75rem; padding: 6px 12px; top: calc(12px + env(safe-area-inset-top, 0px)); }
  #status { right: 14px; max-width: 56vw; font-size: .72rem; }
  #bulk-bar { top: calc(54px + env(safe-area-inset-top, 0px)); font-size: .78rem; }
  form { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); width: calc(100vw - 20px); }
  .row.main input { font-size: 1rem; padding: 10px 14px; }
  .row.secondary, .row.cluster-form { flex-wrap: wrap; }
  .row.secondary select { flex: 1 1 100%; order: 2; }
  .row.secondary input { flex: 1 1 auto; order: 1; }
  .row.secondary #new-cluster-btn { order: 3; }
  #dice, #send { width: 38px; height: 38px; font-size: 1rem; }
  #hint { font-size: 1rem; }
}

@media (max-height: 480px) { #hint { display: none; } }
