:root {
  --ink: #1d2433;
  --panel: #ffffff;
  --accent: #ffb300;
  --accent-dark: #c77c00;
  --alt: #29b6f6;
  --alt-dark: #0277bd;
  --muted: #6b7280;
  --err: #d32f2f;
  --c0: #e53935; --c1: #1e88e5; --c2: #43a047; --c3: #fdd835;
}
* { 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%; }
button:disabled { background: #b0bec5; box-shadow: 0 5px 0 #78909c; cursor: default; transform: none; }
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; }
.panel.small { width: min(360px, 100%); }
.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); }
.logo span { display: block; font-size: 33px; line-height: 1.15; margin-top: 4px; color: var(--c0); text-shadow: 0 4px 0 var(--ink); }
.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; }
.btns.two { grid-template-columns: 1fr 1fr; margin: 0; }
.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; display: flex; align-items: baseline; }
.board li span { flex: 1; }
.board li b { float: right; }
.board li small { color: var(--muted); font-size: 12px; margin: 0 8px 0 6px; }
.board li.mine { font-weight: bold; color: var(--accent-dark); }
.rules ul { margin: 8px 0 0; padding-left: 20px; font-family: system-ui, sans-serif; font-size: 13.5px; color: #374151; line-height: 1.4; }
.rules li { display: list-item; padding: 2px 0; }
h2 { text-align: center; margin: 0 0 12px; font-size: 32px; }
.account { text-align: center; color: var(--alt-dark); font-size: 14px; min-height: 1.1em; margin: 2px 0 10px; }

/* Offene Räume im Menü */
#rooms h3 { margin: 4px 0 6px; font-size: 16px; font-weight: normal; }
#room-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
#room-list li { display: flex; align-items: center; gap: 8px; background: #f1f4f8; border-radius: 10px; padding: 6px 8px 6px 10px; font-size: 15px; }
#room-list li .rc { letter-spacing: .12em; }
#room-list li .ri { flex: 1; color: var(--muted); font-family: system-ui, sans-serif; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#room-list li button { font-size: 14px; padding: 5px 10px; box-shadow: 0 3px 0 var(--accent-dark); }
#room-list li button.alt { box-shadow: 0 3px 0 var(--alt-dark); }

/* Anzeige im Spiel: Spielerkarten oben */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#cards { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 64px; right: 64px; display: flex; flex-wrap: wrap;
  justify-content: center; gap: 10px 12px; }
.pcard { position: relative; background: #fff; border-radius: 12px; padding: 6px 12px 6px 10px; display: flex; align-items: center; gap: 8px;
  font-size: 18px; box-shadow: 0 5px 0 #0002; transition: transform .15s; max-width: 220px; min-width: 0; }
.pcard .chip { width: 20px; height: 20px; flex: none; border: 3px solid var(--ink); border-radius: 6px; }
.pcard .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pcard .home { display: flex; gap: 2px; flex: none; }
.pcard .home i { width: 7px; height: 12px; border-radius: 2px; background: #e3e7ee; }
.pcard .home i.on { background: var(--ink); }
.pcard .st { font-size: 14px; flex: none; }
.pcard.me .nm { color: var(--accent-dark); }
.pcard .du { font-size: 12px; background: var(--accent); color: #fff; border-radius: 5px; padding: 0 5px; flex: none; }
.pcard.active { transform: translateY(4px) scale(1.06); outline: 3px solid var(--ink); }
.pcard.off .nm { opacity: .45; }
.pcard .turn { position: absolute; left: 50%; top: 100%; transform: translate(-50%, 6px); font-size: 13px; background: var(--ink); color: #fff;
  padding: 1px 8px; border-radius: 6px; white-space: nowrap; display: none; }
.pcard.active .turn { display: block; }
.pcard .timer { position: absolute; left: 8px; right: 8px; bottom: 2px; height: 3px; border-radius: 2px; background: #e3e7ee; overflow: hidden; display: none; }
.pcard .timer b { display: block; height: 100%; background: var(--accent); }
.pcard .timer.low b { background: var(--err); }
.pcard.timing .timer { display: block; }
.c0 { background: var(--c0); } .c1 { background: var(--c1); } .c2 { background: var(--c2); } .c3 { background: var(--c3); }
#spec-tag { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 60px); left: 50%; transform: translateX(-50%);
  background: #ffffffd9; border-radius: 8px; padding: 3px 10px; font-size: 15px; white-space: nowrap; }
@media (max-width: 620px) {
  /* Handy: Karten in voller Breite unter den Eck-Knöpfen, damit die Namen Platz haben */
  #cards { display: grid; grid-template-columns: 1fr 1fr; left: 12px; right: 12px; gap: 6px 8px;
    top: calc(max(12px, env(safe-area-inset-top)) + 54px); }
  .pcard { font-size: 15px; padding: 5px 8px; gap: 6px; max-width: none; }
  .pcard .chip { width: 16px; height: 16px; border-width: 2px; }
  .pcard .home i { width: 5px; height: 10px; }
  .pcard.active { transform: scale(1.04); }
  .pcard .turn, .pcard .du { display: none !important; }
  #spec-tag { top: calc(max(12px, env(safe-area-inset-top)) + 136px); }
}

/* Namensschilder an den Häusern, Würfelzahl */
#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: 2px 9px 2px 7px;
  border-radius: 8px; background: #1d2433c7; border-left: 6px solid var(--seat); transition: background .2s; }
.tag.turn { background: #1d2433; box-shadow: 0 0 0 3px #fff; }
.tag.me::after { content: ' (du)'; opacity: .75; }
.tag.off { opacity: .6; }
.tag .emo { position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%); font-size: 30px; animation: pop 1.6s forwards; }
.dienum { position: absolute; transform: translate(-50%, -100%); font-size: 46px; color: #fff; -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); animation: popin .3s; }
.dienum.six { color: var(--accent); font-size: 56px; }
@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 } }

#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; } }

/* unten: Hinweis, Würfeln-Knopf, Abwesend-Hinweis */
#bottom { position: fixed; left: 0; right: 0; bottom: max(18px, env(safe-area-inset-bottom)); display: flex; flex-direction: column;
  align-items: center; gap: 10px; z-index: 6; pointer-events: none; padding: 0 16px; }
#bottom > * { pointer-events: auto; }
#banner { background: #ffffffe6; padding: 9px 16px; border-radius: 12px; font-size: 19px; text-align: center; max-width: 100%;
  pointer-events: none !important; }
#banner.mine { background: var(--accent); color: #fff; box-shadow: 0 5px 0 var(--accent-dark); }
#btn-roll { width: auto; min-width: 220px; font-size: 26px; padding: 14px 28px; animation: nudge .9s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: scale(1) } 50% { transform: scale(1.05) } }
#away { background: #fff; border-radius: 12px; padding: 8px 10px 8px 14px; font-size: 15px; box-shadow: 0 5px 0 #0002; text-align: center; }
#away button { margin-left: 8px; }

/* Lobby */
#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); padding-right: 56px; }
.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(640px, 100%); margin: 0 auto;
  box-shadow: 0 8px 0 #0002; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
#seats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.seat { background: #f1f4f8; border-radius: 12px; padding: 6px 8px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  border-top: 7px solid var(--seat); min-width: 0; }
.seat .who { font-size: 17px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .who.free { color: var(--muted); }
.seat .who small { font-size: 12px; color: var(--muted); }
.seat.me { background: #fff3c4; }
.seat .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.seat button { font-size: 13px; padding: 5px 9px; box-shadow: 0 3px 0 var(--accent-dark); }
.seat button.alt { box-shadow: 0 3px 0 var(--alt-dark); }
.seat button.ghost { box-shadow: 0 3px 0 #0003; background: #fff; }
.seat .cname { font-size: 12px; color: var(--muted); }
.pub { display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 14px; color: var(--muted); margin: 2px 0 10px; font-family: system-ui, sans-serif; }
.pub input { width: 18px; height: 18px; margin: 0; accent-color: var(--alt-dark); }
@media (max-width: 520px) {
  #seats { grid-template-columns: 1fr 1fr; gap: 6px; }
  .seat { gap: 3px; }
  .seat .who { font-size: 15px; }
  .lobby-top { gap: 8px; }
  .lobby-top .room-code { padding: 5px 10px; }
}

/* Ergebnis (unten, damit das Brett sichtbar bleibt) */
#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(440px, calc(100% - 24px)); box-shadow: 0 10px 0 #0002, 0 20px 50px #0003; animation: popin .3s; }
#over h2 { margin: 0 0 8px; font-size: 32px; }
#results { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 4px; }
#results li { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 10px; font-size: 17px; }
#results li:first-child { background: #fff3c4; }
#results li .pl { width: 22px; color: var(--muted); }
#results li .chip { width: 16px; height: 16px; border: 2px solid var(--ink); border-radius: 5px; flex: none; }
#results li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#results li small { color: var(--muted); font-size: 13px; font-family: system-ui, sans-serif; }
#over p { text-align: center; color: var(--muted); margin: 0 0 10px; font-size: 14px; font-family: system-ui, sans-serif; }
.over-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 10px; }
.over-btns button.big { font-size: 19px; padding: 11px 10px; }

.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; color: var(--ink); }
.icon-btn.left { right: auto; left: 12px; font-size: 20px; }
#emotes { position: fixed; right: 12px; top: calc(max(12px, env(safe-area-inset-top)) + 56px); display: grid; gap: 8px; z-index: 8; }
#emo-list { display: grid; gap: 8px; }
#emotes button { width: 44px; height: 44px; padding: 0; font-size: 22px; background: #ffffffcc; box-shadow: 0 3px 0 #0003; }
#emo-toggle { display: none; }
/* Handy: Emotes hinter einem Knopf, damit sie das Brett nicht verdecken */
@media (max-width: 620px) {
  #emotes { top: max(12px, env(safe-area-inset-top)); right: 64px; }
  #emo-toggle { display: block; }
  #emo-list { display: none; }
  #emotes.open #emo-list { display: grid; }
  .lobby-top { padding-right: 112px; }
}
#conn { position: fixed; top: 0; left: 0; right: 0; background: var(--err); color: #fff; text-align: center; padding: 8px; z-index: 20; }
#confirm { z-index: 15; }
#confirm h2 { font-size: 28px; }
