/* This line imports a custom font called 'Press Start 2P' from Google Fonts.
   This font gives the game its retro, pixelated look. */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: 'Press Start 2P', cursive;
  background-color: #1a1a1a;
  color: #333;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
  touch-action: manipulation;
}

.phone-container {
  position: relative;
  width: 100%;
  max-width: 360px;
  height: 85vh;
  max-height: 700px;
  background: linear-gradient(145deg, #2c3e50, #34495e);
  border-radius: 30px;
  padding: 15px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5),
    inset 0 -5px 10px rgba(0, 0, 0, 0.3),
    inset 0 5px 10px rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.phone-brand {
  color: #f8f8f8;
  font-size: 1rem;
  margin-top: 5px;
  letter-spacing: 1px;
  text-shadow: 0 0 5px rgba(0, 255, 255, 0.7);
}

.screen {
  width: 100%;
  height: calc(100% - 20px);
  background-color: #5adc78;
  border-radius: 5px;
  border: 10px solid #1a1a1a;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.3);
}

.status-bar {
  height: 24px;
  background-color: #3a8c48;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
  font-size: 10px;
  border-bottom: 2px solid #1a1a1a;
  color: #000;
}

.battery-icon {
  display: flex;
  align-items: center;
}

.signal-bars {
  display: flex;
  align-items: flex-end;
  height: 10px;
}

.bar {
  width: 3px;
  background-color: #000;
  margin-right: 1px;
}

.bar:nth-child(1) { height: 3px; }
.bar:nth-child(2) { height: 5px; }
.bar:nth-child(3) { height: 7px; }
.bar:nth-child(4) { height: 9px; }

.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px;
}

.header {
  text-align: center;
  font-size: 1rem;
  margin-bottom: 15px;
  color: #000;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.5);
}

.target-word-container {
  margin-top: 15px;
  text-align: center;
}

.word-label {
  font-size: 0.7rem;
  margin-bottom: 8px;
  color: #000;
}

.target-word {
  font-size: 1.5rem;
  background-color: #3a8c48;
  padding: 8px 15px;
  border: 3px solid #000;
  border-radius: 5px;
  letter-spacing: 2px;
  display: inline-block;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
  box-shadow: 0 4px 0 #1a5928, inset 0 0 10px rgba(255, 255, 255, 0.2);
  min-height: 40px;
}

.input-area {
  margin: 20px 0;
  height: 60px;
  background-color: #3a8c48;
  border: 3px solid #000;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
  padding: 0 10px;
}

.input-text {
  font-size: 1.3rem;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
  min-height: 25px;
  flex-grow: 1;
  text-align: center;
}

.cursor {
  display: inline-block;
  width: 10px;
  height: 20px;
  background-color: #fff;
  margin-left: 2px;
  animation: blink 1s infinite;
}

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

.preview-letter {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
  color: #fff;
  background-color: #1a5928;
  padding: 2px 8px;
  border-radius: 3px;
  border: 2px solid #000;
  text-shadow: 1px 1px 0 #000;
}

.keypad {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-gap: 8px;
  margin-top: auto;
  padding: 5px;
}

.key {
  aspect-ratio: 1.2/1;
  background: linear-gradient(to bottom, #f0f0f0, #c0c0c0);
  border: 3px solid #000;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Press Start 2P', cursive;
  box-shadow: 0 5px 0 #666, inset 0 1px 0 rgba(255, 255, 255, 0.8);
  position: relative;
  transition: transform 0.05s, box-shadow 0.05s;
  cursor: pointer;
}

.key:active {
  transform: translateY(5px);
  box-shadow: 0 0 0 #666;
}

.key-number {
  font-size: 1.3rem;
  font-weight: bold;
  color: #000;
}

.key-letters {
  font-size: 0.5rem;
  color: #333;
  margin-top: 3px;
}

.function-key {
  background: linear-gradient(to bottom, #ff9c40, #e67e22);
}

.function-key .key-number, .function-key .key-letters {
    color: #000;
}

.results {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #5adc78;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4);
}

.results-title {
  font-size: 1.5rem;
  margin-bottom: 25px;
  color: #000;
  text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.5);
  text-align: center;
}

.result-item {
  font-size: 0.9rem;
  margin: 8px 0;
  width: 100%;
  text-align: center;
  color: #000;
  background-color: #3a8c48;
  padding: 8px;
  border: 2px solid #000;
  border-radius: 5px;
}

.restart-btn {
  margin-top: 30px;
  padding: 12px 20px;
  background: linear-gradient(to bottom, #ff9c40, #e67e22);
  border: 3px solid #000;
  border-radius: 8px;
  font-family: 'Press Start 2P', cursive;
  font-size: 1rem;
  box-shadow: 0 5px 0 #b35900;
  cursor: pointer;
  color: #000;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.05s, box-shadow 0.05s;
}

.restart-btn:active {
  transform: translateY(5px);
  box-shadow: 0 0 0 #b35900;
}

.screen::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0) 50%,
    rgba(0, 0, 0, 0.05) 50%,
    rgba(0, 0, 0, 0.05) 100%
  );
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 5;
}
