

:root {
  --game-bg: #87CEEB; /* Sky Blue */
  --text-color: #333;
  --player-color: #007BFF; /* Blue */
  --brick-color: #A52A2A; /* Brown */
  --overlay-bg: rgba(255, 255, 255, 0.85);
  --button-color: #4CAF50;
  --button-hover-color: #45a049;
  --secondary-button-color: #f44336;
  --secondary-button-hover-color: #da190b;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Noto Sans KR', sans-serif;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #f0f0f0;
}

#root {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
  width: 100%;
  max-width: 400px;
  height: 100%;
  max-height: 700px;
  background-color: var(--game-bg);
  position: relative;
  overflow: hidden;
  border: 2px solid #333;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  user-select: none;
  touch-action: none; /* Prevents default touch actions like scrolling */
  transition: background-color 0.5s ease, background-image 0.5s ease;
}

#creator-credit {
  position: absolute;
  top: 15px;
  left: 15px;
  color: white;
  font-size: 0.9rem;
  font-weight: bold;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
  z-index: 15;
}

/* Background Skins */
#game-container.bg-sky { background-color: #87CEEB; background-image: none; }
#game-container.bg-night { background-image: linear-gradient(to bottom, #000428, #004e92); }
#game-container.bg-sunset { background-image: linear-gradient(to bottom, #ff7e5f, #feb47b); }
#game-container.bg-forest { background-image: linear-gradient(to bottom, #294832, #577d63); }
#game-container.bg-cosmos { background-image: linear-gradient(to bottom, #141E30, #243B55); }
#game-container.bg-sakura { background-image: linear-gradient(to bottom, #fde4e4, #f8c3c3); }
#game-container.bg-ocean { background-image: linear-gradient(to bottom, #00c6ff, #0072ff); }
#game-container.bg-synthwave { background-image: linear-gradient(to bottom, #4A00E0, #8E2DE2); }


.wall {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  background-color: #6d4c41;
  z-index: 5;
  box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
}

#left-wall {
  left: 0;
}

#right-wall {
  right: 0;
}

#player {
  width: 50px;
  height: 20px;
  border-radius: 8px;
  position: absolute;
  bottom: 10px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.3);
  z-index: 6; /* Player is in front of walls */
  transition: box-shadow 0.2s ease;
  display: none; /* Initially hidden */
}

/* Player Skins */
.player-classic {
  background: linear-gradient(180deg, #4da3ff, var(--player-color));
  border: 1px solid #0056b3;
}
.player-racer {
  background: linear-gradient(180deg, #ff416c, #ff4b2b);
  border: 1px solid #c10f0f;
}
.player-stealth {
  background: linear-gradient(180deg, #555, #222);
  border: 1px solid #000;
}
.player-gold {
  background: linear-gradient(180deg, #fff59d, #ffca28);
  border: 1px solid #ff8f00;
}
.player-hologram {
  background: linear-gradient(45deg, #00ffff, #ff00ff, #ffff00, #00ffff);
  background-size: 400% 400%;
  border: 1px solid #fff;
  animation: hologram-shift 4s ease infinite;
}
@keyframes hologram-shift {
  0%{background-position:0% 50%}
  50%{background-position:100% 50%}
  100%{background-position:0% 50%}
}
.player-wood {
  background: linear-gradient(180deg, #b9936c, #8a6e4b);
  border: 1px solid #5a452a;
}
.player-galaxy {
  background: linear-gradient(180deg, #434371, #24243e);
  border: 1px solid #6a5acd;
  box-shadow: 0 0 5px #fff, inset 0 0 2px #fff;
}
.player-camo {
  background-color: #556B2F;
  background-image:
    linear-gradient(45deg, #4B5320 25%, transparent 25%),
    linear-gradient(-45deg, #4B5320 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #4B5320 75%),
    linear-gradient(-45deg, transparent 75%, #4B5320 75%);
  background-size: 20px 20px;
  border: 1px solid #3B4B21;
}

.shield-active {
    box-shadow: 0 0 15px 5px rgba(0, 255, 255, 0.8), inset 0 0 5px rgba(255, 255, 255, 0.5);
}

.invincible {
  animation: invincible-blink 0.2s linear infinite;
}

@keyframes invincible-blink {
  50% {
    opacity: 0.5;
  }
}

.fever-active {
  animation: rainbow-glow 0.5s linear infinite;
}

@keyframes rainbow-glow {
  0%   { box-shadow: 0 0 15px 5px #ff0000, inset 0 0 5px rgba(255, 255, 255, 0.5); }
  16%  { box-shadow: 0 0 15px 5px #ff7f00, inset 0 0 5px rgba(255, 255, 255, 0.5); }
  33%  { box-shadow: 0 0 15px 5px #ffff00, inset 0 0 5px rgba(255, 255, 255, 0.5); }
  50%  { box-shadow: 0 0 15px 5px #00ff00, inset 0 0 5px rgba(255, 255, 255, 0.5); }
  66%  { box-shadow: 0 0 15px 5px #0000ff, inset 0 0 5px rgba(255, 255, 255, 0.5); }
  83%  { box-shadow: 0 0 15px 5px #4b0082, inset 0 0 5px rgba(255, 255, 255, 0.5); }
  100% { box-shadow: 0 0 15px 5px #ee82ee, inset 0 0 5px rgba(255, 255, 255, 0.5); }
}

#player.magnet-active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300px; 
    height: 300px;
    background: rgba(142, 68, 173, 0.15);
    border: 2px solid rgba(142, 68, 173, 0.5);
    border-radius: 50%;
    animation: magnet-pulse 2s infinite ease-out;
    pointer-events: none;
    z-index: -1;
    transform: translate(-50%, -50%);
}

@keyframes magnet-pulse {
    0% {
        transform: translate(-50%, -50%) scale(0.95);
        opacity: 0.7;
    }
    70% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(0.95);
        opacity: 0.7;
    }
}


.brick {
  width: 40px;
  height: 20px;
  position: absolute;
  border-radius: 2px;
  z-index: 4;
  background-color: var(--brick-color); /* Fallback color */
}

/* Brick Skins */
.brick-classic {
  background: linear-gradient(180deg, #e08d5b, var(--brick-color));
  border: 1px solid #800000;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.2);
}

.brick-ice {
  background: linear-gradient(180deg, #e1ffff, #b2ebf2);
  border: 1px solid #4dd0e1;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.1);
}

.brick-gold {
  background: linear-gradient(180deg, #fff59d, #ffca28);
  border: 1px solid #ff8f00;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.2);
}

.brick-stone {
  background: linear-gradient(180deg, #bdbdbd, #757575);
  border: 1px solid #424242;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.3);
}

.brick-emerald {
  background: linear-gradient(180deg, #a4ffce, #50C878);
  border: 1px solid #009B77;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.2);
}

.brick-ruby {
  background: linear-gradient(180deg, #ff7d9e, #E0115F);
  border: 1px solid #9B111E;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.2);
}

.brick-amethyst {
  background: linear-gradient(180deg, #d3b3ff, #9966CC);
  border: 1px solid #6A0DAD;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.2);
}

.brick-obsidian {
  background: linear-gradient(180deg, #485461, #28313b);
  border: 1px solid #000;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.3);
}

.item {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  z-index: 4;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  color: white;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.item.shield {
  background: radial-gradient(circle, #64b5f6, #1976d2);
}
.item.shield::before {
  content: '🛡️';
  font-size: 1.2rem;
}

.item.slow-mo {
  background: radial-gradient(circle, #fff59d, #fbc02d);
}
.item.slow-mo::before {
  content: '⏳';
  font-size: 1.2rem;
}

.item.health {
  background: radial-gradient(circle, #ff8a80, #d50000);
}
.item.health::before {
  content: '❤️';
  font-size: 1.2rem;
}

.item.fever {
  background: radial-gradient(circle, #ff9800, #ff5722);
}
.item.fever::before {
  content: '🔥';
  font-size: 1.2rem;
}

.item.coin {
  background: radial-gradient(circle, #ffd700, #f9a825);
}
.item.coin::before {
  content: '💰';
  font-size: 1.2rem;
}

.item.clear {
  background: radial-gradient(circle, #888, #333);
}
.item.clear::before {
  content: '💣';
  font-size: 1.2rem;
}

.item.score-multiplier {
  background: radial-gradient(circle, #e040fb, #9c27b0);
}
.item.score-multiplier::before {
  content: '⭐';
  font-size: 1.2rem;
}

.item.time-stop {
  background: radial-gradient(circle, #a1c4fd, #c2e9fb);
}
.item.time-stop::before {
  content: '⏱️';
  font-size: 1.2rem;
}

.item.magnet {
  background: radial-gradient(circle, #7e57c2, #4527a0);
}
.item.magnet::before {
  content: '🧲';
  font-size: 1.2rem;
}


.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    z-index: 100;
    pointer-events: none; /* Make sure they don't interfere with clicks */
}


#score-board {
  position: absolute;
  top: 10px;
  width: 100%;
  text-align: center;
  color: var(--text-color);
  font-size: 1.5rem;
  font-weight: bold;
  z-index: 10;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
}

#score-board p {
  margin: 4px 0;
}

#health-bar {
  font-size: 1.5rem;
  line-height: 1;
  text-shadow: 1px 1px 2px rgba(255,0,0,0.5);
}

#item-status {
  font-size: 1.5rem;
  margin-top: 5px;
}

#item-description-container {
  background: rgba(0,0,0,0.1);
  color: var(--text-color);
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 0.9rem;
  border: 1px solid rgba(0,0,0,0.1);
  margin-bottom: 20px;
  width: 90%;
  max-width: 320px;
  text-align: left;
}

#item-description-container h4 {
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(0,0,0,0.2);
  padding-bottom: 5px;
  text-align: center;
  font-size: 1rem;
}

#item-description-container p {
  margin: 5px 0;
  color: #333;
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--overlay-bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  z-index: 20;
  padding: 20px;
  overflow-y: auto;
}

.overlay h1 {
  font-size: 3rem;
  color: var(--text-color);
  margin-bottom: 20px;
}

.overlay p {
    font-size: 1.2rem;
    margin-bottom: 30px;
    color: #555;
}

#start-screen {
  background: transparent;
  justify-content: center;
}

#start-screen h1 {
  font-size: 3.5rem;
  color: white;
  margin-bottom: 25px;
  text-shadow: 3px 3px 10px rgba(0, 0, 0, 0.7);
  animation: title-glow 2.5s ease-in-out infinite;
}

@keyframes title-glow {
    0%, 100% {
        text-shadow: 3px 3px 10px rgba(0, 0, 0, 0.7), 0 0 5px rgba(255, 255, 255, 0.2);
    }
    50% {
        text-shadow: 3px 3px 15px rgba(0, 0, 0, 0.9), 0 0 15px rgba(255, 255, 255, 0.4);
    }
}

#skin-showcase {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 15px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    text-align: center;
    margin-bottom: 30px;
    width: 80%;
    max-width: 250px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

#skin-showcase > p {
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 15px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 8px;
}

#showcase-items-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    min-height: 40px;
}

#new-high-score-message {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ff4500;
    margin-bottom: 15px;
    animation: bounce 0.8s ease-in-out;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

#easter-egg-message {
    font-size: 1.5rem;
    font-weight: bold;
    color: #8E2DE2;
    margin-bottom: 15px;
    animation: celebrate-glow 1.2s ease-in-out infinite;
    text-shadow: 0 0 5px rgba(255,255,255,0.7);
}

#easter-egg-message small {
    display: block;
    font-size: 0.9rem;
    color: #555;
    font-weight: normal;
    margin-top: 5px;
    animation: none;
    text-shadow: none;
}

@keyframes celebrate-glow {
    0%, 100% {
        transform: scale(1);
        opacity: 0.9;
    }
    50% {
        transform: scale(1.05);
        opacity: 1;
    }
}


#main-menu-buttons,
#pause-buttons,
#game-over-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 80%;
    max-width: 250px;
}

#main-menu-buttons {
    background-color: rgba(0, 0, 0, 0.25);
    padding: 25px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

#difficulty-selection {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 80%;
    max-width: 280px;
    margin-bottom: 20px;
}

.difficulty-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-bottom: 8px;
}

#start-game-btn {
  padding: 20px 40px;
  font-size: 1.5rem;
}

#game-over-buttons {
    flex-direction: row;
    gap: 10px;
}

.overlay button {
  width: 100%;
  max-width: 250px;
  padding: 15px 20px;
  font-size: 1.2rem;
  font-weight: bold;
  font-family: 'Noto Sans KR', sans-serif;
  color: white;
  background-color: var(--button-color);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.1s ease;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

#game-over-buttons button {
  font-size: 1rem;
  padding: 12px 15px;
  flex: 1;
  white-space: nowrap; /* Prevent text wrapping */
}
#select-difficulty-button,
#retry-pause-button {
  background-color: #008CBA;
}
#select-difficulty-button:hover,
#retry-pause-button:hover {
  background-color: #007399;
}

.overlay button:hover {
  background-color: var(--button-hover-color);
}

.overlay button:active {
    transform: translateY(2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#item-description-btn,
#view-rankings-btn, 
#customize-btn {
  background-color: #6c757d;
  font-size: 1.1rem;
  padding: 12px 18px;
}
#item-description-btn:hover,
#view-rankings-btn:hover, 
#customize-btn:hover {
  background-color: #5a6268;
}

.difficulty-btn[data-difficulty="god"] {
    background: linear-gradient(45deg, #ff8c00, #ff0080);
    border: 2px solid white;
}

.difficulty-btn[data-difficulty="god"]:hover {
    background: linear-gradient(45deg, #ffA500, #ff1493);
}

.difficulty-btn[data-difficulty="transcendence"] {
    background: linear-gradient(45deg, #480048, #C04848);
    border: 2px solid white;
}
.difficulty-btn[data-difficulty="transcendence"]:hover {
    background: linear-gradient(45deg, #600060, #D05858);
}

.difficulty-btn[data-difficulty="void"] {
    background: linear-gradient(45deg, #0f0c29, #302b63, #24243e);
    border: 2px solid white;
    color: #e0e0e0;
}
.difficulty-btn[data-difficulty="void"]:hover {
    background: linear-gradient(45deg, #1c183a, #423c7e, #333352);
}

.difficulty-btn[data-difficulty="cataclysm"] {
    background: linear-gradient(45deg, #ff4e50, #f9d423);
    border: 2px solid white;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
}
.difficulty-btn[data-difficulty="cataclysm"]:hover {
    background: linear-gradient(45deg, #ff686a, #fadf55);
}


.back-button {
  margin-top: 20px;
  background-color: #6c757d;
}

.back-button:hover {
  background-color: #5a6268;
}

#back-to-start-button,
#back-to-start-game-over-btn {
    background-color: var(--secondary-button-color);
}

#back-to-start-button:hover,
#back-to-start-game-over-btn:hover {
    background-color: var(--secondary-button-hover-color);
}

#pause-button {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 40px;
  height: 40px;
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--text-color);
  background-color: rgba(255, 255, 255, 0.6);
  border: 2px solid var(--text-color);
  border-radius: 50%;
  cursor: pointer;
  z-index: 15;
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 1;
  padding-bottom: 2px; /* Visual alignment for the pause icon */
  transition: background-color 0.2s ease;
}

#pause-button:hover {
  background-color: rgba(255, 255, 255, 0.9);
}

/* Customize Screen */
.customize-section {
  width: 100%;
  margin-bottom: 20px;
}
.customize-section h2 {
  font-size: 1.5rem;
  margin-bottom: 10px;
  color: #444;
}
.skin-selection-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
}
.skin-option {
  width: 60px;
  height: 60px;
  border: 3px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
  background-size: cover;
  background-position: center;
}
.skin-option:hover {
  transform: scale(1.05);
}
.skin-option.selected {
  border-color: #007bff;
  box-shadow: 0 0 10px rgba(0, 123, 255, 0.5);
}

.skin-option.brick-preview {
    height: 40px; /* Adjust height for brick aspect ratio */
}

.skin-option.player-preview {
    width: 50px;
    height: 20px;
    border-radius: 8px;
}

/* Player Skin Previews */
.player-classic-preview { background: linear-gradient(180deg, #4da3ff, var(--player-color)); border: 1px solid #0056b3; }
.player-racer-preview { background: linear-gradient(180deg, #ff416c, #ff4b2b); border: 1px solid #c10f0f; }
.player-stealth-preview { background: linear-gradient(180deg, #555, #222); border: 1px solid #000; }
.player-gold-preview { background: linear-gradient(180deg, #fff59d, #ffca28); border: 1px solid #ff8f00; }
.player-hologram-preview { background: linear-gradient(45deg, #00ffff, #ff00ff, #ffff00, #00ffff); background-size: 200% 200%; }
.player-wood-preview { background: linear-gradient(180deg, #b9936c, #8a6e4b); border: 1px solid #5a452a; }
.player-galaxy-preview { background: linear-gradient(180deg, #434371, #24243e); border: 1px solid #6a5acd; }
.player-camo-preview { background-color: #556B2F; background-image: linear-gradient(45deg, #4B5320 25%, transparent 25%), linear-gradient(-45deg, #4B5320 25%, transparent 25%); background-size: 10px 10px;}


/* Brick Skin Previews */
.brick-classic-preview { background: linear-gradient(180deg, #e08d5b, var(--brick-color)); }
.brick-ice-preview { background: linear-gradient(180deg, #e1ffff, #b2ebf2); }
.brick-gold-preview { background: linear-gradient(180deg, #fff59d, #ffca28); }
.brick-stone-preview { background: linear-gradient(180deg, #bdbdbd, #757575); }
.brick-emerald-preview { background: linear-gradient(180deg, #a4ffce, #50C878); }
.brick-ruby-preview { background: linear-gradient(180deg, #ff7d9e, #E0115F); }
.brick-amethyst-preview { background: linear-gradient(180deg, #d3b3ff, #9966CC); }
.brick-obsidian-preview { background: linear-gradient(180deg, #485461, #28313b); }

/* Ranking Screen */
#ranking-list {
    list-style-type: none;
    padding: 0;
    width: 100%;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.5);
}

#ranking-list li {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    font-size: 1.1rem;
    border-bottom: 1px solid #ddd;
    color: #333;
}

#ranking-list li:last-child {
    border-bottom: none;
}

#ranking-list .rank-position {
    font-weight: bold;
    min-width: 30px;
}

#ranking-list .rank-score {
    flex-grow: 1;
    text-align: center;
}

#ranking-list .rank-difficulty {
    font-size: 0.9rem;
    color: #555;
    min-width: 60px;
    text-align: right;
    text-transform: capitalize;
}

/* Countdown Overlay */
#countdown-overlay {
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 8rem;
    font-weight: bold;
    text-shadow: 0 0 20px rgba(0,0,0,0.8);
    z-index: 25;
    pointer-events: none;
}

#countdown-text {
    animation: countdown-pulse 1s ease-in-out infinite;
    transform-origin: center;
}

@keyframes countdown-pulse {
  0% { transform: scale(1.1); opacity: 0.8; }
  50% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.1); opacity: 0.8; }
}


.hidden {
  display: none;
}