/* Start screen (A1) and the popups (P0, P3). */

/* Every screen's heading sits right under the site title, centered. */
h2.screen-heading {
  text-align: center;
  font-size: 1.8em;
  font-weight: bold;
  margin: 0 0 0.8em;
}

#start {
  max-width: 560px;
  margin: 0 auto 1.5em;
  padding: 0 16px;
  font-family: 'Roboto', sans-serif;
}

#start .account {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5em 0.75em;
  margin-bottom: 1.25em;
}

#start .account-email {
  font-weight: bold;
}

#start .account-note {
  color: #666;
  font-size: 0.9em;
  width: 100%;
}

#start .start-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75em;
  margin: 0.9em 0;
}

#start button,
.popup button {
  padding: 0.5em 1em;
  border: 1px solid #bbb;
  border-radius: 5px;
  background: #eee;
  cursor: pointer;
  font-size: 0.95em;
}

#start button:disabled,
.popup button:disabled {
  cursor: default;
  color: #aaa;
}

#start select {
  padding: 0.35em;
  font-size: 0.95em;
}

#start .temporary {
  margin-top: 2em;
  color: #666;
  font-size: 0.9em;
}

button.link-button,
#start button.link-button,
.popup button.link-button {
  border: none;
  background: none;
  padding: 0;
  color: #2a6ebb;
  text-decoration: underline;
  cursor: pointer;
  font-size: inherit;
}

#start button.link-button.strong {
  font-weight: bold;
}

.form-error {
  color: #c62828;
  margin: 0.5em 0;
}

.form-message {
  color: #2e7d32;
  margin: 0.5em 0;
}

/* Popups: dimmed backdrop; clicking it closes the popup. */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.popup {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
  width: min(400px, calc(100vw - 32px));
  font-family: 'Roboto', sans-serif;
}

.popup-title {
  padding: 0.7em 1em;
  background: #f0f0f0;
  border-radius: 8px 8px 0 0;
  font-weight: bold;
  cursor: move;
  user-select: none;
  touch-action: none;
}

.popup-body {
  padding: 1em;
}

.login-form label {
  display: block;
  margin-bottom: 0.8em;
  font-size: 0.9em;
  color: #444;
}

.login-form input[type='email'],
.login-form input[type='password'],
.login-form input[type='text'] {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-top: 0.25em;
  padding: 0.45em;
  font-size: 1em;
}

.login-form label.check {
  display: flex;
  align-items: center;
  gap: 0.4em;
}

.login-form .password-field {
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.login-form .password-field input {
  flex: 1;
}

.login-form .button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  margin-top: 0.8em;
}

.login-form .button-row.secondary button {
  font-size: 0.85em;
}

/* Login stands out on its own row; Close sits centered at the bottom.
   (#start in the selector so it outranks the Start screen's gray buttons.) */
#start .popup button.login-button,
.popup button.login-button {
  padding: 0.5em 2em;
  background: crimson;
  border-color: #a50e2d;
  color: #fff;
  font-weight: bold;
}

#start .popup button.login-button:hover,
.popup button.login-button:hover {
  background: #c8102e;
}

#start .popup button.login-button:disabled,
.popup button.login-button:disabled {
  opacity: 0.6;
  color: #fff;
}

.login-form .button-row.login-row {
  justify-content: center;
}

.login-form .button-row.close-row {
  justify-content: center;
}

/* The other Login popup buttons: a lighter teal than Join Video Session, centered. */
.login-form .button-row.secondary {
  justify-content: center;
}

#start .popup .login-form .button-row.secondary button,
.popup .login-form .button-row.secondary button {
  background: #4fb3cf;
  border-color: #3a9cb8;
  color: #fff;
}

#start .popup .login-form .button-row.secondary button:hover:not(:disabled),
.popup .login-form .button-row.secondary button:hover:not(:disabled) {
  filter: brightness(1.1);
}

.popup .login-form .button-row.secondary button:disabled {
  opacity: 0.6;
}

/* Create Game (B1) and Modify Game (B2). */

#ruleset-screen {
  max-width: 960px; /* wide enough for the Out of Time sound line */
  margin: 0 auto 3em;
  padding: 0 16px;
  font-family: 'Roboto', sans-serif;
}

#ruleset-screen .description-field {
  display: flex;
  align-items: center;
  gap: 0.5em;
}

#ruleset-screen .description-field input {
  flex: 1;
}

#ruleset-screen button,
.popup.wide button {
  padding: 0.5em 1em;
  border: 1px solid #bbb;
  border-radius: 5px;
  background: #eee;
  cursor: pointer;
  font-size: 0.95em;
}

#ruleset-screen button.primary {
  background: #dfeedd;
  border-color: #8bb67f;
}

#ruleset-screen button:disabled {
  cursor: default;
  color: #aaa;
  background: #f4f4f4;
  border-color: #ddd;
}

#ruleset-screen .form-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.6em 1em;
  align-items: center;
  margin: 1em 0;
}

#ruleset-screen .form-grid label {
  color: #444;
  text-align: right;
}

#ruleset-screen input,
#ruleset-screen select {
  padding: 0.4em;
  font-size: 0.95em;
  box-sizing: border-box;
}

#ruleset-screen .form-grid > input {
  width: 100%;
}

#ruleset-screen input.short {
  width: 5em;
}

#ruleset-screen .copy-row {
  display: flex;
  gap: 0.5em;
}

#ruleset-screen .or-divider {
  display: flex;
  align-items: center;
  gap: 1em;
  color: #888;
  margin: 1.2em 0;
}

#ruleset-screen .or-divider::before,
#ruleset-screen .or-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid #ddd;
}

.hint,
.form-hint {
  color: #777;
  font-size: 0.85em;
}

.form-hint {
  margin: 0.5em 0;
}

.players-table {
  border-collapse: collapse;
  margin: 1em 0;
  width: 100%;
}

.players-table th {
  text-align: left;
  font-weight: normal;
  color: #444;
  padding: 0 0.4em 0.3em 0;
}

.players-table td {
  padding: 0.15em 0.4em 0.15em 0;
}

.players-table input {
  width: 100%;
}

#ruleset-screen .form-section {
  margin: 1.2em 0;
}

#ruleset-screen .section-label {
  color: #333;
  font-weight: bold;
  margin-bottom: 0.3em;
}

.wordlist-picker {
  margin-top: 0 !important;
}

#ruleset-screen .check {
  display: flex;
  align-items: center;
  gap: 0.4em;
}

#ruleset-screen .button-row {
  display: flex;
  gap: 0.6em;
  margin-top: 1em;
}

/* Delete (B2) sits apart from Save and Cancel, at the right. */
#ruleset-screen .button-row button.delete-game,
#ruleset-screen .button-row button.restore-game {
  margin-left: auto;
}

#ruleset-screen .button-row button.delete-game {
  color: #b00020;
}

@media (max-width: 520px) {
  #ruleset-screen .form-grid {
    grid-template-columns: 1fr;
  }
  #ruleset-screen .form-grid label {
    text-align: left;
  }
}

/* Change Vocabulary (P2). */

.popup.wide {
  width: min(640px, calc(100vw - 32px));
}

.vocabulary .vocab-search {
  display: flex;
  gap: 0.5em;
  align-items: center;
}

.vocabulary input {
  padding: 0.4em;
  font-size: 0.95em;
}

.vocabulary .vocab-letters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2em;
  align-items: center;
  margin: 0.7em 0;
}

.vocabulary .vocab-letters .hint {
  margin-right: 0.4em;
}

.popup.wide .vocab-letters button.letter {
  padding: 0.15em 0.4em;
  min-width: 1.8em;
  font-size: 0.85em;
}

/* The chosen starting letter: bold blue text, like the selected list in
   Examine Word Lists (#ruleset-screen outranks the general gray button rule). */
#ruleset-screen .vocab-letters button.letter.active,
.popup.wide .vocab-letters button.letter.active {
  font-weight: bold;
  color: #1f5fa8;
  border-color: #1f5fa8;
  background: #eef4fb;
}

.vocabulary .vocab-add {
  display: block;
  font-size: 0.9em;
  color: #444;
}

.vocabulary .vocab-add input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-top: 0.25em;
}

.vocabulary .vocab-count {
  margin: 0.7em 0 0.3em;
}

.vocabulary .vocab-list {
  max-height: 45vh;
  overflow-y: auto;
  border: 1px solid #ddd;
}

.vocabulary table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9em;
}

.vocabulary th {
  position: sticky;
  top: 0;
  background: #f4f4f4;
  text-align: left;
  font-weight: normal;
  padding: 0.3em 0.6em;
}

.vocabulary td {
  padding: 0.2em 0.6em;
  border-top: 1px solid #eee;
}

.vocabulary .button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  margin-top: 0.8em;
}

/* The "?" next to Team Assignment Mode (B1/B2). */
#ruleset-screen button.help-button {
  width: 1.6em;
  height: 1.6em;
  padding: 0;
  border-radius: 50%;
  font-weight: bold;
  line-height: 1;
  cursor: pointer;
}

.team-mode-help {
  padding-left: 1.3em;
  line-height: 1.4;
}

.team-mode-help li {
  margin-bottom: 0.6em;
}

/* The two Join buttons stand out: green for the game, teal for the video
   call. (#start in the selectors so they outrank the gray buttons above.) */
#start button.join-session,
#start button.join-video {
  border: none;
  color: #fff;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

#start button.join-session {
  background: #2e9e4f;
}

#start button.join-video {
  background: #1a8fb0;
}

#start button.join-session:hover:not(:disabled),
#start button.join-video:hover:not(:disabled) {
  filter: brightness(1.1);
}

#start button.join-session:disabled,
#start button.join-video:disabled {
  opacity: 0.45;
  box-shadow: none;
  color: #fff;
}

/* Rename (B2), right under the centered title. */
#ruleset-screen .rename-row {
  text-align: center;
  margin: -0.3em 0 0.8em;
}

.rename-form .rename-input {
  margin-left: 0.3em;
  padding: 0.35em;
  font-size: 1em;
  width: 14em;
}

/* Copy From errors (e.g. a duplicate name) appear right under the dropdown. */
#ruleset-screen .copy-error {
  margin: -0.2em 0 0;
}

.login-form .phone-note {
  margin: -0.4em 0 0.8em;
  font-size: 0.85em;
}

/* Examine Word Lists (B1/B2): button beside the section label, and the popup. */
#ruleset-screen .section-label .examine-button {
  margin-left: 0.6em;
  font-weight: normal;
  font-size: 0.85em;
}

.examine-lists .examine-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3em;
  margin-bottom: 0.5em;
}

.popup.wide .examine-lists button.examine-list {
  padding: 0.2em 0.5em;
  font-size: 0.85em;
}

/* The list being shown: bold blue text (#ruleset-screen outranks the
   general gray button rule). */
#ruleset-screen .examine-lists button.examine-list.active,
.popup.wide .examine-lists button.examine-list.active {
  font-weight: bold;
  color: #1f5fa8;
  border-color: #1f5fa8;
  background: #eef4fb;
}

.examine-lists .vocab-search {
  margin-top: 0.4em;
}

/* Exactly three columns (the first, middle and last third of the words),
   scrolling vertically together. */
.examine-lists .examine-words {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 1.2em;
  align-items: start;
  padding: 0.4em 0.6em;
  min-height: 6em;
}

.examine-lists .examine-column > div {
  padding: 0.05em 0;
  overflow-wrap: anywhere;
}

/* Required-field asterisks (B1/B2). */
#ruleset-screen .required {
  color: #d00000;
  font-weight: bold;
}

/* B2 sound file rows: Default/Custom, Play, Load file, Restore Default, ?. */
#ruleset-screen .sound-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4em;
}

#ruleset-screen .sound-row button {
  padding: 0.2em 0.5em;
  font-size: 0.8em;
  white-space: nowrap;
}

#ruleset-screen .sound-row button.help-button {
  padding: 0;
}

#ruleset-screen .sound-status {
  min-width: 4em;
  font-weight: bold;
}

#ruleset-screen .sound-error {
  margin: -0.4em 0 0;
}

/* Each sound's controls stay on one line where there is room. */
@media (min-width: 1000px) {
  #ruleset-screen .sound-row {
    flex-wrap: nowrap;
    white-space: nowrap;
  }
}

/* Create Game and Modify Game: blue (brighter than the gray default,
   distinct from the green/teal Join buttons). */
#start button.create-game,
#start button.modify-game,
#start button.info-button {
  border: none;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

#start button.create-game,
#start button.modify-game {
  color: #fff;
}

#start button.create-game {
  background: #2f6fd6;
}

#start button.modify-game {
  background: #2f6fd6;
}

/* Information row: a soft amber, with dark text for readability. */
#start .info-row {
  align-items: center;
}

#start .info-label {
  font-weight: bold;
  color: #555;
  margin-right: 0.2em;
}

#start button.info-button {
  background: #e9c46a;
  color: #2b1d00;
}

#start button.create-game:hover:not(:disabled),
#start button.modify-game:hover:not(:disabled),
#start button.info-button:hover {
  filter: brightness(1.1);
}

#start button.create-game:disabled,
#start button.modify-game:disabled {
  opacity: 0.45;
  box-shadow: none;
  color: #fff;
}

/* Getting Started / How to Play text. */
.info-text {
  max-height: 60vh;
  overflow-y: auto;
  line-height: 1.45;
  padding-right: 0.4em;
}

.info-text h3 {
  margin: 1em 0 0.3em;
  font-size: 1.05em;
}

.info-text p {
  margin: 0.4em 0;
}

.info-text li {
  margin-bottom: 0.4em;
}

/* Volume slider on each B2 sound line. */
#ruleset-screen .sound-volume {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
}

#ruleset-screen .sound-volume input[type='range'] {
  width: 5em;
}

#ruleset-screen .sound-volume-value {
  min-width: 2.6em;
  font-size: 0.85em;
  color: #555;
}

/* Out of Time: Repeat Sound, Every __ Seconds. */
#ruleset-screen .sound-repeat {
  display: inline-flex;
  align-items: center;
  gap: 0.2em;
  margin-left: 0.2em;
  font-size: 0.9em;
}

#ruleset-screen .sound-repeat label.check {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
}

#ruleset-screen .sound-repeat input.short {
  width: 3.5em;
  padding: 0.2em;
}

/* Admin button on Start: red, set apart from Create/Modify Game. */
#start button.admin-button {
  margin-left: 2em;
  border: none;
  font-weight: bold;
  color: #fff;
  background: #c62828;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

#start button.admin-button:hover {
  filter: brightness(1.1);
}

/* Admin page. */
#admin-screen {
  max-width: 820px;
  margin: 0 auto 3em;
  padding: 0 16px;
  font-family: 'Roboto', sans-serif;
}

#admin-screen .admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3em;
  border-bottom: 2px solid #c62828;
}

#admin-screen button {
  padding: 0.45em 1em;
  border: 1px solid #bbb;
  border-radius: 5px;
  background: #eee;
  font-size: 0.95em;
  cursor: pointer;
}

#admin-screen button.admin-tab {
  border-bottom: none;
  border-radius: 6px 6px 0 0;
}

#admin-screen button.admin-tab.active {
  background: #c62828;
  border-color: #c62828;
  color: #fff;
  font-weight: bold;
}

#admin-screen .admin-panel {
  padding: 1em 0;
}

#admin-screen .admin-info {
  border-collapse: collapse;
  margin-bottom: 1.2em;
}

#admin-screen .admin-info th {
  text-align: left;
  font-weight: normal;
  color: #555;
  padding: 0.15em 1.5em 0.15em 0;
}

#admin-screen .admin-actions > div {
  display: flex;
  align-items: center;
  gap: 0.8em;
  margin-bottom: 0.7em;
}

#admin-screen .admin-actions button {
  min-width: 11em;
}

#admin-screen button.danger {
  color: #b00020;
  font-weight: bold;
}

#admin-screen button:disabled {
  cursor: default;
  color: #aaa;
}

/* Admin stats tables. */
#admin-screen .admin-stats {
  border-collapse: collapse;
  width: 100%;
}

#admin-screen .admin-stats th,
#admin-screen .admin-stats td {
  text-align: left;
  vertical-align: top;
  padding: 0.35em 0.8em 0.35em 0;
  border-bottom: 1px solid #eee;
}

#admin-screen .admin-stats th {
  font-weight: normal;
  color: #444;
}

#admin-screen .admin-stats td.stat-number {
  color: #999;
  width: 2em;
}

/* Vocabulary Stats decile table. */
#admin-screen .admin-deciles {
  border-collapse: collapse;
  margin: 0.5em 0 1em;
}

#admin-screen .admin-deciles th,
#admin-screen .admin-deciles td {
  padding: 0.3em 1.2em;
  border-bottom: 1px solid #eee;
  text-align: right;
}

#admin-screen .admin-deciles thead th {
  border-bottom: 2px solid #ccc;
  font-weight: bold;
}

#admin-screen .admin-deciles tbody th {
  text-align: center;
  font-weight: normal;
  color: #555;
}

#admin-screen .admin-deciles tr.totals th,
#admin-screen .admin-deciles tr.totals td {
  border-top: 2px solid #ccc;
  font-weight: bold;
}

/* Waiting Room: Join Video Session about half a button's width past Begin Game. */
#start button.join-video.waiting-video {
  margin-left: 3.5em;
}

/* Join Video Session popup: three radio choices, one per line. */
.video-choices {
  min-width: 18em;
}

.video-choices .video-choice {
  display: block;
  margin: 0.45em 0;
  cursor: pointer;
}

.video-choices .button-row {
  gap: 0.6em;
}
