@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #0f0f1a;
  --panel: #1a1a2e;
  --panel-light: #252540;
  --brass: #cd7f32;
  --brass-light: #e8a84c;
  --cyan: #00f0ff;
  --cyan-dim: rgba(0,240,255,0.15);
  --red: #ff4444;
  --green: #44ff88;
  --blue: #4488ff;
  --yellow: #ffcc00;
  --text: #e0e0e0;
  --text-dim: #888;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
}

* { margin:0; padding:0; box-sizing:border-box; }

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.app { height: 100%; display: flex; flex-direction: column; }

/* ===== LOGIN ===== */
.login-screen {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(ellipse at center, #1a1a3e 0%, #0f0f1a 70%);
}
.login-logo {
  font-family: 'Orbitron', monospace;
  font-size: 32px; font-weight: 900;
  background: linear-gradient(135deg, var(--brass), var(--cyan));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}
.login-sub { color: var(--text-dim); margin-bottom: 32px; font-size: 14px; }
.login-box {
  background: var(--panel); border: 1px solid rgba(205,127,50,0.3);
  border-radius: var(--radius); padding: 24px; width: 100%; max-width: 340px;
}
.login-box h2 {
  font-family: 'Orbitron', monospace; font-size: 16px;
  color: var(--brass); margin-bottom: 16px; text-align: center;
}
.login-box input {
  width: 100%; padding: 12px 16px; margin-bottom: 12px;
  background: var(--bg); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px; color: var(--text); font-size: 16px;
  outline: none;
}
.login-box input:focus { border-color: var(--cyan); }
.btn {
  width: 100%; padding: 12px; border: none; border-radius: 8px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--brass), var(--brass-light));
  color: #fff;
}
.btn-primary:active { transform: scale(0.97); }
.btn-secondary {
  background: transparent; color: var(--cyan);
  border: 1px solid rgba(0,240,255,0.3); margin-top: 8px;
}
.login-error { color: var(--red); font-size: 13px; margin-bottom: 8px; text-align: center; }

/* ===== HEADER ===== */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; background: var(--panel);
  border-bottom: 1px solid rgba(205,127,50,0.2);
  min-height: 50px; z-index: 100;
}
.header-title {
  font-family: 'Orbitron', monospace; font-size: 16px; font-weight: 700;
  background: linear-gradient(135deg, var(--brass), var(--cyan));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.header-status {
  display: flex; align-items: center; gap: 8px; font-size: 12px;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.status-dot.offline { background: var(--red); box-shadow: 0 0 6px var(--red); }
.header-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--panel-light); border: 1px solid rgba(255,255,255,0.1);
  color: var(--text); display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px;
}
.icon-btn:active { background: var(--cyan-dim); }

/* ===== GAME SELECTOR ===== */
.game-selector {
  display: flex; gap: 8px; padding: 8px 12px; overflow-x: auto;
  background: var(--panel); border-bottom: 1px solid rgba(255,255,255,0.05);
  -webkit-overflow-scrolling: touch;
}
.game-tab {
  flex-shrink: 0; padding: 8px 16px; border-radius: 20px;
  background: var(--panel-light); border: 1px solid rgba(255,255,255,0.08);
  font-size: 13px; font-weight: 500; color: var(--text-dim);
  cursor: pointer; white-space: nowrap; transition: all 0.2s;
}
.game-tab.active {
  background: linear-gradient(135deg, var(--brass), var(--brass-light));
  color: #fff; border-color: var(--brass);
}
.game-tab:active { transform: scale(0.95); }

/* ===== GAME AREA ===== */
.game-area {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  position: relative; overflow: hidden; padding: 8px;
}
.game-info {
  font-size: 14px; font-weight: 600; padding: 6px 16px;
  background: var(--panel); border-radius: 20px;
  border: 1px solid rgba(205,127,50,0.2); margin-bottom: 8px;
}
.game-info .turn { color: var(--cyan); }
.game-board { position: relative; }

/* ===== VIER GEWINNT ===== */
.vg-board {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px; padding: 8px; background: var(--blue);
  border-radius: 12px; box-shadow: var(--shadow);
}
.vg-cell {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--bg); cursor: pointer;
  transition: all 0.2s; position: relative;
}
.vg-cell.p1 { background: var(--red); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3); }
.vg-cell.p2 { background: var(--yellow); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3); }
.vg-cell.win { animation: pulse 0.5s infinite alternate; }
.vg-col-indicator {
  display: flex; gap: 4px; margin-bottom: 4px;
}
.vg-arrow {
  width: 42px; height: 20px; display: flex; align-items: center;
  justify-content: center; color: var(--cyan); font-size: 14px;
  cursor: pointer; opacity: 0.5; transition: opacity 0.2s;
}
.vg-arrow:active { opacity: 1; }

/* ===== DAME ===== */
.dame-board {
  display: grid; grid-template-columns: repeat(8, 1fr);
  border: 2px solid var(--brass); border-radius: 4px;
  box-shadow: var(--shadow);
}
.dame-cell {
  width: 40px; height: 40px; display: flex;
  align-items: center; justify-content: center;
  position: relative;
}
.dame-cell.light { background: #d4a76a; }
.dame-cell.dark { background: #8b5e3c; cursor: pointer; }
.dame-cell.selected { box-shadow: inset 0 0 0 3px var(--cyan); }
.dame-cell.valid-target { box-shadow: inset 0 0 0 3px var(--green); }
.dame-piece {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
  position: relative;
}
.dame-piece.p1 { background: radial-gradient(circle at 35% 35%, #ff6666, #cc0000); }
.dame-piece.p2 { background: radial-gradient(circle at 35% 35%, #cccccc, #666666); }
.dame-piece.king::after {
  content: '♛'; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%); font-size: 18px;
  color: var(--yellow); text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* ===== MUEHLE ===== */
.muehle-board {
  position: relative; width: 300px; height: 300px;
  background: var(--panel); border-radius: 8px;
  box-shadow: var(--shadow);
}
.muehle-lines {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
}
.muehle-point {
  position: absolute; width: 28px; height: 28px;
  border-radius: 50%; transform: translate(-50%, -50%);
  cursor: pointer; z-index: 2; transition: all 0.2s;
  background: var(--panel-light); border: 2px solid rgba(255,255,255,0.15);
}
.muehle-point.p1 {
  background: radial-gradient(circle at 35% 35%, #ff6666, #cc0000);
  border-color: #ff4444;
}
.muehle-point.p2 {
  background: radial-gradient(circle at 35% 35%, #66aaff, #0044cc);
  border-color: #4488ff;
}
.muehle-point.selected { box-shadow: 0 0 12px var(--cyan); border-color: var(--cyan); }
.muehle-point.valid { box-shadow: 0 0 8px var(--green); border-color: var(--green); }
.muehle-point.removable { box-shadow: 0 0 8px var(--red); border-color: var(--red); animation: pulse 0.5s infinite alternate; }
.muehle-point.mill { animation: millGlow 1s ease-in-out; }
.muehle-info {
  text-align: center; margin-top: 12px; font-size: 13px;
  color: var(--text-dim);
}
.muehle-pieces-left {
  display: flex; justify-content: center; gap: 20px;
  margin-bottom: 8px; font-size: 13px;
}

/* ===== MENSCH AERGERE DICH NICHT ===== */
.mensch-board {
  position: relative; width: 310px; height: 310px;
  background: var(--panel); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden;
  border: 1px solid rgba(205,127,50,0.15);
}
.mensch-cell {
  position: absolute; width: 22px; height: 22px;
  border-radius: 50%; border: 1.5px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06); transform: translate(-50%, -50%);
  z-index: 1;
}
.mensch-cell.start-1 {
  background: rgba(255,68,68,0.25); border-color: rgba(255,68,68,0.6);
  box-shadow: 0 0 6px rgba(255,68,68,0.15);
}
.mensch-cell.start-2 {
  background: rgba(68,136,255,0.25); border-color: rgba(68,136,255,0.6);
  box-shadow: 0 0 6px rgba(68,136,255,0.15);
}
.mensch-cell.finish-1 {
  background: rgba(255,68,68,0.12); border-color: rgba(255,68,68,0.4);
  width: 20px; height: 20px;
}
.mensch-cell.finish-2 {
  background: rgba(68,136,255,0.12); border-color: rgba(68,136,255,0.4);
  width: 20px; height: 20px;
}
.mensch-piece {
  position: absolute; width: 20px; height: 20px;
  border-radius: 50%; cursor: pointer;
  transform: translate(-50%, -50%); z-index: 3;
  border: 2px solid rgba(255,255,255,0.4);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4), inset 0 -2px 3px rgba(0,0,0,0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.mensch-piece.p1 {
  background: radial-gradient(circle at 35% 35%, #ff7777, #cc0000);
  border-color: rgba(255,200,200,0.5);
}
.mensch-piece.p2 {
  background: radial-gradient(circle at 35% 35%, #77aaff, #0044cc);
  border-color: rgba(200,220,255,0.5);
}
.mensch-piece.movable {
  animation: menschPulse 0.6s ease-in-out infinite alternate;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0,240,255,0.4), 0 2px 6px rgba(0,0,0,0.4);
}
.mensch-piece.home { opacity: 0.5; }

.mensch-roll-btn {
  padding: 12px 32px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, var(--brass), var(--brass-light));
  color: #fff; font-size: 18px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 15px rgba(205,127,50,0.3);
  transition: all 0.2s; display: inline-flex; align-items: center; gap: 8px;
}
.mensch-roll-btn:active { transform: scale(0.95); }
.mensch-roll-btn .dice-icon { font-size: 24px; }

.mensch-dice-display {
  font-size: 56px; line-height: 1;
  animation: diceAppear 0.3s ease-out;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

@keyframes menschPulse {
  from { transform: translate(-50%, -50%) scale(1); box-shadow: 0 0 6px rgba(0,240,255,0.3), 0 2px 6px rgba(0,0,0,0.4); }
  to { transform: translate(-50%, -50%) scale(1.15); box-shadow: 0 0 14px rgba(0,240,255,0.5), 0 2px 6px rgba(0,0,0,0.4); }
}
@keyframes diceAppear {
  from { transform: scale(0.3) rotate(-180deg); opacity: 0; }
  to { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ===== SPEECH BUBBLE OVERLAY ===== */
.bubble-container {
  position: absolute; top: 0; left: 0; right: 0;
  pointer-events: none; z-index: 50;
  display: flex; flex-direction: column; align-items: center;
  padding: 10px;
}
.speech-bubble {
  pointer-events: auto; max-width: 80%;
  padding: 10px 16px; border-radius: 16px;
  margin-bottom: 8px; font-size: 14px;
  animation: bubbleIn 0.3s ease-out;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  position: relative; cursor: pointer;
}
.speech-bubble.self {
  background: linear-gradient(135deg, var(--brass), var(--brass-light));
  color: #fff; align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.speech-bubble.other {
  background: var(--panel-light);
  border: 1px solid rgba(0,240,255,0.2);
  color: var(--text); align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.speech-bubble .sender {
  font-size: 11px; font-weight: 600;
  color: var(--cyan); margin-bottom: 2px;
}
.speech-bubble.self .sender { color: rgba(255,255,255,0.7); }
.speech-bubble .voice-play {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; pointer-events: auto;
}
.speech-bubble .voice-play .play-icon {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255,255,255,0.2); display: flex;
  align-items: center; justify-content: center;
}
.speech-bubble.fade-out { animation: bubbleOut 0.5s ease-in forwards; }

/* ===== CHAT BAR ===== */
.chat-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--panel);
  border-top: 1px solid rgba(205,127,50,0.2);
  min-height: 52px;
}
.chat-input {
  flex: 1; padding: 10px 16px; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 24px; background: var(--bg); color: var(--text);
  font-size: 16px; outline: none; min-height: 40px;
}
.chat-input:focus { border-color: var(--cyan); }
.chat-input::placeholder { color: var(--text-dim); }
.chat-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; transition: all 0.2s;
}
.chat-btn.send {
  background: linear-gradient(135deg, var(--brass), var(--brass-light));
  color: #fff;
}
.chat-btn.emoji { background: var(--panel-light); color: var(--text); }
.chat-btn.voice {
  background: var(--panel-light); color: var(--text);
}
.chat-btn.voice.recording {
  background: var(--red); color: #fff; animation: pulse 0.5s infinite alternate;
}
.chat-btn:active { transform: scale(0.9); }

/* ===== EMOJI PICKER ===== */
.emoji-picker {
  position: absolute; bottom: 56px; left: 12px; right: 12px;
  background: var(--panel); border: 1px solid rgba(205,127,50,0.3);
  border-radius: 16px; padding: 12px; display: none;
  z-index: 60; box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
  max-height: 250px; overflow-y: auto;
}
.emoji-picker.open { display: block; }
.emoji-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
}
.emoji-item {
  width: 100%; aspect-ratio: 1; display: flex;
  align-items: center; justify-content: center;
  font-size: 24px; cursor: pointer; border-radius: 8px;
  transition: background 0.15s;
}
.emoji-item:active { background: var(--cyan-dim); }

/* ===== ADMIN PANEL ===== */
.admin-panel {
  height: 100%; overflow-y: auto; padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.admin-panel h2 {
  font-family: 'Orbitron', monospace; font-size: 18px;
  color: var(--brass); margin-bottom: 16px;
}
.admin-section {
  background: var(--panel); border-radius: var(--radius);
  border: 1px solid rgba(205,127,50,0.2);
  padding: 16px; margin-bottom: 16px;
}
.admin-section h3 {
  font-size: 14px; color: var(--cyan); margin-bottom: 12px;
  font-family: 'Orbitron', monospace;
}
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
  text-align: left; padding: 8px; color: var(--text-dim);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.admin-table td {
  padding: 8px; border-bottom: 1px solid rgba(255,255,255,0.05);
}
.admin-table .actions { display: flex; gap: 4px; }
.admin-btn {
  padding: 4px 10px; border-radius: 6px; border: none;
  font-size: 12px; cursor: pointer;
}
.admin-btn.edit { background: var(--cyan-dim); color: var(--cyan); }
.admin-btn.delete { background: rgba(255,68,68,0.15); color: var(--red); }
.admin-form { display: flex; flex-direction: column; gap: 8px; }
.admin-form input {
  padding: 8px 12px; background: var(--bg); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px; color: var(--text); font-size: 14px; outline: none;
}
.admin-form input:focus { border-color: var(--cyan); }
.admin-stat {
  display: flex; justify-content: space-between; padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.admin-stat .value { color: var(--cyan); font-weight: 600; }

/* ===== GAME OVER MODAL ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7); display: none; z-index: 200;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--brass);
  border-radius: var(--radius); padding: 32px; text-align: center;
  max-width: 320px; width: 100%; box-shadow: 0 0 40px rgba(205,127,50,0.2);
}
.modal h2 {
  font-family: 'Orbitron', monospace; font-size: 22px;
  margin-bottom: 8px;
}
.modal .winner-text { color: var(--cyan); font-size: 16px; margin-bottom: 20px; }

/* ===== WAITING ===== */
.waiting-screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%; gap: 16px;
}
.waiting-screen .spinner {
  width: 40px; height: 40px; border: 3px solid var(--panel-light);
  border-top-color: var(--cyan); border-radius: 50%;
  animation: spin 1s linear infinite;
}
.waiting-text { color: var(--text-dim); font-size: 14px; }

/* ===== ANIMATIONS ===== */
@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(10px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes bubbleOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-10px); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes diceRoll {
  0% { transform: translateX(-50%) rotate(0deg) scale(1); }
  50% { transform: translateX(-50%) rotate(180deg) scale(1.1); }
  100% { transform: translateX(-50%) rotate(360deg) scale(1); }
}
@keyframes millGlow {
  0% { box-shadow: 0 0 0 rgba(0,240,255,0); }
  50% { box-shadow: 0 0 20px var(--cyan); }
  100% { box-shadow: 0 0 0 rgba(0,240,255,0); }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--brass); border-radius: 4px; }

/* ===== SAFE AREAS (iPhone notch) ===== */
@supports (padding: max(0px)) {
  .header { padding-top: max(8px, env(safe-area-inset-top)); }
  .chat-bar { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
  .vg-cell { width: 56px; height: 56px; }
  .dame-cell { width: 56px; height: 56px; }
  .dame-piece { width: 42px; height: 42px; }
  .muehle-board { width: 400px; height: 400px; }
  .muehle-point { width: 36px; height: 36px; }
  .mensch-board { width: 420px; height: 420px; }
  .mensch-cell { width: 30px; height: 30px; }
  .mensch-piece { width: 26px; height: 26px; }
}
