body {
  font-family: Arial, sans-serif;
  background: #0f172a;
  color: white;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #0f172a;
  z-index: 9999;
}

.login-box {
  background: #1e293b;
  padding: 24px;
  border-radius: 16px;
  width: 320px;
  max-width: 90%;
  text-align: center;
}

.loginLogo {
  width: 40px !important;
  height: 40px !important;
  object-fit: contain;
  display: block;
  margin: 0 auto 12px auto;
}

.login-box h1 {
  margin: 0 0 20px;
  font-size: 22px;
}

.loginStack {
  width: 380px;
  max-width: 94vw;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.registration-box {
  order: 1;
}

.admin-login-box {
  order: 2;
}

.login-box {
  width: 100%;
}

.registration-box .hint {
  text-align: center;
  margin: -6px 0 14px;
}

#appPage {
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.topbar {
  background: #111827;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topLogo {
  width: 22px !important;
  height: 22px !important;
  object-fit: contain;
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: #1e293b;
  flex-wrap: wrap;
}

.tabBtn {
  padding: 10px 14px;
  background: #334155;
  border: none;
  border-radius: 10px;
  color: white;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
}

.tabBtn:hover {
  opacity: 0.9;
}

.tabBtn.active {
  background: #22c55e;
}

.tabContent {
  display: none;
  padding: 20px;
  max-width: 100%;
  overflow-x: hidden;
}

.tabContent.active {
  display: block;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.card {
  background: #1e293b;
  padding: 18px;
  border-radius: 16px;
  margin-bottom: 20px;
  max-width: 100%;
  overflow-x: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.card h2,
.card h3,
.card h4 {
  margin-top: 0;
}

input,
select,
textarea,
button {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 12px;
  margin: 8px 0;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  box-sizing: border-box;
}

input,
select,
textarea {
  background: white;
  color: #111827;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

button {
  background: #22c55e;
  color: white;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
}

button:hover {
  opacity: 0.92;
}

.deleteBtn {
  background: #dc2626;
}

.scrollBox {
  max-height: 350px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid #334155;
  padding: 10px;
  border-radius: 12px;
  margin-top: 10px;
  background: #0f172a;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid #334155;
}

.actionBtns {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.actionBtns button {
  flex: 1;
  min-width: 120px;
}

hr {
  border: none;
  border-top: 1px solid #334155;
  margin: 20px 0;
}

/* PLAYER QR */
#playerQR {
  margin: 20px auto;
  display: flex;
  justify-content: center;
  align-items: center;
  background: white;
  padding: 12px;
  border-radius: 16px;
  width: fit-content;
}

#playerQR img,
#playerQR canvas {
  display: block;
  max-width: 100%;
}

/* QR SCANNER MODAL */
#qrScannerModal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.95);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#qrScannerModal.hidden {
  display: none !important;
}

#qr-reader {
  width: 100%;
  max-width: 420px;
  background: white;
  border-radius: 16px;
  padding: 10px;
  overflow: hidden;
}

/* html5-qrcode fixes */
#qr-reader video {
  width: 100% !important;
  border-radius: 12px;
}

#qr-reader__dashboard {
  color: black !important;
}

#qr-reader__dashboard_section {
  color: black !important;
}

#qr-reader__status_span {
  color: black !important;
}

#qr-reader button {
  background: #22c55e !important;
  color: white !important;
  border-radius: 10px;
  border: none;
}

/* PRINT AREA */
#printArea {
  background: white;
  color: black;
  padding: 24px;
  text-align: center;
}

#printArea h2,
#printArea h3,
#printArea p {
  color: black;
}

/* INSTALL BUTTON */
#installBtn {
  width: auto;
  padding: 10px 16px;
}

/* MOBILE */
@media screen and (max-width: 480px) {
  .titleIcon { margin-right: 5px; }

  .login-box {
    width: 92%;
    padding: 20px;
  }

  .loginLogo {
    width: 36px !important;
    height: 36px !important;
  }

  .topLogo {
    width: 20px !important;
    height: 20px !important;
  }

  .topbar h1 {
    font-size: 15px;
  }

  .tabBtn {
    font-size: 13px;
    padding: 8px 10px;
    flex: 1;
    min-width: 90px;
  }

  .tabContent {
    padding: 12px;
  }

  input,
  select,
  textarea,
  button {
    font-size: 14px;
    padding: 10px;
  }

  .row {
    flex-wrap: wrap;
  }

  .actionBtns button {
    width: 100%;
    min-width: unset;
  }

  #qr-reader {
    max-width: 100%;
  }
}
/* PATCH: dashboard/payment/attendance improvements */
.bigNumber {
  display: block;
  font-size: 42px;
  font-weight: 800;
  margin-top: 8px;
}

.topActions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.topActions button,
.secondaryBtn {
  width: auto;
  padding: 10px 14px;
  margin: 0;
}

.secondaryBtn {
  background: #475569;
}

.hint {
  color: #cbd5e1;
  font-size: 13px;
  margin-top: -4px;
}

.innerCard {
  background: #0f172a;
  border: 1px solid #334155;
  margin-top: 14px;
}

.miniCard {
  margin: 8px 0;
  padding: 12px;
  background: #111827;
  border: 1px solid #334155;
}

.miniCard small {
  color: #cbd5e1;
}

label {
  display: block;
  margin-top: 10px;
  font-size: 13px;
  color: #cbd5e1;
  font-weight: bold;
}

.scanStatus {
  margin: 12px 0;
  padding: 10px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 12px;
  text-align: center;
  font-weight: bold;
}

.scannerCard {
  width: 460px;
  max-width: 100%;
}

#attendanceList input[type="checkbox"] {
  width: 24px;
  height: 24px;
  margin: 0;
}

@media screen and (max-width: 480px) {
  .titleIcon { margin-right: 5px; }

  .topActions {
    width: 100%;
    margin-top: 10px;
  }

  .topActions button {
    flex: 1;
  }
}

.topActions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.topActions button,
.smallBtn,
.xBtn {
  width: auto;
}

.secondaryBtn {
  background: #475569;
}

.bigNumber {
  font-size: 42px;
  font-weight: 800;
}

.hint {
  color: #cbd5e1;
  font-size: 13px;
  margin-top: -4px;
}

.innerCard {
  background: #0f172a;
  border: 1px solid #334155;
  margin-top: 14px;
}

.miniCard {
  background: #111827;
  border: 1px solid #334155;
  margin-bottom: 10px;
}

.checkRow,
.entryLine {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid #334155;
}

.checkRow input[type="checkbox"] {
  width: 24px;
  height: 24px;
  margin: 0;
  flex: 0 0 auto;
}

.entryMain {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.xBtn {
  background: #dc2626;
  border-radius: 999px;
  width: 34px;
  height: 34px;
  padding: 0;
  margin: 0;
  font-size: 22px;
  line-height: 1;
  flex: 0 0 auto;
}

.smallBtn {
  background: #2563eb;
  padding: 8px 10px;
  margin: 0;
  border-radius: 10px;
  flex: 0 0 auto;
}

.pill {
  display: inline-block;
  background: #22c55e;
  color: #052e16;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 800;
}

label {
  display: block;
  color: #cbd5e1;
  font-weight: bold;
  margin-top: 8px;
}

@media screen and (max-width: 480px) {
  .titleIcon { margin-right: 5px; }

  .topActions {
    width: 100%;
    margin-top: 8px;
  }

  .topActions button {
    flex: 1;
  }

  .entryLine {
    align-items: flex-start;
  }
}


/* MOBILE WIDTH FIX - prevent left/right scrolling and pinch-to-fit */
html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden !important;
}

body {
  position: relative;
}

img, video, canvas, svg, table, iframe {
  max-width: 100% !important;
}

#appPage,
.topbar,
.tabs,
.tabContent,
.card,
.scrollBox,
.row,
.checkRow,
.entryLine,
.innerCard,
.miniCard {
  max-width: 100% !important;
  overflow-x: hidden !important;
}

.brand,
.topActions,
.tabs,
.row,
.checkRow,
.entryLine {
  min-width: 0;
}

.brand h1,
.row span,
.entryMain,
.checkRow span,
.miniCard,
.card,
p,
small,
strong,
label,
h1,
h2,
h3 {
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media screen and (max-width: 600px) {
  body {
    width: 100vw;
  }

  .topbar {
    padding: 10px;
    align-items: flex-start;
  }

  .brand {
    width: 100%;
  }

  .brand h1 {
    font-size: 15px;
  }

  .topActions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .topActions button,
  .secondaryBtn {
    width: 100%;
    min-width: 0;
    padding: 9px 6px;
    font-size: 12px;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
  }

  .tabBtn {
    width: 100%;
    min-width: 0 !important;
    padding: 10px 6px;
    font-size: 13px;
  }

  .tabContent {
    padding: 10px;
  }

  .card {
    padding: 12px;
    border-radius: 14px;
  }

  .cards {
    grid-template-columns: 1fr !important;
  }

  input,
  select,
  textarea,
  button {
    width: 100% !important;
    min-width: 0 !important;
    font-size: 14px;
  }

  .row,
  .checkRow,
  .entryLine {
    gap: 8px;
  }

  .checkRow input[type="checkbox"],
  #attendanceList input[type="checkbox"] {
    width: 22px !important;
    height: 22px !important;
    flex: 0 0 22px;
  }

  .smallBtn,
  .xBtn {
    flex: 0 0 auto;
  }

  #qr-reader {
    width: 100% !important;
    max-width: 100% !important;
  }

  .scannerCard {
    width: 100% !important;
  }
}


/* LATEST MOBILE HISTORY FIX - iPhone friendly attendance/payment entries */
#attendanceHistory,
#paymentsList {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden !important;
}

#attendanceHistory .entryLine,
#paymentsList .entryLine {
  width: 100%;
  max-width: 100%;
}

#attendanceHistory .entryMain,
#paymentsList .entryMain {
  min-width: 0;
  max-width: 100%;
}

#attendanceHistory small,
#paymentsList small,
#attendanceHistory span,
#paymentsList span,
#attendanceHistory strong,
#paymentsList strong {
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media screen and (max-width: 600px) {
  #attendanceHistory,
  #paymentsList {
    padding: 8px;
  }

  #attendanceHistory .entryLine,
  #paymentsList .entryLine {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 8px;
    padding: 10px 8px;
  }

  #attendanceHistory .xBtn {
    justify-self: end;
  }

  #paymentsList .smallBtn {
    width: 100% !important;
    justify-self: stretch;
    margin-top: 4px;
  }

  #paymentsList .pill {
    margin-top: 4px;
  }
}

.fileLabel {
  display: block;
  margin: 10px 0 2px;
  font-size: 13px;
  font-weight: 700;
  color: #cbd5e1;
}

input[type="file"] {
  background: #f8fafc;
  color: #111827;
  padding: 10px;
}

.photoPreviewWrap {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 10px 0;
}

.photoPreview {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  object-fit: cover;
  background: white;
  border: 4px solid #334155;
}

.titleIcon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  font-size: 1.05em;
  line-height: 1;
}

.tabBtn .titleIcon {
  margin-right: 6px;
}

.card h2,
.card h3 {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Add player form hidden by default + public registration form */
.addPlayerForm,
.publicRegisterForm {
  margin-top: 10px;
}

.publicRegisterForm {
  text-align: left;
  border-top: 1px solid #334155;
  padding-top: 14px;
  max-height: 72vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.publicRegisterForm h2 {
  text-align: center;
  font-size: 18px;
  margin: 0 0 12px;
}

.secondaryBtn {
  background: #475569 !important;
}

.fileLabel {
  display: block;
  margin: 8px 0 2px;
  font-size: 13px;
  font-weight: bold;
  color: #dbeafe;
}

@media screen and (max-width: 600px) {
  .screen {
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 0;
  }

  .loginStack {
    width: 94vw;
    max-width: 94vw;
    margin: 0 auto;
  }

  .login-box {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
  }

  .publicRegisterForm {
    max-height: none;
    overflow-y: visible;
  }
}

/* PHOTO CROP MODAL */
#photoCropModal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.96);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

#photoCropModal.hidden {
  display: none !important;
}

.cropCard {
  width: min(430px, 96vw);
  max-height: 96vh;
  overflow-y: auto;
}

.cropCanvasWrap {
  position: relative;
  width: min(320px, 82vw);
  height: min(320px, 82vw);
  margin: 12px auto;
  background: #111827;
  overflow: hidden;
  border-radius: 16px;
}

#photoCropCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.cropCircleGuide {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(15, 23, 42, 0.42);
  border: 3px solid #22c55e;
  pointer-events: none;
}

#photoCropModal label {
  display: block;
  margin-top: 10px;
  font-weight: 700;
}

#photoCropModal input[type="range"] {
  padding: 0;
  background: transparent;
}

/* Pending registration dashboard */
.pendingCard {
  border: 1px solid rgba(250, 204, 21, 0.45);
}

.pendingList {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.pendingItem {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 10px;
}

.pendingInfo {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.pendingInfo strong,
.pendingInfo span {
  overflow-wrap: anywhere;
}

.pendingMscId {
  margin: 0;
}

.pendingActions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.smallBtn {
  padding: 9px 10px;
  margin: 0;
  font-size: 13px;
}

/* Player Management history section */
.playerHistoryGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.playerHistoryBox {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 14px;
  padding: 12px;
  min-width: 0;
}

.playerHistoryBox h3 {
  font-size: 16px;
  margin: 0 0 10px;
}

.miniHistoryList {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.miniHistoryItem {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 10px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.miniHistoryItem small {
  color: #cbd5e1;
}

@media screen and (max-width: 480px) {
  .playerHistoryGrid {
    grid-template-columns: 1fr;
  }
  .miniHistoryList {
    max-height: none;
  }
}

/* Parent Portal */
.parent-portal-box { order: 2; }
.admin-login-box { order: 3; }
.parentSummary { margin: 10px 0 14px; }
.parentPlayerCard {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 14px;
  padding: 10px;
  text-align: left;
}
.parentPlayerCard img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: white;
  flex: 0 0 auto;
}
.parentPlayerCard strong { font-size: 15px; }
.parentPlayerCard small { color: #cbd5e1; line-height: 1.5; }
#parentPortalPanel h3 {
  margin: 18px 0 6px;
  font-size: 16px;
  text-align: left;
  color: #e2e8f0;
}
.paymentPendingItem .pendingActions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media screen and (max-width: 520px) {
  .screen {
    align-items: flex-start;
    overflow-y: auto;
    padding: 14px 0;
  }
  .loginStack { max-width: 94vw; }
  .paymentPendingItem .pendingActions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .parentPlayerCard {
    align-items: flex-start;
  }
}

/* Front page welcome + portal footer */
.frontWelcome {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid #334155;
  border-radius: 18px;
  padding: 22px 18px;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.28);
}
.welcomeLogo {
  width: 82px;
  height: 82px;
  object-fit: contain;
  display: block;
  margin: 0 auto 10px;
}
.frontWelcome h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}
.frontWelcome p {
  margin: 8px 0 0;
  color: #facc15;
  font-weight: 800;
  letter-spacing: 0.3px;
  font-size: 17px;
}
.historyLimitNote {
  display: inline-block;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 500;
  margin-left: 4px;
}
.portalFooter {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid #334155;
  color: #94a3b8;
  font-size: 12px;
  text-align: center;
}
@media screen and (max-width: 520px) {
  .frontWelcome { padding: 18px 14px; }
  .welcomeLogo { width: 72px; height: 72px; }
  .frontWelcome h1 { font-size: 20px; }
  .frontWelcome p { font-size: 15px; }
}


/* Main front page alignment/footer fix */
.frontWelcome {
  width: 100%;
  max-width: 100%;
  padding: 24px;
  border-radius: 16px;
}
.mainFooter {
  width: 100%;
  margin: 2px 0 0;
  padding: 12px 8px 4px;
  color: #94a3b8;
  font-size: 12px;
  text-align: center;
}
.miniHistoryList {
  min-height: 42px;
}
@media screen and (min-width: 700px) {
  .loginStack {
    width: 380px;
  }
  .frontWelcome,
  .login-box {
    width: 100%;
  }
}
@media screen and (max-width: 520px) {
  .frontWelcome {
    padding: 18px 14px;
  }
  .mainFooter {
    font-size: 11px;
    padding-bottom: 10px;
  }
}


/* Final front page sizing + footer placement fix */
.screen {
  align-items: flex-start;
  overflow-y: auto;
  padding: 0;
}
.loginStack {
  width: 380px;
  max-width: 94vw;
  min-height: 100svh;
  padding: 32px 0 16px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.frontWelcome,
.login-box {
  width: 100% !important;
  max-width: 100% !important;
}
.frontWelcome {
  order: 0;
  background: #1e293b;
  border: 1px solid #334155;
  padding: 24px;
  border-radius: 16px;
}
.registration-box { order: 1; }
.parent-portal-box { order: 2; }
.admin-login-box { order: 3; }
.mainFooter {
  order: 99;
  width: 100%;
  margin-top: auto;
  padding: 18px 8px 4px;
  color: #94a3b8;
  font-size: 12px;
  text-align: center;
}
.appFooter {
  width: 100%;
  padding: 18px 10px 24px;
  color: #94a3b8;
  font-size: 12px;
  text-align: center;
}
.portalFooter {
  display: none;
}
@media screen and (max-width: 520px) {
  .loginStack {
    width: 94vw;
    padding: 18px 0 14px;
  }
  .frontWelcome,
  .login-box {
    width: 100% !important;
    max-width: 100% !important;
  }
  .mainFooter,
  .appFooter {
    font-size: 11px;
  }
}

.featureIcon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px auto;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.14);
  font-size: 28px;
  line-height: 1;
}

.welcomeLogo,
.loginLogo,
.topLogo {
  background: transparent !important;
  mix-blend-mode: normal;
}
