:root {
  --primary-color: #00ffcc;
  --secondary-color: #ff00ff;
  --bg-color: #1a1a1a;
  --text-color: #ffffff;
  --track-color: #333;
  --font-main: 'Courier New', Courier, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-color);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #2a2a2a 0%, #1a1a1a 100%);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.screen {
  background: rgba(0, 0, 0, 0.9);
  padding: 3rem;
  border-radius: 1rem;
  text-align: center;
  border: 2px solid var(--primary-color);
  box-shadow: 0 0 30px var(--primary-color), inset 0 0 20px rgba(0, 255, 204, 0.2);
  pointer-events: auto;
  z-index: 10;
  backdrop-filter: blur(5px);
  animation: fadeIn 0.5s ease-out;
}

.hidden {
  display: none !important;
}

h1 {
  font-size: 5rem;
  margin-bottom: 1.5rem;
  color: var(--primary-color);
  text-shadow: 4px 4px var(--secondary-color);
  animation: pulse 2s infinite alternate;
  font-weight: 900;
  letter-spacing: 5px;
}

h2 {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    color: var(--secondary-color);
    text-shadow: 2px 2px #fff;
}

button {
  background: linear-gradient(45deg, var(--primary-color), #00ccaa);
  color: #000;
  border: none;
  padding: 1.2rem 3rem;
  font-size: 1.8rem;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  margin-top: 1.5rem;
  transition: all 0.2s ease;
  border-radius: 5px;
  box-shadow: 0 5px 15px rgba(0, 255, 204, 0.4);
  text-transform: uppercase;
}

button:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 10px 25px rgba(0, 255, 204, 0.6);
  background: linear-gradient(45deg, #00ffcc, #55ffdd);
}

button:active {
  transform: translateY(1px);
}

#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 30px;
    pointer-events: none;
}

.stats-panel {
    display: flex;
    gap: 3rem;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    padding: 15px 40px;
    border-radius: 50px;
    align-self: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
}

.stat-box {
    text-align: center;
}

.stat-box .label {
    display: block;
    font-size: 0.9rem;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.stat-box .value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    text-shadow: 0 0 10px rgba(0, 255, 204, 0.5);
}

#typing-area {
    background: rgba(0, 0, 0, 0.8);
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 60px;
    align-self: center;
    width: 90%;
    max-width: 900px;
    border: 1px solid #444;
    font-size: 1.4rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    min-height: 120px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

#target-text {
    font-family: 'Courier New', Courier, monospace;
}

.char {
    color: #555;
    transition: color 0.1s;
}

.char.correct {
    color: var(--primary-color);
    text-shadow: 0 0 5px var(--primary-color);
}

.char.incorrect {
    color: var(--secondary-color);
    text-decoration: underline;
    background-color: rgba(255, 0, 255, 0.2);
}

.char.current {
    background-color: #fff;
    color: #000;
    border-radius: 2px;
    box-shadow: 0 0 10px #fff;
    animation: blink 0.8s infinite;
}

.results p {
    font-size: 1.5rem;
    margin: 10px 0;
    color: #eee;
}

.results span {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 1.8rem;
}

@keyframes pulse {
  0% { text-shadow: 4px 4px var(--secondary-color); transform: scale(1); }
  100% { text-shadow: 6px 6px var(--secondary-color); transform: scale(1.02); }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
