@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

body {
  background: #1a1a2e;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Press Start 2P', monospace;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 560px;
  padding: 16px;
}

/* Header */
#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  color: #fff;
  font-size: 10px;
}

#cat-name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

#cat-name {
  font-size: 12px;
  color: #ffd6a5;
  text-shadow: 2px 2px #7d4f2a;
}

#rename-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
}
#rename-btn:hover { opacity: 1; }

#age-display {
  color: #a0a0c0;
  font-size: 8px;
}

/* Game canvas area */
#game-area {
  position: relative;
  width: 100%;
  border: 4px solid #5a3e2b;
  border-radius: 4px;
  box-shadow: 0 0 0 2px #2e1a0e, 0 8px 32px rgba(0,0,0,0.6);
  overflow: hidden;
  image-rendering: pixelated;
}

#game-canvas {
  display: block;
  width: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#status-message {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 7px;
  padding: 4px 10px;
  border-radius: 2px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}
#status-message.show { opacity: 1; }

/* Stats */
#stats-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.stat {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-label {
  color: #ccc;
  font-size: 7px;
  width: 80px;
  flex-shrink: 0;
}

.bar-bg {
  flex: 1;
  height: 12px;
  background: #2a2a4a;
  border: 2px solid #444;
  border-radius: 2px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: #4caf50;
  border-radius: 1px;
  transition: width 0.5s ease;
}

.stat-val {
  color: #fff;
  font-size: 8px;
  width: 28px;
  text-align: right;
}

/* Action buttons */
#action-panel {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: center;
}

.action-btn {
  flex: 1;
  padding: 10px 4px;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  background: #3d2b1f;
  color: #ffd6a5;
  border: 3px solid #7d5a3c;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.1s;
  image-rendering: pixelated;
}

.action-btn:hover {
  background: #5a3e2b;
  border-color: #c8944a;
  transform: translateY(-2px);
}

.action-btn:active {
  transform: translateY(1px);
  border-color: #ffd6a5;
}

.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Color picker */
#color-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.color-label {
  color: #aaa;
  font-size: 7px;
  font-family: 'Press Start 2P', monospace;
}

.color-btn {
  background: #2a2a4a;
  border: 3px solid #444;
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  line-height: 1;
}

.color-btn:hover  { border-color: #c8944a; transform: translateY(-2px); }
.color-btn.active { border-color: #ffd6a5; background: #3d2b1f; }

/* Offline notice */
#offline-notice {
  background: #2d1b00;
  border: 2px solid #8b4513;
  border-radius: 4px;
  padding: 10px 14px;
  color: #ffb347;
  font-size: 7px;
  text-align: center;
  line-height: 1.8;
  width: 100%;
}

/* Modal */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

#modal {
  background: #1e1e3a;
  border: 3px solid #7d5a3c;
  border-radius: 6px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 280px;
}

#modal p {
  color: #ffd6a5;
  font-size: 9px;
  text-align: center;
}

#name-input {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  background: #0d0d1a;
  color: #fff;
  border: 2px solid #5a3e2b;
  border-radius: 3px;
  padding: 8px 10px;
  width: 100%;
  outline: none;
}

#name-input:focus { border-color: #c8944a; }

.modal-btns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-btns button {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 8px 14px;
  border-radius: 3px;
  cursor: pointer;
  border: 2px solid;
}

#modal-cancel {
  background: #2a2a4a;
  color: #aaa;
  border-color: #444;
}

#modal-confirm {
  background: #3d2b1f;
  color: #ffd6a5;
  border-color: #7d5a3c;
}

#modal-confirm:hover { background: #5a3e2b; }

.hidden { display: none !important; }

#home-btn, #mode3d-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  background: rgba(30,20,10,0.6);
  color: #aaa;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 4px 7px;
  text-decoration: none;
  cursor: pointer;
}
#home-btn:hover, #mode3d-btn:hover { color: #ffd6a5; border-color: #7d5a3c; }
