
/* CSS v49 */
/* IMPORTANT: COMMENT STYLE FOR CSS */

  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  :root {
    --bg:        #1c1c1e;
    --surface:   #2a2a2e;
    --surface2:  #323236;
    --border:    #444448;
    --green:     #3cb371;
    --green-dk:  #2a8a54;
    --green-lt:  #5dcc8a;
    --cream:     #e8e4dc;
    --cream-dk:  #b0aca4;
    --muted:     #6e6e76;
    --gold:      #c9a84c;
    --gold-lt:   #e8c87a;
    --red:       #c0392b;
    --shadow:    0 4px 20px rgba(0,0,0,0.4);
  }
  body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--cream); min-height: 100vh; padding: 1rem; }
.screen {
  display: none;
}

.screen.active {
  display: block;

  /* IMPORTANT: prevents weird stacking contexts */
  position: relative;
}

  /* LOADING */
  .loading-wrap { max-width: 400px; margin: 6rem auto; text-align: center; }
  .loading-wrap h2 { color: var(--green); margin-bottom: 1rem; }
  .spinner { width: 48px; height: 48px; border: 3px solid rgba(60,179,113,0.2); border-top-color: var(--green); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 1rem auto; }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* LOGO */
/* LOGO (now title wrapper) */
.logo-wrap {
  text-align: center;
  margin-bottom: 1.5rem;
  display: block; /* IMPORTANT: removes flex distortion */
}

.logo-wrap img {
  display: none; /* safety fallback if any old markup remains */
}

  /* SETUP */
  .setup-wrap { max-width: 520px; margin: 1.5rem auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.8rem; box-shadow: var(--shadow); }
  .field-group { margin-bottom: 1.1rem; }
  .field-group label { display: block; font-size: 0.75rem; font-weight: 500; color: var(--green-lt); margin-bottom: 5px; letter-spacing: 0.5px; text-transform: uppercase; }
  .field-group input, input.ep-name, input.ep-email { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 7px; color: var(--cream); font-family: 'DM Sans', sans-serif; font-size: 0.93rem; padding: 9px 13px; outline: none; transition: border-color 0.2s; }
  .field-group input:focus, input.ep-name:focus, input.ep-email:focus { border-color: var(--green); }
  .field-group input::placeholder, input.ep-name::placeholder, input.ep-email::placeholder { color: var(--muted); }
  .player-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 7px; margin-bottom: 7px; align-items: center; }
  .btn-icon { background: rgba(192,57,43,0.18); border: 1px solid rgba(192,57,43,0.4); border-radius: 7px; color: #e07070; cursor: pointer; padding: 7px 10px; font-size: 0.95rem; transition: all 0.2s; }
  .btn-icon:hover { background: rgba(192,57,43,0.35); }
  .btn { display: inline-block; cursor: pointer; border: none; font-family: 'DM Sans', sans-serif; font-weight: 500; border-radius: 8px; transition: all 0.18s; }
  .btn-primary { background: var(--green); color: #fff; padding: 11px 22px; font-size: 0.97rem; width: 100%; letter-spacing: 0.2px; }
  .btn-primary:hover:not(:disabled) { background: var(--green-lt); transform: translateY(-1px); }
  .btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
  .btn-secondary { background: rgba(60,179,113,0.1); border: 1px solid rgba(60,179,113,0.3); color: var(--green-lt); }
  .btn-secondary:hover { background: rgba(60,179,113,0.2); }
  .divider { border: none; border-top: 1px solid var(--border); margin: 1.1rem 0; }
  details.email-config { background: rgba(0,0,0,0.25); border-radius: 9px; padding: 0.9rem; margin-bottom: 1rem; font-size: 0.82rem; border: 1px solid var(--border); }
  details.email-config summary { cursor: pointer; color: var(--green-lt); font-weight: 500; list-style: none; }
  details.email-config summary::before { content: "▶ "; font-size: 0.68rem; }
  details.email-config[open] summary::before { content: "▼ "; }
  .config-grid { display: grid; gap: 7px; margin-top: 9px; }
  .config-row { display: grid; grid-template-columns: 1fr 1.5fr; gap: 7px; align-items: center; }
  .config-row label { font-size: 0.76rem; color: var(--muted); }
  .config-row input { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--cream); font-family: "DM Sans", sans-serif; font-size: 0.82rem; padding: 7px 10px; outline: none; width: 100%; }
  .config-row input:focus { border-color: var(--green); }
  .hint { font-size: 0.71rem; color: var(--muted); margin-top: 7px; line-height: 1.5; }

  /* GAME LAYOUT */
  .game-layout { display: grid; grid-template-columns: 1fr 300px; gap: 1rem; max-width: 1040px; margin: 0 auto; }
  .panel { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 0.9rem; box-shadow: var(--shadow); }
  .panel-title { font-size: 0.68rem; font-weight: 700; color: var(--green); letter-spacing: 1.2px; text-transform: uppercase; margin-bottom: 0.7rem; }

  /* DICE AREA */
  .dice-panel { padding: 0.8rem 1rem; }
  .dice-top-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; gap: 8px; }
  .turn-status-inline { font-size: 0.88rem; color: var(--cream-dk); }
  .turn-status-inline strong { color: var(--green-lt); font-weight: 700; }
  .rolls-left-inline { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
  .dice-main-row { display: flex; align-items: center; gap: 12px; margin-bottom: 0.4rem; height: 88px; }
  .dice-row { display: flex; gap: 8px; flex-wrap: nowrap; flex: 1; justify-content: center; align-items: center; }
  .roll-info { font-size: 0.72rem; color: var(--muted); text-align: center; }
  .status-bar { display:none; } /* legacy — replaced by turn-status-inline */

.die { 
  width: 72px; 
  height: 72px; 
  border-radius: 8px; 
  cursor: pointer; 
  border: 3px solid transparent; 
  transition: border-color 0.2s; 
  position: relative; 
  user-select: none;
  overflow: hidden;
  background: #3a3a3a;

  /* HARD CENTERING SYSTEM */
  display: grid;
  place-items: center;

  flex-shrink: 0;
}

.die img { 
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;

  /* critical: remove inline/image baseline artifacts */
  vertical-align: middle;
}

  .die:hover { transform: translateY(-2px); }
  .die.held { border-color: var(--green); box-shadow: 0 0 0 2px var(--green), 0 0 14px rgba(60,179,113,0.4); }
  .die.held::after { content: "HELD"; position: absolute; top: 2px; right: 3px; font-size: 0.48rem; font-weight: 700; color: var(--green-lt); letter-spacing: 0.5px; background: rgba(0,0,0,0.55); padding: 1px 3px; border-radius: 3px; }
  .die.rolling { border-color: var(--gold); }
  .rolls-left { font-size: 1.1rem; font-weight: 500; color: var(--cream); text-align: center; margin-bottom: 3px; }
  .roll-info { text-align: center; font-size: 0.78rem; color: var(--muted); margin-bottom: 0.7rem; }

/* ROLL BUTTON - styled like original green button */

#roll-btn {
  background: var(--green);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;

  height: 72px;
  width: 120px;              /* FIXED WIDTH prevents layout shift */
  padding: 0 20px;

  border-radius: 8px;
  border: none;
  cursor: pointer;

  letter-spacing: 0.5px;
  font-family: "DM Sans", sans-serif;

  box-shadow: 0 3px 0 var(--green-dk), 0 4px 8px rgba(0,0,0,0.3);
  transition: all 0.12s;

  flex-shrink: 0;

  /* layout stability + centering */
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;

  white-space: nowrap;       /* prevents accidental wrapping */
}

#roll-btn:hover:not(:disabled) {
  background: var(--green-lt);
  transform: translateY(-1px);
}

#roll-btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--green-dk);
}

#roll-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: 0 3px 0 var(--green-dk), 0 4px 8px rgba(0,0,0,0.3);
}

  /* SCORECARD */
  .score-header { display: grid; gap: 3px; margin-bottom: 5px; padding-bottom: 5px; border-bottom: 1px solid var(--border); }
  .score-row { display: grid; gap: 3px; padding: 6px 4px; border-radius: 5px; cursor: pointer; transition: background 0.13s; align-items: center; min-height: 32px; }
  .score-row:hover { background: rgba(60,179,113,0.07); }
  .score-row.scored { cursor: default; }
  .score-row.scored:hover { background: transparent; }
  .score-row.potential { background: rgba(60,179,113,0.08); outline: 1px solid rgba(60,179,113,0.2); min-height: 32px; }
  .score-row.potential-zero { background: rgba(60,179,113,0.04); outline: 1px solid rgba(60,179,113,0.2); min-height: 32px; }
  .score-row.section-header { background: rgba(0,0,0,0.3); font-weight: 700; font-size: 0.68rem; color: var(--green); letter-spacing: 0.5px; cursor: default; padding: 4px; border-radius: 4px; margin: 5px 0 2px; }
  .score-row.section-header:hover { background: rgba(0,0,0,0.3); }
  .cat-name { color: var(--cream-dk); font-size: 0.8rem; }
  .cat-score { text-align: center; color: var(--cream); font-weight: 500; font-size: 0.8rem; }
  .cat-score.potential { color: var(--green-lt); font-style: italic; }
  .cat-score.zero { color: var(--muted); }
  .total-row { display: grid; gap: 3px; padding: 7px 4px; border-top: 1px solid var(--border); margin-top: 5px; font-weight: 600; }
  .total-label { color: var(--green-lt); font-size: 0.8rem; }
  .total-val { text-align: center; color: var(--green-lt); font-weight: 700; font-size: 0.88rem; }

  /* PLAYERS */
  .player-card { display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 9px; margin-bottom: 7px; border: 1px solid transparent; transition: all 0.2s; }
  .player-card.active-player { background: rgba(60,179,113,0.1); border-color: rgba(60,179,113,0.35); }
  .player-avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.82rem; font-weight: 700; flex-shrink: 0; }
  .player-info { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; }
  .player-name { font-size: 0.88rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .player-score-val { font-size: 0.76rem; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
  .turn-indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; animation: pulse 1.5s ease-in-out infinite; }
  @keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.4;transform:scale(0.75)} }

  /* GAME TITLE TEXT */
  .game-title-text { font-family: "DM Sans", sans-serif; font-weight: 700; letter-spacing: 2px; margin-bottom: 0.5rem; line-height: 1; user-select: none; }
  .game-title-s { font-size: 2.2rem; color: var(--green-lt); text-shadow: 0 0 18px rgba(60,179,113,0.5); }
  .game-title-rest { font-size: 1.6rem; color: var(--cream); }
  .game-title-bang { font-size: 2.2rem; color: var(--green); text-shadow: 0 0 18px rgba(60,179,113,0.4); }

  /* GAME LINK BAR */
  details.game-link-details { background: rgba(0,0,0,0.2); border: 1px solid var(--border); border-radius: 9px; margin-bottom: 0.8rem; overflow: hidden; }
  details.game-link-details summary { padding: 7px 13px; cursor: pointer; font-size: 0.78rem; color: var(--muted); list-style: none; user-select: none; }
  details.game-link-details summary:hover { color: var(--green-lt); }
  details.game-link-details summary::before { content: "▶ "; font-size: 0.65rem; }
  details.game-link-details[open] summary::before { content: "▼ "; }
  .game-link-inner { display: flex; align-items: center; gap: 8px; padding: 0 13px 10px; flex-wrap: wrap; }
  .game-link-inner span { font-size: 0.72rem; color: var(--green-lt); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: monospace; }

  .notif-summary { cursor: pointer; list-style: none; margin-bottom: 0; }
  .notif-summary::before { content: "▶ "; font-size: 0.65rem; }
  details.notif-details[open] .notif-summary::before { content: "▼ "; }

  /* TOAST */
  .toast { position: fixed; top: 1rem; right: 1rem; background: rgba(30,30,32,0.97); border: 1px solid var(--green); border-radius: 9px; padding: 11px 16px; font-size: 0.86rem; color: var(--cream); z-index: 999; box-shadow: var(--shadow); transform: translateX(120%); transition: transform 0.3s ease; max-width: 280px; }
  .toast.show { transform: translateX(0); }
  .toast strong {
    display: block;
    margin-bottom: 2px;
  }

  /* SCHMATZEE FLASH */
  .schmatzee-flash { position: fixed; inset: 0; background: rgba(60,179,113,0.18); pointer-events: none; z-index: 500; opacity: 0; }
  .schmatzee-flash.show { animation: flash 0.9s ease-out forwards; }
  @keyframes flash { 0%{opacity:1} 100%{opacity:0} }

  /* GAME OVER */
/* GAME OVER MODAL BASE STATE */
.game-over-modal {
  background: var(--panel);
  padding: 2rem;
  border-radius: 12px;
  text-align: center;

  min-width: 320px;
  max-width: 90vw;

  /* IMPORTANT: remove full-screen behavior */
  position: relative;
  width: auto;
  height: auto;

  display: block;
  z-index: auto;
}

/* ACTIVE STATE */
.game-over-modal.show {
  display: flex;
}

  .modal-box { background: var(--surface); border: 2px solid var(--green); border-radius: 14px; padding: 1.8rem; text-align: center; max-width: 340px; width: 90%; }
  .modal-box h2 { color: var(--green-lt); font-size: 1.7rem; margin-bottom: 0.5rem; }
  .final-scores { margin: 1rem 0; font-size: 0.86rem; }
  .final-score-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); }
  .final-score-row:last-child { border: none; }

  /* OPPONENT SCORECARDS */
  .opp-card { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 5px; overflow: hidden; background: rgba(0,0,0,0.15); }
  .opp-card-summary { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 4px; padding: 7px 10px; cursor: pointer; list-style: none; user-select: none; }
  .opp-card-summary::-webkit-details-marker { display: none; }
  .opp-card-summary::before { content: "▶"; font-size: 0.6rem; color: var(--muted); }
  details.opp-card[open] .opp-card-summary::before { content: "▼"; }
  .opp-card-name { font-size: 0.82rem; font-weight: 600; }
  .opp-card-score { font-size: 0.75rem; color: var(--muted); text-align: right; }
  .opp-card-body { padding: 4px 10px 8px; }
  .opp-section-hdr { font-size: 0.65rem; font-weight: 700; color: var(--green); letter-spacing: 0.8px; text-transform: uppercase; margin: 5px 0 2px; }
  .opp-row { display: grid; padding: 2px 0; align-items: center; }
  .opp-cat { font-size: 0.75rem; color: var(--cream-dk); }
  .opp-val { font-size: 0.75rem; text-align: right; color: var(--cream); font-weight: 500; }
  .opp-empty { color: var(--muted) !important; }
  .opp-zero { color: var(--muted) !important; }
  .opp-bonus { margin: 2px 0; }
  .opp-total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }

	.dice-panel {
	  display: flex;
	  flex-direction: column;
	  overflow: hidden;
	  align-self: start;
	}

	.dice-main-row {
	  height: 90px;
	  flex: 0 0 auto;
	  align-items: center;
	}

	.status-slot {
	  height: 28px;
	  display: flex;
	  align-items: center;
	  justify-content: center;
	  overflow: hidden;
	}

	.status-slot > div {
	  width: 100%;
	  text-align: center;
	}

	/* DIE STABLE BOX */
	.die {
	  width: 72px;
	  height: 72px;
	  border-radius: 8px;
	  cursor: pointer;
	  border: 3px solid transparent;
	  user-select: none;
	  overflow: hidden;
	  background: #3a3a3a;

	  display: grid;
	  place-items: center;

	  flex-shrink: 0;
	}

.status-slot {
  display: flex;
  align-items: center;
  justify-content: flex-start; /* IMPORTANT: stops global centering */
}

/* this holds your actual text */
.status-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* fake "roll button width" on the right */
.status-spacer {
  flex: 0 0 120px;
  width: 120px;
  min-width: 120px;
  max-width: 120px;
  height: 1px;
}

.game-over-modal .modal-box button {
  width: 100%;
  max-width: 220px; /* adjust if needed */
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.logo-wrap .game-title-text,
.logo-wrap .game-title-text span {
  font-family: "DM Sans", sans-serif;
}

#game-over-section .game-title-text {
  margin-bottom: 18px;
}

#game-over-section h2 {
  color: var(--green-lt);
  margin-bottom: 12px;
}

#game-over-modal {
  position: fixed;
  inset: 0;
  z-index: 999999;

  display: none;

  justify-content: center;
  align-items: center;

  /* CRITICAL: isolate from screen system */
  pointer-events: none;
}

#game-over-modal.show {
  display: flex;
  pointer-events: auto;
}

#game-over-modal.show {
  display: flex !important;
}

#game-over-section {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);

  display: flex;
  align-items: center;
  justify-content: center;

  z-index: 99999;
}

.game-over-modal {
  background: var(--panel, #222);
  color: var(--cream, white);
  padding: 2rem;
  border-radius: 12px;
  text-align: center;

  min-width: 320px;
  max-width: 90vw;

  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

#game-over-section .game-over-modal {
  display: block;
  background: var(--surface);
  border: 2px solid var(--green);
  border-radius: 14px;
  padding: 1.8rem;
  text-align: center;
  max-width: 340px;
  width: 90%; 
}

#game-over-section .game-over-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

#game-over-section .game-over-buttons .btn {
  width: 100%;
  margin: 0 !important;
  padding: 11px 22px !important;
  font-size: 0.97rem !important;
  box-sizing: border-box;
}

#game-over-section .btn-primary {
  width: 85%;
  margin: 0 auto;
}

.final-section-title {
  margin-top: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.final-section-title .title-text {
  color: var(--green);
}


  /* MOBILE */
  .mobile-score-tabs { display: flex; gap: 5px; margin-bottom: 7px; overflow-x: auto; padding-bottom: 3px; }
  .mobile-score-tab { background: rgba(0,0,0,0.25); border: 1px solid var(--border); border-radius: 20px; padding: 5px 12px; font-size: 0.74rem; white-space: nowrap; cursor: pointer; color: var(--cream-dk); flex-shrink: 0; }
  .mobile-score-tab.active { background: rgba(60,179,113,0.18); border-color: var(--green); color: var(--green-lt); }

  @media (max-width: 720px) {
    .game-layout { grid-template-columns: 1fr; }
    body { padding: 0.5rem; }
    .die { width: 58px; height: 58px; }
    .score-row { padding: 10px 5px; }
    .score-row.potential { padding: 12px 7px; min-height: 44px; }
    .cat-name { font-size: 0.86rem; }
  }
  @media (min-width: 721px) { .mobile-score-tabs { display: none; } }