/* Define color variables for consistency */
:root {
  --primary-bg: linear-gradient(135deg, #1a1a1a 0%, #2c2c2c 100%);
  --accent-cyan: #00d4ff;
  --accent-magenta: #ff007a;
  --accent-green: #00ff7f;
  --text-primary: #ffffff;
  --text-secondary: #cccccc;
  --menu-bg: rgba(0, 0, 0, 0.9);
  --button-bg: linear-gradient(45deg, #00d4ff, #ff007a);
  --table-bg: rgba(255, 255, 255, 0.1);
}

/* Reset default styles */
* {
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Font imports (unchanged) */
@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 400;
  src: local('Lato Regular'), local('Lato-Regular'), url(http://themes.googleusercontent.com/static/fonts/lato/v6/9k-RPmcnxYEPm8CNFsH2gg.woff) format('woff');
}
@font-face {
  font-family: 'Source Sans Pro';
  font-style: normal;
  font-weight: 400;
  src: local('Source Sans Pro'), local('SourceSansPro-Regular'), url(http://themes.googleusercontent.com/static/fonts/sourcesanspro/v5/ODelI1aHBYDBqgeIAH2zlBM0YzuT7MdOe03otPbuUS0.woff) format('woff');
}
@font-face {
  font-family: 'Source Sans Pro';
  font-style: normal;
  font-weight: 900;
  src: local('Source Sans Pro Black'), local('SourceSansPro-Black'), url(http://themes.googleusercontent.com/static/fonts/sourcesanspro/v5/toadOcfmlt9b38dHJxOBGHiec-hVyr2k4iOzEQsW1iE.woff) format('woff');
}

/* General */
html {
  font-size: 1em;
}
body {
  font: 1em 'Source Sans Pro';
  margin: 0;
  background: var(--primary-bg);
  background-size: cover;
  color: var(--text-primary);
}
a {
  color: var(--accent-cyan);
  text-decoration: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}
th {
  padding: 0;
  font-weight: normal;
}
td {
  padding: 0;
}

/* Header */
h1 {
  color: var(--accent-magenta);
  font-size: 2rem;
  margin: 0.65em 0;
  text-shadow: 0 0 5px var(--accent-magenta);
}
h3 {
  margin: 0;
  text-transform: uppercase;
  font-weight: normal;
  text-align: center;
  color: var(--accent-cyan);
  text-shadow: 0 0 5px var(--accent-cyan);
}
nav > ul {
  margin: 0;
  padding: 0;
}
.button,
nav li {
  display: block;
}
.button,
nav a {
  font: 1.25rem 'Lato';
  display: inline-block;
  width: 50%;
  color: var(--text-primary);
  border: 2px solid var(--accent-green);
  cursor: pointer;
  border-radius: 1em;
  padding: 0.3rem 0.6rem 0.4rem;
  margin: 0.5em;
  background: var(--button-bg);
  transition: transform 0.2s, box-shadow 0.2s;
}
.button:hover,
nav a:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px var(--accent-cyan);
}
.button:active,
nav a:active {
  transform: scale(0.95);
}
.button {
  margin: 0;
}

/* Content */
#content {
  display: table;
  margin: auto;
  padding-top: 18px;
}

/* Canvases */
#sprite {
  display: none;
}
#bg {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  z-index: -1;
}
#a {
  position: relative;
  overflow: hidden;
  float: left;
  display: block;
}
#b {
  border: 2px solid #fff;
  box-shadow: 0 0 20px rgba(50,50,50,0.5);
  position: relative;
  overflow: hidden;
  float: left;
  z-index: 3;
  display: block;
  border-radius: 1em;
}
#c {
  padding: 0 0.5em;
  position: relative;
  overflow: hidden;
  float: left;
  display: block;
}
#bgStack {
  background: #333;
  position: absolute;
  z-index: 2;
  border-radius: 1em;
}
#hold,
#preview,
#stack {
  position: absolute;
  z-index: 2;
}
#active {
  position: absolute;
  z-index: 3;
}
#msg {
  font: 900 4rem 'Source Sans Pro', sans-serif;
  font-size: 4rem;
  color: var(--accent-magenta);
  position: absolute;
  text-align: center;
  width: 100%;
  line-height: 642px;
  margin: 0;
  z-index: 4;
  text-shadow: 0 0 10px var(--accent-magenta);
}
#d {
  padding: 0px 0.5em;
  position: relative;
  overflow: hidden;
  float: left;
  display: block;
}

/* Stats */
#stats {
  color: var(--accent-cyan);
  text-shadow: 0 0 5px var(--accent-cyan);
}

#stats tbody {
  display: block;
}

#stats tr {
  display: block;
  clear: both;
  padding: 0;
}

#stats th {
  text-transform: uppercase;
  display: inline-block;
  width: 100%;
  vertical-align: top;
  text-align: center;
}

#stats td {
  font-size: 150%;
  font-weight: normal;
  text-align: center;
  line-height: 1;
  display: inline-block;
  width: 100%;
}

/* Score Container */
#score-container {
  clear: both;
  text-align: center;
  padding: 0.5em 0;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5em;
}

#score-label {
  text-transform: uppercase;
  font-weight: normal;
  color: var(--text-secondary);
}

#score {
  font-size: 150%;
  font-weight: normal;
  text-align: center;
  line-height: 1;
  color: var(--accent-cyan);
  text-shadow: 0 0 5px var(--accent-cyan);
}

#time {
  text-align: center;
  font-weight: 900;
  font-size: 1.125em;
  display: block;
  color: var(--accent-magenta);
  text-shadow: 0 0 5px var(--accent-magenta);
}

/* Menus */
.menu {
  text-align: center;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: -200%;
  position: absolute;
  background: var(--menu-bg);
  border: 2px solid var(--accent-green);
  top: 0;
  z-index: 50;
  border-radius: 1em;
  opacity: 0;
  transition: opacity .8s ease-out,
              background .4s ease-out .3s,
              margin .4s ease-out;
}
.on {
  background: rgba(0, 0, 0, 0.8);
  opacity: 1;
  margin: 0;
}

/* Controls */
#controls {
  margin: 0 auto 1em;
}
#controls th {
  font-weight: bold;
  text-align: left;
  line-height: 1.6;
  color: var(--text-primary);
}
#controls td {
  font-weight: bold;
  cursor: pointer;
  display: block;
  margin: 0.2em 0 0.2em 2em;
  text-align: center;
  width: 6em;
  line-height: 1.6;
  background: #222;
  border-radius: 5px;
  color: var(--accent-cyan);
}
#controls td:hover {
  background: #2a2a2a;
  color: var(--accent-magenta);
}
#controls td:active {
  background: #1a1a1a;
}

/* Settings */
.left,
.right {
  font-family: FontAwesome;
  font-weight: normal;
  font-style: normal;
  cursor: pointer;
  -webkit-font-smoothing: antialiased;
  -webkit-transition: all .1s ease-out;
  transition: all .1s ease-out;
  color: var(--text-primary);
}
.left:hover,
.right:hover {
  color: var(--accent-magenta);
}
.left:before,
.right:before {
  text-decoration: inherit;
  display: inline-block;
}
.left:before  { content: "\f022"; }
.right:before { content: "\f023"; }

#settings {
  margin: 0 0 1em;
}
#settings b {
  text-align: left;
  display: inline-block;
  width: 7em;
  color: var(--text-primary);
}
#settings span {
  text-align: center;
  font-weight: bold;
  display: inline-block;
  width: 5em;
  margin: 0.3em 0;
  color: var(--accent-cyan);
}

/* Special Menus */
#go {
  background: none;
  transition: opacity .8s ease-out .8s;
}
#go ul {
  width: 100%;
  position: absolute;
  bottom: 2em;
}

#pause {
  background: none;
  transition: opacity .8s ease-out;
}
#pause ul {
  width: 100%;
  position: absolute;
  bottom: 2em;
}

nav#leftctrls {
  position: absolute;
  bottom: 6em;
  left: 2em;
  z-index: 60;
}

nav#rightctrls {
  position: absolute;
  bottom: 6em;
  right: 2em;
  z-index: 60;
}

nav.touchctrl li {
  display: inline-block;
  text-align: center;
}

nav#leftctrls a {
  width: 2em;
  height: 2em;
  display: inline-block;
  padding: 0px;
  line-height: 2em;
}

nav#rightctrls a {
  width: 2em;
  height: 2em;
  display: inline-block;
  padding: 0px;
  line-height: 2em;
}

/* Leaderboard */
#leaderboard {
  min-height: 400px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 0.5em; /* Reduced padding to allow table to stretch wider */
  background: var(--table-bg);
  box-sizing: border-box; /* Ensure padding doesn't affect inner width */
}

/* Leaderboard Filter */
#leaderboard-filter {
  margin-bottom: 1em;
  text-align: center;
}

#leaderboard-filter label {
  margin-right: 0.5em;
  color: var(--text-secondary);
}

#leaderboard-filter select {
  padding: 0.3em;
  font-size: 1rem;
  border-radius: 0.5em;
  background: #222;
  color: var(--text-primary);
  border: 1px solid var(--accent-green);
}

/* Leaderboard Table */
#leaderboardTable {
  width: 100%; /* Full width of container */
  border-collapse: collapse;
  border: 1px solid var(--accent-green);
}

#leaderboardTable th,
#leaderboardTable td {
  padding: 0.1em; /* Further reduced padding for table content */
  text-align: center;
  border-bottom: none;
  background: var(--table-bg);
}

/* Set specific column widths */
#leaderboardTable th:nth-child(1), /* Rank */
#leaderboardTable td:nth-child(1) {
  width: 10%;
}
#leaderboardTable th:nth-child(2), /* Player */
#leaderboardTable td:nth-child(2) {
  width: 25%;
}
#leaderboardTable th:nth-child(3), /* Score */
#leaderboardTable td:nth-child(3) {
  width: 15%;
}
#leaderboardTable th:nth-child(4), /* Mode */
#leaderboardTable td:nth-child(4) {
  width: 20%;
}
#leaderboardTable th:nth-child(5), /* Date */
#leaderboardTable td:nth-child(5) {
  width: 30%;
}

#leaderboardTable th {
  font-size: 0.7rem;
  font-weight: bold;
  text-transform: uppercase;
  background: var(--button-bg);
  color: var(--text-primary);
  text-shadow: 0 0 5px var(--accent-blue);
}

#leaderboardTable td {
  font-size: 0.7rem; /* Reduced font size for table content to match headers */
  font-weight: normal;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--accent-green);
}

#leaderboardTable tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.05);
}

#leaderboardTable tr:hover {
  background: rgba(0, 212, 255, 0.2);
  transition: background 0.3s;
}

/* Clearfix for buttons in leaderboard */
#leaderboard div[style="clear:both"] {
  text-align: center;
  margin-top: 20px;
}

/* Sound button */
#soundButton {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 1.5rem;
  color: var(--accent-green);
  cursor: pointer;
  transition: color 0.2s;
}

#soundButton:hover {
  color: var(--accent-magenta);
}