/* =========================================
   1. GLOBAL RESET & TYPOGRAPHY
   ========================================= */
:root {
  --bg-dark: #141e30;
  --bg-light: #243b55;
  --neon-blue: #03e9f4;
  --glass-bg: rgba(0, 0, 0, 0.5);
  --text-white: #ffffff;
  --font-main: sans-serif;
}

* { 
  box-sizing: border-box; 
  outline: none; 
  -webkit-tap-highlight-color: transparent; 
}

html, body {
  height: 100%; 
  margin: 0; 
  padding: 0;
  font-family: var(--font-main);
  background: linear-gradient(var(--bg-dark), var(--bg-light));
  overflow-x: hidden; 
  color: var(--text-white);
  -webkit-text-size-adjust: 100%;
}

/* =========================================
   2. PERSISTENT HUD (Heads Up Display)
   ========================================= */
#hud-container {
  position: fixed; top: 10px; left: 0; width: 100%;
  display: flex; justify-content: space-between;
  padding: 0 15px; z-index: 1000; pointer-events: none;
}
.hud-item {
  background: rgba(0, 0, 0, 0.6); padding: 8px 12px;
  border-radius: 6px; font-size: clamp(.85rem, 4vw, 1.3rem); font-weight: 700;
  border: 1px solid var(--neon-blue); box-shadow: 0 0 8px var(--neon-blue);
  white-space: nowrap;
}

/* =========================================
   3. MAIN GAME CONTAINER (.login-box)
   ========================================= */
.login-box {
  position: absolute; top: 50%; left: 50%;
  width: 92%; max-width: 700px; 
  padding: 30px 20px;
  transform: translate(-50%, -50%);
  background: var(--glass-bg);
  box-shadow: 0 15px 25px rgba(0,0,0,.6);
  border-radius: 12px; text-align: center; z-index: 10;
  max-height: 90vh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.login-box h2 { margin: 0 0 20px; font-size: clamp(1.4rem, 6vw, 2.8rem); color: #fff; text-align: center; }
.login-box p { margin: 10px 0 20px; padding: 0; color: #fff; font-size: clamp(1rem, 4vw, 1.6rem); text-align: left; line-height: 1.5; }
.login-box form { display: flex; flex-direction: column; gap: 16px; align-items: center; }

/* =========================================
   4. INPUT FIELDS (Registration & Admin)
   ========================================= */
.user-box { position: relative; width: 100%; margin-bottom: 16px; }
.user-box input {
  width: 100%; padding: 12px 0; font-size: 16px; color: #fff;
  margin-bottom: 20px; border: none; border-bottom: 1px solid #fff;
  background: transparent; transition: .3s;
}
.user-box label {
  position: absolute; top: 0; left: 0; padding: 12px 0;
  font-size: 16px; color: #fff; pointer-events: none; transition: .5s;
}
.user-box input:focus ~ label, .user-box input:valid ~ label {
  top: -20px; left: 0; color: var(--neon-blue); font-size: .9rem;
}

/* =========================================
   5. NEON BUTTONS (Touch-Optimized)
   ========================================= */
.neon-btn {
  position: relative; display: block; width: 100%;
  min-height: 48px; padding: 12px 16px; color: var(--neon-blue);
  font-size: clamp(.95rem, 3.5vw, 1.3rem);
  text-decoration: none; text-transform: uppercase;
  overflow: hidden; transition: .3s; margin-top: 10px;
  letter-spacing: 1px; border: 1px solid rgba(255,255,255,.2);
  text-align: center; cursor: pointer; background: transparent;
  font-family: var(--font-main); border-radius: 6px;
  touch-action: manipulation;
}
.neon-btn:hover {
  background: var(--neon-blue); color: #000;
  box-shadow: 0 0 12px var(--neon-blue); border-color: var(--neon-blue);
}
.neon-btn:active { transform: scale(.98); opacity: .9; }
.neon-btn span { position: absolute; display: block; }
.neon-btn span:nth-child(1) { top: 0; left: -100%; width: 100%; height: 2px; background: linear-gradient(90deg, transparent, var(--neon-blue)); animation: btn-anim1 1s linear infinite; }
@keyframes btn-anim1 { 0% { left: -100%; } 50%,100% { left: 100%; } }
.neon-btn span:nth-child(2) { top: -100%; right: 0; width: 2px; height: 100%; background: linear-gradient(180deg, transparent, var(--neon-blue)); animation: btn-anim2 1s linear infinite; animation-delay: .25s; }
@keyframes btn-anim2 { 0% { top: -100%; } 50%,100% { top: 100%; } }
.neon-btn span:nth-child(3) { bottom: 0; right: -100%; width: 100%; height: 2px; background: linear-gradient(270deg, transparent, var(--neon-blue)); animation: btn-anim3 1s linear infinite; animation-delay: .5s; }
@keyframes btn-anim3 { 0% { right: -100%; } 50%,100% { right: 100%; } }
.neon-btn span:nth-child(4) { bottom: -100%; left: 0; width: 2px; height: 100%; background: linear-gradient(360deg, transparent, var(--neon-blue)); animation: btn-anim4 1s linear infinite; animation-delay: .75s; }
@keyframes btn-anim4 { 0% { bottom: -100%; } 50%,100% { bottom: 100%; } }
.neon-btn.disabled { opacity: .35; pointer-events: none; filter: grayscale(.8); color: #444; border-color: #333; }

/* =========================================
   6. ADMIN MODE STYLES
   ========================================= */
.admin-editable {
  width: 100%; padding: 8px; border-radius: 4px;
  background: rgba(255,255,255,.1); border: 1px dashed #555;
  color: #fff!important; font-weight: 700; transition: .2s; text-align: center;
}
.admin-editable:focus { border-color: var(--neon-blue); background: rgba(3,233,244,.15); }

#admin-toggle {
  position: fixed; bottom: 15px; right: 15px; font-size: 22px;
  color: rgba(255,255,255,.4); cursor: pointer; z-index: 9999;
  background: rgba(0,0,0,.6); width: 46px; height: 46px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 1px solid #555; touch-action: manipulation;
}
#admin-toggle:hover { color: var(--neon-blue); transform: rotate(90deg); }

#save-btn, #export-btn, #reset-btn {
  position: fixed; bottom: 15px; padding: 10px 16px; border-radius: 20px;
  cursor: pointer; z-index: 10000; font-size: .9rem; font-weight: 700;
  touch-action: manipulation; color: #fff; border: none;
}
#save-btn { right: 80px; background: #28a745; box-shadow: 0 0 10px rgba(40,167,69,0.5); }
#save-btn:hover { background: #218838; }
#export-btn { left: 185px; background: #03e9f4; color: #000; box-shadow: 0 0 10px rgba(3,233,244,0.5); }
#export-btn:hover { background: #02b8c4; }
#reset-btn { left: 15px; background: #ff4444; box-shadow: 0 0 10px rgba(255,68,68,0.5); }
#reset-btn:hover { background: #e63939; }

.admin-field { position: relative; flex: 1; min-width: 0; }
.admin-field[data-tooltip]::after {
  content: attr(data-tooltip); position: absolute; bottom: calc(100% + 5px); left: 50%;
  transform: translateX(-50%); background: #000; color: var(--neon-blue);
  padding: 5px 8px; border-radius: 4px; font-size: .7rem; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: .2s; border: 1px solid var(--neon-blue);
  z-index: 9999; box-shadow: 0 4px 8px rgba(0,0,0,.5);
}
.admin-field[data-tooltip]:hover::after { opacity: 1; transform: translateX(-50%) scale(1); }

.admin-option-card {
  border: 1px solid #444; padding: 12px; margin-bottom: 12px;
  border-radius: 6px; background: rgba(0,0,0,.4); text-align: left; position: relative;
}
.admin-option-title { font-size: .85rem; color: #aaa; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 1px; }

.admin-params-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.admin-param { flex: 1 1 50px; display: flex; flex-direction: column; min-width: 50px; position: relative; }
.admin-param label { font-size: .7rem; color: #888; margin-bottom: 3px; text-align: center; }
.admin-param input {
  width: 100%; padding: 5px 2px; text-align: center; font-size: .85rem;
  background: rgba(255,255,255,.1); border: 1px solid #555; color: #fff; border-radius: 3px;
}
.admin-param input:focus { border-color: var(--neon-blue); background: rgba(3,233,244,.1); }

.admin-opt-remove {
  position: absolute; top: 8px; right: 8px; background: #ff4444; color: #fff;
  border: none; width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  font-size: 14px; line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: .2s; z-index: 2;
}
.admin-opt-remove:hover { background: #cc0000; transform: scale(1.1); }

.admin-add-option {
  width: 100%; padding: 10px; margin-top: 10px;
  background: rgba(3,233,244,.1); border: 1px dashed var(--neon-blue);
  color: var(--neon-blue); border-radius: 6px; cursor: pointer;
  font-size: .9rem; font-weight: 700; transition: .2s;
}
.admin-add-option:hover { background: rgba(3,233,244,.2); }

.nav-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 10px; }
.nav-btn {
  background: #444; color: #fff; border: none; padding: 8px 12px;
  border-radius: 6px; cursor: pointer; font-size: .9rem; touch-action: manipulation; transition: .2s;
}
.nav-btn:hover { background: #555; }

.admin-scroll-list { max-height: 60vh; overflow-y: auto; margin-bottom: 10px; padding-right: 5px; }
.admin-scroll-list::-webkit-scrollbar { width: 8px; }
.admin-scroll-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 4px; }
.admin-scroll-list::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
.admin-scroll-list::-webkit-scrollbar-thumb:hover { background: #555; }

/* =========================================
   7. FINAL SCREEN BARS
   ========================================= */
.result-bar {
  width: 100%; padding: 15px; margin-bottom: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: bold; border-radius: 5px;
}
.bar-name { background: teal; color: white; }
.bar-id { background: burlywood; color: black; }
.bar-score { background: mediumslateblue; color: white; }
.bar-time { background: green; color: white; }

/* =========================================
   8. RESPONSIVE ADJUSTMENTS
   ========================================= */
@media (max-width: 480px) {
  .login-box { width: 96%; padding: 20px 15px; max-height: 92vh; }
  .hud-item { padding: 6px 10px; font-size: .85rem; }
  #hud-container { top: 8px; }
  .user-box input { font-size: 16px; } /* Prevents iOS zoom */
}