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

body {
  font-family: "Comic Sans MS", cursive, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

.game-container {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 50px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  max-width: 95vw;
  max-height: 95vh;
  width: 100%;
  height: auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* สำหรับหน้าจอเล็ก */
@media (max-height: 800px) {
  .game-container {
    padding: 10px;
    border-radius: 15px;
  }

  h1 {
    font-size: 1.8em !important;
    margin-bottom: 10px !important;
  }

  .cat-container {
    margin: 15px auto !important;
    width: 200px !important;
    height: 200px !important;
  }

  .controls {
    gap: 10px !important;
  }

  .instructions {
    font-size: 0.9em !important;
    margin-top: 10px !important;
  }
}

@media (max-height: 650px) {
  h1 {
    font-size: 1.5em !important;
    margin-bottom: 5px !important;
  }

  .cat-container {
    width: 150px !important;
    height: 150px !important;
    margin: 10px auto !important;
  }

  .settings,
  .score-section,
  .sound-level {
    padding: 8px 15px !important;
    font-size: 1em !important;
  }

  .message {
    font-size: 1.1em !important;
    min-height: 30px !important;
  }
}

@media (max-width: 480px) {
  .game-container {
    padding: 8px;
  }

  .settings {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .score-section {
    flex-direction: column !important;
    gap: 10px !important;
  }

  .volume-bar {
    width: 150px !important;
  }
}

h1 {
  font-size: 2em;
  margin-bottom: 15px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  color: #ffe4e1;
}

.cat-container {
  position: relative;
  margin: 20px auto;
  width: 250px;
  height: 250px;
  flex-shrink: 0;
}

.cat {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #ffa500;
  position: relative;
  transition: all 0.5s ease;
  cursor: pointer;
}

.cat.sleeping {
  background: #ffb84d;
}

.cat.awake {
  background: #ff8c00;
  animation: shake 0.5s ease-in-out infinite;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* หู */
.ear {
  position: absolute;
  width: 40px;
  height: 40px;
  background: #ff8c00;
  border-radius: 50% 50% 0 0;
  top: 20px;
}

.ear.left {
  left: 60px;
  transform: rotate(-30deg);
  transition: transform 0.5s ease;
}

.ear.right {
  right: 60px;
  transform: rotate(30deg);
  transition: transform 0.5s ease;
}

.cat.awake .ear {
  animation: wiggle 0.3s ease-in-out infinite alternate;
}

@keyframes wiggle {
  from {
    transform: rotate(-30deg) translateY(-5px);
  }
  to {
    transform: rotate(-45deg) translateY(-10px);
  }
}

.cat.awake .ear.right {
  animation: wiggle-right 0.3s ease-in-out infinite alternate;
}

@keyframes wiggle-right {
  from {
    transform: rotate(30deg) translateY(-5px);
  }
  to {
    transform: rotate(45deg) translateY(-10px);
  }
}

/* ตา */
.eyes {
  position: absolute;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 30px;
}

.eye {
  width: 25px;
  height: 25px;
  background: black;
  border-radius: 50%;
  transition: all 0.5s ease;
}

.cat.sleeping .eye {
  height: 3px;
  border-radius: 10px;
  background: #333;
}

/* จมูก */
.nose {
  position: absolute;
  top: 140px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 8px;
  background: #ff69b4;
  border-radius: 50%;
}

/* ปาก */
.mouth {
  position: absolute;
  top: 160px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 20px;
  border: 3px solid #333;
  border-top: none;
  border-radius: 0 0 40px 40px;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.cat.awake .mouth {
  opacity: 1;
}

/* หิม */
.whiskers {
  position: absolute;
  top: 130px;
  left: 50%;
  transform: translateX(-50%);
}

.whisker {
  position: absolute;
  width: 40px;
  height: 2px;
  background: #333;
  border-radius: 2px;
}

.whisker:nth-child(1) {
  left: -60px;
  top: -5px;
}
.whisker:nth-child(2) {
  left: -60px;
  top: 5px;
}
.whisker:nth-child(3) {
  right: -60px;
  top: -5px;
}
.whisker:nth-child(4) {
  right: -60px;
  top: 5px;
}

.controls {
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
  flex-shrink: 0;
}

.settings {
  display: flex;
  align-items: center;
  gap: 15px;
  background: rgba(255, 255, 255, 0.1);
  padding: 15px 25px;
  border-radius: 25px;
  font-size: 1.1em;
  flex-wrap: wrap;
  justify-content: center;
}

.settings input {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  padding: 8px 12px;
  color: white;
  font-size: 1em;
  font-weight: bold;
  width: 80px;
  text-align: center;
}

.settings input:focus {
  outline: none;
  border-color: #ffe4e1;
  box-shadow: 0 0 10px rgba(255, 228, 225, 0.5);
}

.settings input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.score-section {
  display: flex;
  align-items: center;
  gap: 15px;
  background: rgba(255, 255, 255, 0.1);
  padding: 15px 25px;
  border-radius: 25px;
  font-size: 1.2em;
  font-weight: bold;
}

.wake-counter {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 107, 107, 0.3);
  padding: 10px 20px;
  border-radius: 20px;
  border: 2px solid rgba(255, 107, 107, 0.5);
}

.wake-counter.good-score {
  background: rgba(76, 175, 80, 0.3);
  border-color: rgba(76, 175, 80, 0.5);
}

.wake-counter.excellent-score {
  background: rgba(255, 215, 0, 0.3);
  border-color: rgba(255, 215, 0, 0.5);
  animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
  0%,
  100% {
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
  }
}

.reset-btn {
  background: linear-gradient(45deg, #6c5ce7, #a29bfe);
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  color: white;
  font-size: 1em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px rgba(108, 92, 231, 0.4);
}

.reset-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(108, 92, 231, 0.6);
}

.reset-btn:active {
  transform: translateY(0);
}

.sound-level {
  display: flex;
  align-items: center;
  gap: 15px;
  background: rgba(255, 255, 255, 0.1);
  padding: 15px 25px;
  border-radius: 25px;
  font-size: 1.2em;
  font-weight: bold;
}

.volume-bar {
  width: 200px;
  height: 20px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  overflow: visible;
  position: relative;
}

.volume-fill {
  height: 100%;
  background: linear-gradient(90deg, #4caf50 0%, #ffc107 50%, #f44336 100%);
  width: 0%;
  border-radius: 10px;
  transition: width 0.1s ease;
}

.threshold-line {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 3px;
  background: #ffe4e1;
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(255, 228, 225, 0.8);
  transition: left 0.3s ease;
  z-index: 10;
}

.threshold-line::before {
  content: attr(data-value) "dB";
  position: absolute;
  top: -25px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8em;
  font-weight: bold;
  color: #ffe4e1;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
}

button {
  background: linear-gradient(45deg, #ff6b6b, #ff8e8e);
  border: none;
  padding: 15px 30px;
  border-radius: 25px;
  color: white;
  font-size: 1.1em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255, 107, 107, 0.6);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  background: #ccc;
  cursor: not-allowed;
  box-shadow: none;
}

.message {
  margin-top: 15px;
  font-size: 1.2em;
  font-weight: bold;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.sleeping-zzz {
  position: absolute;
  top: 50px;
  right: 50px;
  font-size: 2em;
  opacity: 0;
  transition: opacity 0.5s ease;
  animation: float 2s ease-in-out infinite;
}

.cat.sleeping .sleeping-zzz {
  opacity: 1;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

.stars {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.star {
  position: absolute;
  width: 4px;
  height: 4px;
  background: white;
  border-radius: 50%;
  animation: twinkle 3s ease-in-out infinite;
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

.instructions {
  margin-top: 15px;
  font-size: 0.95em;
  opacity: 0.8;
  line-height: 1.4;
  flex-shrink: 0;
}

/* ป้องกันการ select text เพื่อไม่ให้เด็กกดผิด */
* {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

input {
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  user-select: text !important;
}

/* ซ่อน scrollbar แต่ยังสามารถเลื่อนได้ */
.game-container::-webkit-scrollbar {
  width: 0px;
  background: transparent;
}

/* สำหรับ Firefox */
.game-container {
  scrollbar-width: none;
}
