:root {
  --ms-red: #E3000B;
  --ms-red-dark: #B4000A;
  --ms-black: #111114;
  --ms-grey: #6b6b70;
  --ms-grey-light: #f2f2f4;
  --ms-border: #e2e2e6;
  --ms-white: #ffffff;
  --ms-green: #1b8a4a;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: var(--ms-grey-light);
  color: var(--ms-black);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

/* iPad-Kiosk: keine versehentliche Textauswahl, aber Formulareingaben bleiben nutzbar */
input, textarea {
  -webkit-user-select: text;
  user-select: text;
}

/* Versteckte Tap-Zone oben rechts: 10x antippen oeffnet die Einstellungen */
#adminTapZone {
  position: fixed;
  top: 0;
  right: 0;
  width: 110px;
  height: 110px;
  z-index: 100;
  background: transparent;
}

.logo-bar {
  padding: calc(env(safe-area-inset-top, 0) + 14px) 18px 0;
}

.logo-bar .logo {
  height: 34px;
  width: auto;
  display: block;
  opacity: 0.92;
}

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
}

.card {
  background: var(--ms-white);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.10);
  padding: 56px 48px;
  text-align: center;
  max-width: 560px;
  width: 100%;
}

.card-wide {
  max-width: 760px;
  text-align: left;
}

.card-wide h1 { text-align: center; }
.card-wide .subtitle { text-align: center; }

.card h1 {
  font-size: 32px;
  margin: 0 0 14px;
  font-weight: 900;
  letter-spacing: -0.01em;
}

.subtitle {
  color: var(--ms-grey);
  font-size: 18px;
  margin: 0 0 36px;
  line-height: 1.5;
}

.call-button {
  appearance: none;
  border: none;
  background: var(--ms-red);
  color: var(--ms-white);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.01em;
  padding: 30px 40px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  box-shadow: 0 10px 28px rgba(227, 0, 11, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease, background 0.12s ease;
  width: 100%;
  justify-content: center;
  min-height: 92px;
}

.call-button:active {
  background: var(--ms-red-dark);
  transform: scale(0.98);
  box-shadow: 0 6px 18px rgba(227, 0, 11, 0.3);
}

/* Ersetzt den Button nach dem Ruf: Bestaetigungstext + Timer an derselben Stelle */
.called-state {
  min-height: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.confirm-msg {
  color: var(--ms-green);
  font-weight: 800;
  font-size: 19px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.confirm-msg .icon {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
}

.countdown {
  font-size: 16px;
  color: var(--ms-grey);
  font-weight: 700;
}

.hidden { display: none !important; }

.icon-xl {
  width: 52px;
  height: 52px;
  color: var(--ms-red);
  margin-bottom: 14px;
}

.apology p {
  color: var(--ms-grey);
  line-height: 1.6;
  font-size: 18px;
}

/* Modal overlay (Spiel-Angebot + Spiel) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 20, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal {
  background: var(--ms-white);
  border-radius: 16px;
  padding: 40px 36px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal .icon-xl { color: var(--ms-black); }

.modal h2 {
  margin: 0 0 12px;
  font-size: 24px;
  font-weight: 900;
}

.modal p {
  color: var(--ms-grey);
  line-height: 1.5;
  margin: 0 0 26px;
  font-size: 16px;
}

.modal-actions, .button-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-primary, .btn-secondary, .btn-danger {
  border: none;
  border-radius: 12px;
  padding: 18px 20px;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  min-height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-sizing: border-box;
}

.btn-primary {
  background: var(--ms-red);
  color: var(--ms-white);
}

.btn-primary:active { background: var(--ms-red-dark); }

.btn-secondary {
  background: var(--ms-grey-light);
  color: var(--ms-black);
}

.btn-secondary:active { background: #e5e5e9; }

.btn-danger {
  background: #fdeaea;
  color: var(--ms-red-dark);
}

.btn-danger:active { background: #f8d5d5; }

.btn-small {
  min-height: 40px;
  padding: 8px 14px;
  font-size: 14px;
}

.full-width { width: 100%; }

/* Spiel */
.game-wrap {
  background: var(--ms-black);
  border-radius: 16px;
  padding: 20px;
  max-width: 720px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ms-white);
  font-weight: 800;
  margin-bottom: 12px;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.game-hud #gameCountdown {
  color: #ff8a8f;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--ms-white);
  cursor: pointer;
  opacity: 0.92;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close .icon {
  width: 20px;
  height: 20px;
}

#gameCanvas {
  width: 100%;
  height: auto;
  aspect-ratio: 800 / 260;
  background: var(--ms-white);
  border-radius: 10px;
  display: block;
  touch-action: manipulation;
}

.game-hint {
  color: #b9b9c0;
  text-align: center;
  font-size: 14px;
  margin: 14px 0 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

/* Admin / Registrierung / Dashboard */
.admin-form {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-form label {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ms-grey);
  margin-top: 16px;
}

.admin-form input, .add-tablet-form input {
  border: 2px solid var(--ms-border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 17px;
  font-family: inherit;
  -webkit-user-select: text;
  user-select: text;
  min-height: 50px;
}

.admin-form input:focus, .add-tablet-form input:focus {
  outline: none;
  border-color: var(--ms-red);
}

.admin-form .btn-primary {
  margin-top: 28px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row > div {
  flex: 1;
}

.hint {
  font-size: 13px;
  color: var(--ms-grey);
  margin: 10px 0 0;
}
.hint a {
  color: var(--ms-red);
  font-weight: 700;
  text-decoration: none;
}

.hint a:active {
  color: var(--ms-red-dark);
}

.icon {
  width: 20px;
  height: 20px;
}

.error-msg, .success-msg {
  border-radius: 10px;
  padding: 14px 16px;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.error-msg {
  background: #fdeaea;
  color: var(--ms-red-dark);
}

.success-msg {
  background: #e7f7ee;
  color: var(--ms-green);
}

.admin-links {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
  font-size: 15px;
}

.admin-links a {
  color: var(--ms-grey);
  text-decoration: none;
  font-weight: 700;
}

.admin-links a:active { color: var(--ms-red); }

/* Markt-/Tablet-Link Anzeige */
.link-box {
  background: var(--ms-grey-light);
  border: 2px solid var(--ms-border);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 4px 0 12px;
  overflow-x: auto;
}

.link-box .copyable-link {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 15px;
  color: var(--ms-black);
  white-space: nowrap;
  -webkit-user-select: text;
  user-select: text;
}

.admin-setup-link {
  margin-top: 12px;
}

#copyLinkBtn {
  margin-bottom: 8px;
}

/* Dashboard: Tablet-Liste */
.section-heading {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ms-grey);
  margin: 32px 0 12px;
}

.section-heading:first-of-type {
  margin-top: 0;
}

.tablet-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tablet-card {
  border: 2px solid var(--ms-border);
  border-radius: 12px;
  padding: 16px 18px;
}

.tablet-card-name {
  font-weight: 800;
  font-size: 17px;
  margin-bottom: 8px;
}

.tablet-card-link {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  color: var(--ms-grey);
  word-break: break-all;
  -webkit-user-select: text;
  user-select: text;
  margin-bottom: 12px;
}

.tablet-card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.tablet-card-actions form { margin: 0; }

.badge-unconfigured {
  display: inline-block;
  background: #fff4e0;
  color: #a86200;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 6px;
  padding: 3px 8px;
  margin-left: 8px;
  vertical-align: middle;
}

.add-tablet-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.add-tablet-form > div { flex: 1; min-width: 200px; }
.add-tablet-form label { margin-top: 0; }
.add-tablet-form .btn-primary { margin-top: 0; height: 50px; min-height: 50px; }

hr.divider {
  border: none;
  border-top: 2px solid var(--ms-border);
  margin: 32px 0;
}

@media (max-width: 480px) {
  .card { padding: 36px 26px; }
  .form-row { flex-direction: column; gap: 0; }
}
