/**
 * Tile Eating - Main Styling & Layout
 * Version: 5.0.0
 * Based on the reference image (Food Hunt / Pixel Eater)
 */

:root {
  --te-bg: #f7d2b4;
  --te-bg-gradient: radial-gradient(circle at 50% 30%, #fbe3cf 0%, #f4c5a3 100%);
  --te-frame-bg: #ffffff;
  --te-frame-border: #e8d0bc;
  --te-slot-bg: #ffffff;
  --te-slot-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15);
  --te-hole-bg: radial-gradient(circle, #25160d 40%, #583925 80%, #7d5236 100%);
}

.screen-tile-eating {
  width: 100%;
  max-width: 480px;
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--te-bg);
  background-image: var(--te-bg-gradient);
  color: #333333;
  overflow: hidden; /* No scrolling! */
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* HEADER */
.te-header {
  padding: 6px 12px 2px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 10;
}

.te-top-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.te-brand-badge {
  display: flex;
  align-items: center;
  background: linear-gradient(135deg, #ff7675 0%, #d63031 100%);
  padding: 4px 10px;
  border-radius: 16px;
  box-shadow: 0 3px 8px rgba(214, 48, 49, 0.35);
  border: 1.5px solid rgba(255, 255, 255, 0.4);
}

.te-brand-title {
  font-size: 14px;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* SCOREBOARD */
.te-scoreboard {
  width: 100%;
  margin-top: 4px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 10px;
  padding: 4px 6px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.te-score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.te-score-label {
  font-size: 8px;
  font-weight: 700;
  color: #7f6451;
  text-transform: uppercase;
}

.te-score-val {
  font-size: 12px;
  font-weight: 800;
  color: #2d3436;
  font-variant-numeric: tabular-nums;
}

.te-score-val.gold {
  color: #d35400;
}

/* LEVEL TITLE BANNER */
.te-level-banner {
  margin-top: 3px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0 4px;
}

.te-level-title {
  font-size: 15px;
  font-weight: 800;
  color: #4a2c1d;
}

.te-progress-badge {
  font-size: 10px;
  font-weight: 700;
  color: #7f6451;
  background: rgba(255, 255, 255, 0.5);
  padding: 1px 6px;
  border-radius: 8px;
}

/* GAMEPLAY AREA - NO SCROLL */
.te-game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 2px 10px 4px 10px;
  overflow: hidden; /* No scroll! */
  position: relative;
  width: 100%;
}

/* TOP: PIXEL ART PICTURE FRAME */
.te-frame-wrapper {
  width: 100%;
  max-width: min(240px, 29vh);
  aspect-ratio: 1;
  background: #fdfbf7;
  border: 4px solid #eae0d5;
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(110, 75, 50, 0.16), inset 0 2px 4px rgba(0, 0, 0, 0.05);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.te-canvas-grid {
  width: 100%;
  height: 100%;
  display: grid;
  gap: 1px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.04);
}

.te-tile {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border-radius: 1px;
  transition: transform 0.2s ease, opacity 0.2s ease;
  position: relative;
}

.te-tile.accessible {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
  animation: tileBlink 1.8s infinite ease-in-out;
}

@keyframes tileBlink {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.18); }
}

.te-tile.eating {
  animation: tileFlyToHole 0.3s ease forwards;
}

@keyframes tileFlyToHole {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.1) translateY(40px); opacity: 0; }
}

/* CENTER: THE BLACK HOLE */
.te-hole-container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1px 0;
  position: relative;
  height: 24px;
}

.te-hole {
  width: 48px;
  height: 22px;
  border-radius: 50%;
  background: var(--te-hole-bg);
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.85), 0 2px 4px rgba(255, 255, 255, 0.4);
  transition: transform 0.15s ease;
}

.te-hole.gulp {
  animation: holeGulp 0.25s ease;
}

@keyframes holeGulp {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); filter: brightness(1.4); }
}

/* CENTER: STOCK TRAY (5 SLOTS) */
.te-tray-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 330px;
  margin: 2px 0;
  position: relative;
}

.te-tray-slot {
  flex: 1;
  max-width: 52px;
  aspect-ratio: 1;
  background: var(--te-slot-bg);
  border-radius: 11px;
  box-shadow: var(--te-slot-shadow), 0 2px 4px rgba(255, 255, 255, 0.85);
  border: 1.5px solid rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.15s ease;
}

/* PALETTE BLOCKS (IN TRAY OR AS COLUMN FRONT) */
.te-palette-btn {
  width: 100%;
  height: 100%;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
  border: none;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.22), 0 4px 6px rgba(0, 0, 0, 0.15);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  position: relative;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.te-palette-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.22);
}

.te-tray-slot .te-palette-btn {
  animation: trayPopIn 0.22s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes trayPopIn {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* BOTTOM: 4-COLUMN WAITING PALETTES (NO SCROLLING) */
.te-columns-wrapper {
  width: 100%;
  max-width: 330px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  height: 52px;
  overflow: hidden; /* No scrolling! */
  padding: 2px;
  position: relative;
}

.te-column-lane {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  height: 100%;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  padding: 2px;
  border: 1px dashed rgba(110, 75, 50, 0.2);
}

.te-column-front {
  width: 100%;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.22), 0 5px 8px rgba(0, 0, 0, 0.15);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  position: relative;
  z-index: 5;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.te-column-front.pop-in {
  animation: frontPopIn 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes frontPopIn {
  0% { transform: scale(0.65) translateY(6px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.te-column-front:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.22);
}

.te-column-front.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
}

.te-column-empty {
  width: 100%;
  height: 48px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(110, 75, 50, 0.35);
  font-size: 16px;
  font-weight: 700;
  border: 1px dashed rgba(110, 75, 50, 0.25);
  box-sizing: border-box;
}

.te-column-queue {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  position: relative;
  margin-top: -4px;
}

.te-queue-item {
  width: 88%;
  height: 28px;
  margin-top: -14px;
  border-radius: 8px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 2px;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
  opacity: 0.85;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.te-queue-item.layer-1 {
  z-index: 3;
  width: 92%;
  height: 30px;
  margin-top: -10px;
  opacity: 0.92;
}

.te-queue-item.layer-2 {
  z-index: 2;
  width: 84%;
  height: 26px;
  margin-top: -12px;
  opacity: 0.75;
}

/* WALKING COLOR BOTS LAYER */
#te-bots-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 60;
  overflow: hidden;
}

.te-bot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35);
  transition: left 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), top 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.25s ease, opacity 0.25s ease;
  z-index: 70;
}

.te-bot-eyes {
  display: flex;
  gap: 3px;
  position: absolute;
  top: 5px;
}

.te-bot-eye {
  width: 4px;
  height: 5px;
  background: #ffffff;
  border-radius: 50%;
  position: relative;
}

.te-bot-eye::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  width: 2px;
  height: 2px;
  background: #222222;
  border-radius: 50%;
}

.te-bot-feet {
  display: flex;
  gap: 6px;
  position: absolute;
  bottom: -3px;
}

.te-bot-foot {
  width: 4px;
  height: 4px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 50%;
  animation: botWaddle 0.16s infinite alternate ease-in-out;
}

.te-bot-foot:nth-child(2) {
  animation-delay: 0.08s;
}

@keyframes botWaddle {
  0% { transform: translateY(0); }
  100% { transform: translateY(-2px); }
}

.te-bot.enter-hole {
  animation: botIntoHole 0.3s ease forwards;
}

@keyframes botIntoHole {
  0% { transform: scale(1) rotate(0deg); opacity: 1; }
  100% { transform: scale(0.08) rotate(220deg); opacity: 0; }
}

/* CONTROLS BAR */
.te-controls-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.45);
  border-top: 1px solid rgba(255, 255, 255, 0.65);
  width: 100%;
}

.te-btn {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: #4a2c1d;
  padding: 5px 10px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

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

.te-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* SCREEN & CANVAS STYLES */
#screen-tile-eating {
  background: var(--te-bg);
  background-image: var(--te-bg-gradient);
}

#te-confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 150;
}
