:root {
  --ink: #1d2433;
  --panel: #ffffff;
  --accent: #ffb300;
  --accent-dark: #c77c00;
  --alt: #29b6f6;
  --alt-dark: #0277bd;
  --muted: #6b7280;
  --err: #d32f2f;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #58c2ea; color: var(--ink);
  font-family: 'Lilita One', system-ui, sans-serif; letter-spacing: 0.02em; user-select: none; -webkit-user-select: none; }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 3;
  background: radial-gradient(ellipse at 50% 45%, transparent 62%, rgba(20, 30, 50, .22) 100%); }
body { -webkit-touch-callout: none; }
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
.hidden { display: none !important; }

button { font-family: inherit; font-size: 18px; border: 0; border-radius: 10px; cursor: pointer; color: #fff;
  background: var(--accent); box-shadow: 0 5px 0 var(--accent-dark); padding: 10px 16px; transition: transform .05s; }
button:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--accent-dark); }
button.alt { background: var(--alt); box-shadow: 0 5px 0 var(--alt-dark); }
button.ghost { background: #ffffffcc; color: var(--ink); box-shadow: 0 4px 0 #0003; }
button.small { font-size: 15px; padding: 7px 12px; }
button.big { font-size: 22px; padding: 13px 18px; width: 100%; }
input { font-family: inherit; font-size: 20px; border: 3px solid #dfe3ea; border-radius: 10px; padding: 9px 12px; width: 100%;
  color: var(--ink); outline: none; background: #f7f8fa; }
input:focus { border-color: var(--alt); }

.panel-wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: #0000002a; z-index: 10; }
.panel { background: var(--panel); border-radius: 18px; padding: 22px 22px 18px; width: min(400px, 100%);
  box-shadow: 0 10px 0 #0002, 0 20px 50px #0003; max-height: calc(100vh - 32px); overflow-y: auto; }
.logo { font-size: 64px; line-height: .9; text-align: center; margin: 4px 0 6px; color: #fff;
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); transform: rotate(-3deg); }
.sub { text-align: center; color: var(--muted); margin: 6px 0 18px; font-size: 15px; }
.field { display: block; font-size: 15px; color: var(--muted); margin-bottom: 14px; }
.field input { margin-top: 5px; }
.btns { display: grid; gap: 12px; margin-bottom: 14px; }
.join-row { display: flex; gap: 10px; }
.join-row input { text-transform: uppercase; text-align: center; letter-spacing: .2em; }
.join-row button { flex: none; background: var(--ink); box-shadow: 0 5px 0 #000; }
.err { color: var(--err); min-height: 1.2em; margin: 10px 0 4px; font-size: 15px; text-align: center; }
.help, .hint { color: var(--muted); font-size: 13px; text-align: center; margin: 10px 0 0; }
.board { margin-top: 8px; font-size: 15px; }
.board summary { cursor: pointer; color: var(--ink); }
.board ol { margin: 8px 0 0; padding-left: 28px; max-height: 220px; overflow-y: auto; font-family: system-ui, sans-serif; font-size: 14px; }
.board li { padding: 2px 0; }
.board li b { float: right; }
h2 { text-align: center; margin: 0 0 12px; font-size: 32px; }


/* Anzeige im Spiel */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.cards { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 12px; right: 66px; display: flex; align-items: flex-start; justify-content: center; gap: 10px; }
.card { position: relative; background: #fff; border-radius: 12px; padding: 7px 12px; display: flex; align-items: center; gap: 8px; font-size: 20px;
  box-shadow: 0 5px 0 #0002; transition: transform .15s; max-width: 40vw; }
.card .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card.active { transform: translateY(4px) scale(1.06); outline: 3px solid var(--ink); }
.card.off .nm { opacity: .45; }
.card .turn { position: absolute; left: 50%; top: 100%; transform: translate(-50%, 6px); font-size: 14px; background: var(--ink); color: #fff;
  padding: 2px 8px; border-radius: 6px; white-space: nowrap; display: none; }
.card.active .turn { display: block; }
.chip { width: 22px; height: 22px; flex: none; border: 3px solid var(--ink); border-radius: 6px; }
.chip.c0 { background: #e53935; }
.chip.c1 { background: #ffc107; }
#tally { font-size: 40px; color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); line-height: 1.1; white-space: nowrap; }
#spec-tag { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 78px); left: 50%; transform: translateX(-50%); background: #ffffffd9; border-radius: 8px; padding: 3px 10px; font-size: 15px; }
@media (max-width: 520px) { .card { font-size: 16px; padding: 6px 9px; } #tally { font-size: 30px; } }

#center-msg { position: fixed; top: 30%; left: 0; right: 0; text-align: center; font-size: 72px; color: #fff; z-index: 6;
  -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-shadow: 0 7px 0 var(--ink); pointer-events: none; animation: popin .35s; }
@keyframes popin { 0% { transform: scale(.4); opacity: 0 } 70% { transform: scale(1.1) } 100% { transform: scale(1); opacity: 1 } }
@media (max-width: 520px) { #center-msg { font-size: 48px; } }
#banner { position: fixed; bottom: max(24px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: #ffffffe6;
  padding: 10px 18px; border-radius: 12px; font-size: 19px; z-index: 6; pointer-events: none; text-align: center; max-width: calc(100% - 32px); white-space: nowrap; }
#banner.mine { background: var(--accent); color: #fff; box-shadow: 0 5px 0 var(--accent-dark); }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.tag { position: absolute; transform: translate(-50%, -100%); white-space: nowrap; font-size: 15px; color: #fff; padding: 1px 8px;
  border-radius: 6px; background: #1d2433b3; }
.tag.me { background: #c77c00d9; }
.tag.spec { font-size: 12px; opacity: .85; }
.tag.off::after { content: ' (weg)'; opacity: .7; }
.tag .emo { position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%); font-size: 30px; animation: pop 1.6s forwards; }
@keyframes pop { 0% { transform: translate(-50%, 10px) scale(.3); opacity: 0 } 15% { transform: translate(-50%, 0) scale(1.1); opacity: 1 }
  80% { opacity: 1 } 100% { transform: translate(-50%, -20px); opacity: 0 } }

/* Warten auf Gegner */
#lobby { position: fixed; inset: 0; pointer-events: none; z-index: 7; display: flex; flex-direction: column; justify-content: space-between; padding: 12px 16px; }
#lobby > * { pointer-events: auto; }
.lobby-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding-top: env(safe-area-inset-top); }
.room-code { background: #fff; border-radius: 10px; padding: 7px 14px; font-size: 18px; box-shadow: 0 4px 0 #0002; }
.room-code b { letter-spacing: .15em; font-size: 22px; }
.lobby-bottom { background: #ffffffeb; border-radius: 16px; padding: 12px; width: min(560px, 100%); margin: 0 auto;
  box-shadow: 0 8px 0 #0002; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.lobby-msg { text-align: center; margin: 2px 0 10px; font-size: 19px; }
#chars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
#chars button { font-size: 12px; padding: 6px 2px; background: #eef1f5; color: var(--ink); box-shadow: 0 3px 0 #0002; }
#chars button.sel { background: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-dark); }
#chars button canvas { display: block; margin: 0 auto 2px; width: 44px; height: 44px; }
@media (max-width: 520px) { #chars { grid-template-columns: repeat(4, 1fr); } }

/* Ergebnis */
#over { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 9;
  background: #fff; border-radius: 18px; padding: 14px 18px; width: min(420px, calc(100% - 24px)); box-shadow: 0 10px 0 #0002, 0 20px 50px #0003; animation: popin .3s; }
#over h2 { margin: 0 0 2px; font-size: 34px; }
#over p { text-align: center; color: var(--muted); margin: 0 0 12px; font-size: 16px; }
.over-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#btn-again.waiting { background: #b0bec5; box-shadow: 0 5px 0 #78909c; }
#btn-again.ask { animation: nudge .8s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: scale(1) } 50% { transform: scale(1.05) } }

.icon-btn { position: fixed; top: max(12px, env(safe-area-inset-top)); right: 12px; z-index: 11; width: 44px; height: 44px; padding: 0;
  font-size: 22px; background: #ffffffcc; box-shadow: 0 3px 0 #0003; }
#emotes { position: fixed; right: 12px; top: calc(max(12px, env(safe-area-inset-top)) + 56px); display: grid; gap: 8px; z-index: 8; }
#emotes button { width: 44px; height: 44px; padding: 0; font-size: 22px; background: #ffffffcc; box-shadow: 0 3px 0 #0003; }
#conn { position: fixed; top: 0; left: 0; right: 0; background: var(--err); color: #fff; text-align: center; padding: 8px; z-index: 20; }
.account { text-align: center; color: var(--alt-dark); font-size: 14px; min-height: 1.1em; margin: 2px 0 10px; }
.board li.mine { font-weight: bold; color: var(--accent-dark); }
.board li small { color: var(--muted); font-size: 12px; margin: 0 8px 0 6px; }
.board li { display: flex; align-items: baseline; }
.board li span { flex: 1; }
.logo span { font-size: 46px; color: #ffc107; }
