:root {
  --bg-color: #FFFDF5;
  --ui-color: #5D4037;
  --accent-color: #FFB74D;
  --danger-color: #FF5252;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  background-color: #FFE082;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* --- Game Container --- */
#game-container {
  position: relative;
  width: 100%;
  max-width: 450px;
  height: 100%;
  max-height: 850px;
  background-color: var(--bg-color);
  /* 테두리 느낌을 줄이기 위해 그림자를 제거 */
  box-shadow: none;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
}

/* --- Header --- */
header {
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.9);
  z-index: 10;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.score-box {
  display: flex;
  flex-direction: column;
}

.score-label {
  font-size: 12px;
  color: #888;
  font-weight: bold;
}

.score-val {
  font-size: 24px;
  font-weight: 800;
  color: var(--ui-color);
}

.btn-setting {
  font-size: 24px;
  cursor: pointer;
  color: var(--ui-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-setting svg {
  width: 24px;
  height: 24px;
}

/* --- Canvas Area --- */
#canvas-wrapper {
  position: relative;
  flex: 1;
  width: 100%;
  background-color: var(--bg-color);
  overflow: hidden;
  cursor: crosshair;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Deadline Line */
#deadline {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-top: 2px dashed var(--danger-color);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

#deadline.warning {
  opacity: 1;
  animation: blink 1s infinite;
}

@keyframes blink {
  50% {
    opacity: 0.3;
  }
}

/* --- Footer (Controls) --- */
footer {
  height: 100px;
  background: white;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 15px;
  border-top: 1px solid #eee;
  z-index: 20;
}

.control-group {
  display: flex;
  gap: 15px;
  align-items: center;
}

/* Next Fruit Display */
.next-fruit-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.next-fruit-label {
  font-size: 10px;
  color: #888;
  margin-bottom: 5px;
}

.next-preview {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #eee;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 2px solid #ddd;
  overflow: hidden; /* 내부 원이 넘치지 않도록 */
}

/* Item Buttons */
.item-btn {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 12px;
  border: none;
  background: #f0f0f0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: transform 0.1s;
  font-weight: bold;
  font-size: 12px;
  color: #555;
  overflow: hidden;
}

.item-btn:active {
  transform: scale(0.95);
}

.item-icon {
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-icon svg {
  width: 20px;
  height: 20px;
}

/* Basket Specific Styles */
#btn-basket {
  border: 2px solid #ddd;
}

#btn-basket.active {
  border-color: var(--accent-color);
  background-color: #FFF3E0;
}

#btn-basket.expired {
  border-color: #999;
  background-color: #ddd;
  opacity: 0.8;
}

.basket-timer {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 4px;
  background: var(--accent-color);
  width: 0%;
  transition: width 1s linear;
}

.ad-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--ui-color);
  color: white;
  font-size: 8px;
  padding: 2px 4px;
  border-radius: 4px;
}

.item-count {
  font-size: 10px;
  margin-left: 4px;
  opacity: 0.9;
}

/* Floating Text Animation */
.floating-text {
  position: absolute;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  animation: floatUp 1s forwards;
  font-size: 24px;
  z-index: 50;
}

@keyframes floatUp {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(-50px) scale(1.5);
    opacity: 0;
  }
}

/* Modals */
.modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  display: none;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 16px;
  text-align: center;
  width: 80%;
  max-width: 300px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.modal h2 {
  margin-top: 0;
  color: var(--ui-color);
}

.btn-primary {
  background: var(--accent-color);
  color: white;
  border: none;
  padding: 12px 24px;
  font-size: 16px;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 15px;
  font-weight: bold;
}

.btn-secondary {
  background: #eee;
  color: #555;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 10px;
}