/* Global box-sizing */
* {
  box-sizing: border-box;
}

/* Base Styling */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: Arial, sans-serif;
  background: #f9f9f9;
  text-align: center;
  font-size: 16px;
}

/* Spacer Cell */
.spacer-cell {
  border: 1px solid #000;
  padding: 4px;
  height: 3px;
  background: #f0f0f0;
}

/* Buttons */
button {
  font-size: 20px;
  padding: 6px 12px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-family: Arial, sans-serif;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #ccc;
  color: #666;
}
.difficulty-btn.TopTen,
.difficulty-btn.FastestPlayers,
.difficulty-btn.LeastRestarts,
.difficulty-btn.MedalCount {
  font-size: 18px;
  background: gold;
  font-weight: bold;
  color: black;
}
.difficulty-btn.TopTen:disabled,
.difficulty-btn.MedalCount:disabled {
  opacity: 1.0;
  background: gold;
  color: black;
}

/* Medal Count Button */
.medal-count-btn {
  font-size: 18px;
  background: #ff4500;
  color: white;
  font-weight: bold;
  border: 1px solid #000;
  border-radius: 5px;
  padding: 6px 12px;
  cursor: pointer;
}
.medal-count-btn:hover {
  background: #ff6347;
}

/* Top Data Popup */
.top-data {
  position: fixed;
  background: #777;
  border: 2px solid #000;
  z-index: 1000;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  text-align: center;
  font-family: Arial, sans-serif;
  font-size: 16px;
  width: 100%;
  max-width: 100vw;
  max-height: 99vh;
  overflow-y: auto;
  border-radius: 8px;
  top: 15px;
  left: 0;
  transform: none;
  padding: 12px;
  box-sizing: border-box;
  position: relative;
}
.top-data::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('fullhouse.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.5;
  z-index: -1;
}
.top-data h1 {
  background: gold;
  font-weight: bold;
  border: 2px solid #000;
  border-radius: 5px;
  padding: 8px 16px;
  margin: 8px auto;
  display: inline-block;
  font-size: 24px;
  color: black;
}
.top-data h2 {
  font-size: 18px;
  margin: 0 8px;
  display: inline-block;
  vertical-align: middle;
  font-family: Arial, sans-serif;
}
.top-data p {
  font-size: 14px;
  margin: 8px 0;
}
.top-data table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 4px;
  background-color: #fff;
  overflow-x: auto;
  position: relative;
  z-index: 1;
}
.top-data th:not(:last-child),
.top-data td:not(:last-child) {
  border: 3px solid #000;
  padding: 3px;
  font-size: 18px;
}
.top-data th:last-child,
.top-data td:last-child {
  border: 3px solid #000;
  padding: 3px;
  font-size: 16px;
  white-space: nowrap;
}
.top-data th {
  background: mediumblue;
  color: white;
  font-weight: bold;
}
.top-data th.medal {
  font-size: 37px; /* Medal emojis at 37px */
}
.top-data tr:hover {
  background: #e8f4f8;
}
.bold-row {
  font-weight: bold;
  background: #e6e6fa;
  color: #000;
}
.top-data td.when-played-just-now {
  background: #000;
  color: #FFD700;
}
.top-data td.when-played-minutes {
  background: #98FB98;
}
.top-data td.when-played-hours {
  background: #ADD8E6;
}
.top-data td.when-played-days {
  background: #FFFFE0;
}
.top-data td.when-played-months {
  background: #FFB6C1;
}
.top-data th:nth-child(3),
.top-data td:nth-child(3) {
  min-width: 80px;
}
.dropdown-row {
  background: mediumblue;
  font-weight: bold;
}
.dropdown-row td {
  border: 3px solid #000;
  padding: 6px;
  text-align: center;
}
.top-data .level-dropdown {
  font-size: 16px;
  padding: 6px 12px;
  border-radius: 5px;
  background: mediumblue;
  color: white;
  border: 1px solid #000;
  cursor: pointer;
  font-family: Arial, sans-serif;
  font-weight: bold;
  width: 100%;
  max-width: 350px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12"><polygon points="0,0 12,0 6,12" fill="black"/></svg>');
  background-repeat: no-repeat;
  background-position: 95% center;
  background-size: 12px;
}
.top-data .level-dropdown option {
  background: mediumblue;
  font-weight: bold;
  color: white;
  font-family: Arial, sans-serif;
  font-size: 16px;
}

.hidden {
  display: none;
}
.medal-count-btn.hidden {
  display: none;
}

.top-data .level-dropdown.hidden {
  display: none;
}
.all-levels-container {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 19999;
}

/* Medal Filter Buttons */
.medal-filters {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}
.medal-filters.hidden {
  display: none;
}
.medal-button-group {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.medal-filter-btn {
  font-size: 18px;
  padding: 6px 12px;
  border: 1px solid #000;
  border-radius: 5px;
  cursor: pointer;
  font-family: Arial, sans-serif;
  background: #333; /* Dark gray when OFF */
  color: white;
}
.medal-filter-btn.on {
  background: #FFD700; /* Bright gold when ON */
  color: black;
  font-weight: bold;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.8); /* Glow effect for stark contrast */
}

/* Selection Controls */
.selection-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  position: relative;
  z-index: 1;
}

/* Header and Dropdown Container */
.header-and-dropdown {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  position: relative;
  z-index: 1;
}
.level-dropdown option:disabled {
  color: #999999;
  background-color: #f0f0f0;
}

/* Style for the "All" row */
.top-data tr.all-row {
  background: #d3d3d3;
  font-weight: bold;
}

/* Seq Buttons in Table */
.play-btn,
.seq-btn {
  font-size: 18px;
  background: gold;
  font-weight: bold;
  color: black;
  border: 1px solid #808080;
  border-radius: 0;
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  display: block;
}
.play-btn:hover,
.seq-btn:hover {
  background: #ffcc00;
}
.seq-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Table Cells for Seq Buttons */
.top-data td:first-child {
  padding: 0;
  margin: 0;
  background: gold;
  border: 3px solid #000;
}

/* Ensure table rows have minimal height */
.top-data tr {
  height: auto;
}

/* Back Button */
.back-btn {
  font-size: 18px;
  background: mediumblue;
  color: white;
  font-weight: bold;
  border: 1px solid #000;
  border-radius: 5px;
  padding: 6px 12px;
  margin-top: 10px;
  cursor: pointer;
}
.back-btn:hover {
  background: #0000cc;
}

/* Desktop Media Query */
@media (min-width: 600px) {
  html { font-size: 18px; }
  .top-data {
    font-size: 16px;
    max-width: 500px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px;
    background: #777;
    position: relative;
  }
  .top-data::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('fullhouse.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.5;
    z-index: -1;
  }
  .top-data h1 {
    background: gold;
    border: 2px solid #000;
    border-radius: 5px;
    padding: 8px 16px;
    margin: 8px auto;
    font-size: 28px;
    color: black;
    font-weight: bold;
  }
  .top-data h2 {
    font-size: 28px;
  }
  .top-data p {
    font-size: 16px;
  }
  button { font-size: 20px; }
  .top-data .level-dropdown {
    font-size: 20px;
    padding: 6px 12px;
    background: mediumblue;
    color: white;
    font-weight: bold;
    border: 1px solid #000;
    width: 100%;
    max-width: 350px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12"><polygon points="0,0 12,0 6,12" fill="black"/></svg>');
    background-repeat: no-repeat;
    background-position: 95% center;
    background-size: 12px;
  }
  .top-data .level-dropdown option {
    background: mediumblue;
    color: white;
    font-size: 20px;
    font-weight: bold;
  }
  .top-data table {
    background-color: #fff;
    min-width: 450px;
    position: relative;
    z-index: 1;
  }
  .top-data th:not(:last-child),
  .top-data td:not(:last-child) {
    font-size: 20px;
  }
  .top-data th:last-child,
  .top-data td:last-child {
    font-size: 16px;
    white-space: nowrap;
  }
  .top-data th.medal {
    font-size: 37px; /* Medal emojis at 37px */
  }
  .dropdown-row {
    background: mediumblue;
    font-weight: bold;
  }
  .dropdown-row td {
    border: 3px solid #000;
    padding: 6px;
    text-align: center;
  }
  .play-btn,
  .seq-btn {
    font-size: 20px;
    background: gold;
    font-weight: bold;
    color: black;
    border: 1px solid #808080;
    border-radius: 0;
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    display: block;
  }
  .play-btn:hover,
  .seq-btn:hover {
    background: #ffcc00;
  }
  .seq-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
  .top-data td:first-child {
    padding: 0;
    margin: 0;
    background: gold;
    border: 3px solid #000;
  }
  .difficulty-btn.TopTen,
  .difficulty-btn.FastestPlayers,
  .difficulty-btn.LeastRestarts,
  .difficulty-btn.MedalCount {
    font-size: 20px;
    background: gold;
    font-weight: bold;
    color: black;
  }
  .difficulty-btn.TopTen:disabled,
  .difficulty-btn.MedalCount:disabled {
    opacity: 1.0;
    background: gold;
    color: black;
  }
  .medal-count-btn {
    font-size: 20px;
  }
  .medal-filter-btn {
    font-size: 20px;
  }
}

/* Table Cells for Rank in TopTen View */
.top-data.top-ten td:first-child {
  background: #d3d3d3;
  border: 3px solid #000;
  padding: 3px;
}

/* Ensure seq-btn and play-btn retain gold background */
.top-data td:first-child .seq-btn,
.top-data td:first-child .play-btn {
  background: gold;
}

/* Medal styling for top three ranks */
.top-data.top-ten td:first-child.medal {
  font-size: 28px;
}

/* Desktop Media Query for Medal Styling */
@media (min-width: 600px) {
  .top-data.top-ten td:first-child.medal {
    font-size: 32px;
  }
}

/* Medal Count Rank Column */
.top-data td:nth-child(1) {
  background: #d3d3d3;
  border: 3px solid #000;
  padding: 3px;
}

/* Desktop Media Query for Medal Count Rank Column */
@media (min-width: 600px) {
  .top-data td:nth-child(1) {
    background: #d3d3d3;
    border: 3px solid #000;
    padding: 3px;
  }
}
