/* KupfKniffel Facelift: presentation layer only. No game mechanics are changed. */
:root {
  --bg: #f4f7fc;
  --card: #ffffff;
  --text: #17243b;
  --muted: #60718a;
  --line: #e2e8f2;
  --accent: #3059e6;
  --ok: #047857;
  --danger: #bd3143;
  --shadow: 0 10px 28px rgba(28, 49, 94, 0.075);
  --radius: 20px;
}

html { scroll-behavior: smooth; }
body {
  min-height: 100dvh;
  background: radial-gradient(ellipse at 15% -5%, #e4edff 0, transparent 35%), #f4f7fc;
  color: var(--text);
  padding-bottom: max(100px, calc(env(safe-area-inset-bottom) + 94px));
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font-family: inherit; }
button { transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
button:active:not(:disabled) { transform: scale(.985); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(48, 89, 230, .38);
  outline-offset: 2px;
}
button.secondary { background: #edf2fa; color: #263858; }
button.secondary:hover:not(:disabled) { background: #e1e9f7; }
input, select, textarea { border-color: #cfdaeb; color: var(--text); }
.subtitle { display: block; font-size: .88rem; line-height: 1.5; }
.small-label { color: var(--muted); }
.chip { border-radius: 999px; }
.app-shell { padding: 14px 16px 30px; }

.topbar {
  max-width: 1280px;
  margin-inline: auto;
  padding: 18px 16px 8px;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}
.brand { min-width: 0; }
.brand-heading { display: flex; align-items: center; gap: 11px; }
.brand-symbol {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  font-size: 25px;
  border-radius: 15px;
  background: linear-gradient(140deg, #2346b9, #5882ff);
  box-shadow: 0 8px 18px rgba(46, 81, 209, .23);
}
.brand h1 { font-size: clamp(1.12rem, 3vw, 1.45rem); font-weight: 850; letter-spacing: -.035em; line-height: 1.15; }
.brand-caption { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.brand-meta { display: flex; align-items: center; gap: 8px; margin: 8px 0 0 56px; }
.mode-badge {
  margin: 0; background: #e8efff; color: #2143a9;
  border: 1px solid #cfddff; padding: 5px 9px; font-size: 11px; font-weight: 800;
}
.brand .debug-version {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.65);
  color: #768499;
  padding: 4px 7px;
  font-size: 10px;
}
.topbar .button-row.compact { gap: 8px; align-items: center; }
.topbar .button-row.compact button { border-radius: 12px; }
.user-badge {
  border: 1px solid var(--line);
  background: #fff;
  padding: 5px 10px 5px 5px;
  box-shadow: 0 2px 8px rgba(37,57,99,.045);
}
.user-avatar { background: linear-gradient(140deg, #3157d6, #5985f5); }
#userStats { font-size: 11px; color: var(--muted); line-height: 1.3; }
#menuBtn { background: #e9effc; color: #1d3d92; font-weight: 800; }

.card {
  border: 1px solid rgba(217, 226, 241, .94);
  border-radius: 20px;
  box-shadow: var(--shadow);
  background: #fff;
}
.card.muted { background: #f1f5ff; }
.section-head h2, #screenLobby h2 { font-weight: 820; letter-spacing: -.025em; }
.section-head { gap: 10px; }
.card .chip { background: #eaf0ff; color: #3155b1; }
.small-grid > div { border-radius: 12px; }

#screenHome .start-hero {
  display: block;
  text-align: left;
  padding: 26px 28px;
  margin: 4px 0 15px;
  border-radius: 24px;
  background: linear-gradient(125deg, #1b397f 0%, #315cdb 58%, #6189f6 100%);
  box-shadow: 0 12px 27px rgba(41,75,163,.15);
  color: #fff;
}
#screenHome .start-hero .hero-eyebrow {
  display: inline-block;
  font-size: 10px;
  letter-spacing: .15em;
  font-weight: 850;
  color: #d9e6ff;
  margin-bottom: 10px;
}
#screenHome .start-hero h1 { font-size: clamp(1.45rem, 4.5vw, 2.1rem); line-height: 1.17; letter-spacing: -.035em; margin: 0 0 8px; }
#screenHome .start-hero p { color: #e8efff; font-size: .91rem; line-height: 1.45; max-width: 42rem; margin: 0; }
#screenHome .compact-start-card { padding: 19px; }
#screenHome .compact-start-card h2 { font-size: 1.1rem; margin-bottom: 10px; }
#screenHome .mode-picker { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin: 8px 0 14px; }
#screenHome .mode-card {
  min-width: 0;
  min-height: 100px;
  padding: 17px 7px;
  background: #f6f8fe;
  color: #233553;
  border: 1px solid #dce4f3;
  border-radius: 18px;
  box-shadow: none;
  text-align: center;
}
#screenHome .mode-card.active {
  color: #fff;
  background: linear-gradient(145deg, #2549be, #4874ef);
  border-color: #274cbd;
  box-shadow: 0 9px 18px rgba(37,75,188,.22);
}
#screenHome .mode-card .mode-icon { font-size: 1.65rem; line-height: 1.25; }
#screenHome .mode-card .mode-title { font-size: .9rem; }
#btnCreateGame { min-height: 51px; font-weight: 850; border-radius: 14px; background: linear-gradient(100deg,#2f53d2,#4777ef); }
#screenHome #homePostLogin .card + .card { margin-top: 12px !important; }
#screenHome #joinCode { text-transform: uppercase; font-weight: 700; letter-spacing: .065em; }

/* Navigation: essential actions always one tap away on a phone. */
.bottom-nav {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(calc(100% - 28px), 700px);
  display: grid;
  grid-template-columns: repeat(5,minmax(0,1fr));
  gap: 4px;
  padding: 8px;
  border-radius: 23px;
  border: 1px solid #dce4f4;
  background: rgba(255,255,255,.97);
  box-shadow: 0 10px 35px rgba(23,46,89,.19);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 40;
}
.bottom-nav .nav-btn {
  appearance: none;
  background: transparent;
  color: #667790;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: 16px;
  min-height: 60px;
  min-width: 0;
  font-size: .72rem;
  font-weight: 780;
  line-height: 1.1;
}
.bottom-nav .nav-btn:hover:not(.active) { background: #f2f5fb; }
.bottom-nav .nav-btn.active { background: #e9efff; color: #214bd0; box-shadow: inset 0 0 0 1px #d7e3ff; }
.bottom-nav .nav-icon { width: 22px; height: 22px; flex-shrink: 0; }
.bottom-nav .nav-label { white-space: nowrap; }

/* Menu opens as an organized, accessible modal. */
#menuDialog.app-menu-dialog {
  padding: 0;
  border: 1px solid #dce5f2;
  border-radius: 24px;
  box-shadow: 0 20px 70px rgba(17,31,61,.25);
  width: min(460px, calc(100vw - 28px));
  max-width: 100%;
  max-height: min(88dvh, 810px);
  background: #fff;
  color: var(--text);
}
#menuDialog::backdrop { background: rgba(19,31,54,.48); backdrop-filter: blur(3px); }
#menuDialog .menu-surface {
  padding: 22px;
  max-height: min(86dvh, 790px);
  overflow-y: auto;
  scrollbar-gutter: stable;
}
#menuDialog .menu-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
#menuDialog .menu-heading h2 { margin: 4px 0 0; font-size: 1.45rem; letter-spacing: -.035em; }
#menuDialog .menu-eyebrow { color: #637b9a; font-size: 10px; font-weight: 850; letter-spacing: .13em; }
#menuDialog .menu-close-btn { border-radius: 12px; padding: 8px 12px; font-weight: 800; }
#menuDialog .menu-section + .menu-section { margin-top: 19px; }
#menuDialog .menu-section h3 {
  font-size: .77rem;
  text-transform: uppercase;
  letter-spacing: .075em;
  color: #60718a;
  margin: 0 0 10px;
}
#menuDialog .menu-list { display: grid; gap: 6px; }
#menuDialog #menuLinks:not(:empty) { margin-bottom: 6px; }
#menuDialog .menu-item,
#menuDialog .menu-item.secondary,
#menuDialog .menu-item.menu-link {
  min-height: 48px;
  display: grid;
  width: 100%;
  grid-template-columns: 30px minmax(0,1fr) 20px;
  gap: 10px;
  align-items: center;
  padding: 9px 13px;
  border: 1px solid #e4eaf5;
  background: #f7f9fd;
  border-radius: 13px;
  color: #253653;
  font-size: .9rem;
  font-weight: 720;
  line-height: 1.25;
  text-align: left;
  box-shadow: none;
}
#menuDialog .menu-item:hover:not(:disabled) { background: #edf3ff; border-color: #c8d7fa; }
#menuDialog .menu-item-icon { display: inline-grid; place-items: center; font-size: 18px; }
#menuDialog .menu-chevron { color: #8292aa; font-size: 21px; line-height: 1; text-align: right; }
#menuDialog .menu-section-actions { padding-top: 15px; border-top: 1px solid var(--line); }
#menuDialog .menu-item.menu-danger { color: #a9283e; border-color: #f1d6dd; background: #fff5f6; }
#menuDialog .menu-item.menu-danger:hover { background: #ffecee; }
#menuDialog .menu-footnote { display: flex; justify-content: center; gap: 10px; border-top: 1px solid var(--line); margin-top: 20px; padding-top: 14px; }
#menuDialog .menu-version { display: inline; margin: 0; font-size: 11px; color: #8190a5; }

/* Score area */
#screenLobby .live-header { border-color: #dde6f4; }
#screenLobby .leader-line { border-color: #e3eaf5; background: #f7f9fd; border-radius: 13px; }
#screenLobby .leader-rank { background: #30466d; }
#screenLobby .leader-rank.active-turn { background: #315ce4; }
#screenLobby .leader-ticker { margin-top: 7px; }
#screenLobby .score-card { border-color: #dae3f1; }
#screenLobby .score-card h3 { background: #f5f8ff; }
#screenLobby .mobile-tab { background: #edf2fa; color: #253a65; border-radius: 11px; }
#screenLobby .mobile-tab.active { background: #2e55d7; color: #fff; }
#screenLobby .mobile-tabs { scrollbar-width: thin; }
#screenLobby .v2-dice-container { background: #f5f7fc; border: 1px solid #e5eaf5; box-shadow: none; }
#screenLobby .v2-dice-header, #screenLobby .v2-data-card { border: 1px solid #e2e9f3; border-radius: 17px; box-shadow: 0 3px 15px rgba(29,56,106,.045); }
#screenLobby .v2-dice-actions-sticky { border: 1px solid #dce6f5; box-shadow: 0 6px 18px rgba(25,45,86,.09); }
#screenLobby .v2-btn-primary { background: linear-gradient(115deg,#3159dc,#4e80f2); }
#screenLobby .v2-btn-huge { min-height: 54px; }
#screenLobby .v2-dice-hint { color: #77879e; }
#screenLobby .table-wrap, #screenLobby .overview-table-container { border-radius: 14px; }
#screenLobby #viewListe .simple-list { gap: 10px; }
#liveModeView .card { border-radius: 20px; }
#liveModeView .camera-preview { box-shadow: 0 7px 22px rgba(18,40,40,.13); }

@media (max-width: 860px) {
  .topbar { padding: 10px 12px 5px; gap: 9px; }
  .brand-symbol { width: 40px; height: 40px; flex-basis: 40px; font-size: 23px; border-radius: 12px; }
  .brand-meta { margin-left: 51px; margin-top: 6px; }
  .brand-caption { display: none; }
  .topbar #finishGameBtn, .topbar #resetCacheBtn, .topbar #installBtn { display: none !important; }
  #userStats { display: none; }
  .app-shell { padding: 10px 10px 28px; }
  .card { border-radius: 17px; padding: 13px; }
  #screenHome .start-hero { padding: 22px 20px; margin-top: 3px; }
  #screenHome .mode-card { min-height: 88px; }
  .bottom-nav {
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    border-radius: 18px 18px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding: 7px max(6px, env(safe-area-inset-left)) calc(env(safe-area-inset-bottom) + 7px) max(6px, env(safe-area-inset-right));
    gap: 2px;
  }
  .bottom-nav .nav-btn { min-height: 56px; padding: 8px 2px; gap: 3px; font-size: 10px; border-radius: 13px; }
  .bottom-nav .nav-icon { width: 22px; height: 22px; }
  #screenLobby .live-header { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 21; }
  #screenLobby .v2-dice-actions-sticky { position: sticky; top: 6px; z-index: 20; }
  #screenLobby .v2-dice-container { padding: 10px; gap: 10px; }
  #screenLobby .leaderboard-lines { grid-template-columns: repeat(auto-fit,minmax(135px,1fr)); gap: 5px; }
  #screenLobby .leader-line { padding: 8px; }
  #menuDialog .menu-surface { padding: 18px; }
  #menuDialog .menu-heading h2 { font-size: 1.32rem; }
}
@media (max-width: 380px) {
  #screenHome .start-hero h1 { font-size: 1.43rem; }
  #screenHome .mode-card { padding: 12px 3px; }
  #screenHome .mode-card .mode-title { font-size: .78rem; }
  .brand h1 { font-size: 1.04rem; }
  .topbar .button-row.compact button { padding: 8px; font-size: 11px; }
  .bottom-nav .nav-btn { font-size: 9.5px; }
  .bottom-nav .nav-icon { width: 20px; height: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  button { transition: none; }
}

/* v252: visible status during slow game creation */
#createGameStatus[hidden] { display: none !important; }
#createGameStatus.create-game-status {
  margin: 6px 0 0; padding: 10px 13px;
  border: 1px solid #bed2f6; border-radius: 11px;
  color: #204a98; background: #eef4ff;
  font-size: .87rem; line-height: 1.45; font-weight: 650;
}
#btnCreateGame:disabled { opacity: .7; cursor: progress; }

/* v255: matching category symbols, with readable labels on narrow screens. */
.category-btn { display: flex; align-items: center; gap: 8px; min-width: 0; }
.category-symbol { display: block; width: 52px; height: 28px; flex: 0 0 52px; color: var(--accent); }
.category-text { display: block; min-width: 0; line-height: 1.3; overflow-wrap: anywhere; }
.category-hint { display: block; margin-top: 2px; color: var(--muted); font-size: .78em; font-weight: 500; line-height: 1.35; }
@media (max-width: 480px) {
  .category-btn { gap: 5px; }
  .category-btn.mobile-label { padding: 10px 8px; }
  .category-symbol { width: 38px; height: 25px; flex-basis: 38px; }
}
@media print { .category-symbol { color: #263858; } }

/* v256: larger dice in two rows instead of tiny six-dice strips. */
.category-symbol { width: 52px; height: 42px; flex: 0 0 52px; }
@media (max-width: 480px) {
  .category-btn { gap: 6px; }
  .category-symbol { width: 48px; height: 40px; flex-basis: 48px; }
}
@media (max-width: 380px) {
  .category-symbol { width: 44px; height: 38px; flex-basis: 44px; }
}


/* End-of-game review: visible until the result is confirmed. */
.finish-ready-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0;
  padding: 14px 16px;
  border: 1px solid rgba(49, 89, 220, .25);
  background: #f1f5ff;
  border-radius: 16px;
}
.finish-ready-banner.hidden { display: none !important; }
.finish-ready-banner .small-label { margin-top: 4px; }
.finish-ready-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.finish-ready-actions button { min-width: 0; white-space: normal; }
@media (max-width: 540px) {
  .finish-ready-banner button { width: 100%; }
  .finish-ready-actions { grid-template-columns: 1fr; }
}

/* Bestenliste period filters: compact, touch-friendly controls on iPhone. */
.bestenliste-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0 6px;
}
.bestenliste-filters label {
  display: block;
  min-width: 0;
  font-size: .83rem;
  color: var(--muted);
  font-weight: 700;
}
.bestenliste-filters select {
  width: 100%;
  min-width: 0;
  margin-top: 5px;
  padding: 10px 8px;
  border-radius: 12px;
  box-sizing: border-box;
  font-size: 16px;
}
.bestenliste-filter-info {
  margin: 0 0 12px;
  font-size: .8rem;
}
