:root {
  --color-pink: #ff69b4;
  --color-blue: #1e90ff;
  --color-green: #32cd32;
  --color-yellow: #ffd700;
  --bg-dark: #2a2a72;
  --bg-light: #4f4f9f;
  --font-family: 'Fredoka One', cursive;
  --text-color: #ffffff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  overflow-x: hidden;
  font-family: var(--font-family);
  color: var(--text-color);
}

body {
  background: linear-gradient(135deg, var(--bg-dark), var(--bg-light));
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1rem;
  min-height: 100vh;
}

#app {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-grow: 1;
}

.title {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 400; /* Fredoka One is already bold */
  letter-spacing: 2px;
  color: var(--text-color);
  text-shadow: 4px 4px 0px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.title-icon {
    width: 2rem;
    height: 2rem;
    filter: drop-shadow(4px 4px 0px rgba(0,0,0,0.2));
}

.game-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    padding: 1rem;
}

.wheel-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.username-container {
    width: 80%;
    max-width: 300px;
}

#usernameInput {
    width: 100%;
    padding: 12px 20px;
    font-family: var(--font-family);
    font-size: 1.2rem;
    color: var(--text-color);
    background-color: rgba(0, 0, 0, 0.2);
    border: 3px solid var(--color-blue);
    border-radius: 12px;
    text-align: center;
    box-shadow: inset 0 0 8px rgba(0,0,0,0.4);
    outline: none;
    transition: all 0.2s ease;
}

#usernameInput::placeholder {
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    font-size: 1rem;
}

#usernameInput:focus {
    border-color: var(--color-yellow);
    box-shadow: inset 0 0 8px rgba(0,0,0,0.4), 0 0 15px var(--color-yellow);
}

#wheelCanvas {
  max-width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
}

#winners-container {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    padding: 1.5rem;
    width: 300px;
    height: clamp(380px, 50vh, 450px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    border: 3px solid var(--color-blue);
    display: flex;
    flex-direction: column;
}

#winners-container h2 {
    font-size: 1.8rem;
    color: var(--color-yellow);
    margin-bottom: 1rem;
    text-shadow: 2px 2px 0px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.header-icon {
    width: 2rem;
    height: 2rem;
}

#winners-list {
    list-style: none;
    padding: 0;
    margin: 0;
    height: 100%;
    overflow-y: auto;
    text-align: left;
}

.winner-item {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border-radius: 15px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 2px solid transparent;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, bob 3s ease-in-out infinite;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.winner-avatar {
    width: 45px;
    height: 45px;
    border-radius: 20%; /* Blocky shape */
    flex-shrink: 0;
    border: 2px solid white;
    position: relative; /* For accessories */
}

/* Eyes for the avatar */
.winner-avatar .eyes {
    position: absolute;
    top: 35%;
    left: 50%;
    width: 60%;
    height: 15%;
    transform: translateX(-50%);
}

.winner-avatar .eyes::before,
.winner-avatar .eyes::after {
    content: '';
    position: absolute;
    top: 0;
    width: 8px; /* Eye width */
    height: 8px; /* Eye height */
    background-color: #2c2c2c;
    border-radius: 50%;
    animation: blink 4s infinite;
}

.winner-avatar .eyes::before { left: 0; }
.winner-avatar .eyes::after { right: 0; }

@keyframes blink {
    0%, 90%, 100% { transform: scaleY(1); }
    95% { transform: scaleY(0.1); }
}

/* Avatar Accessories */
.winner-avatar.hat::before {
    content: '';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%) rotate(-15deg);
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-bottom: 20px solid var(--color-pink);
}

.winner-avatar.glasses::before {
    content: '';
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
    width: 110%;
    height: 10px;
    background-color: #333;
    border-radius: 2px;
    z-index: 1;
}

.winner-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    flex-grow: 1;
}

.winner-name {
    font-weight: bold;
    font-size: 1.1rem;
}

.prize-amount {
    font-size: 1rem;
    color: var(--text-color);
    opacity: 0.9;
}

/* Prize Tier Glows */
.winner-item.common {
    border-color: var(--color-green);
    box-shadow: 0 0 10px var(--color-green);
}
.winner-item.rare {
    border-color: var(--color-blue);
    box-shadow: 0 0 12px var(--color-blue);
}
.winner-item.jackpot {
    border-color: var(--color-yellow);
    box-shadow: 0 0 15px var(--color-yellow);
}

.prize-amount.bounce {
    animation: highlight-and-bounce 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes highlight-and-bounce {
    0%, 100% { transform: scale(1); text-shadow: none; }
    25% { transform: scale(1.3); color: var(--color-yellow); text-shadow: 0 0 10px var(--color-yellow); }
    50% { transform: scale(0.9); }
    75% { transform: scale(1.1); }
}

.ui-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#spinButton {
  font-family: var(--font-family);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 400;
  color: var(--bg-dark);
  background-color: var(--color-yellow);
  border: none;
  border-radius: 15px;
  padding: 15px 40px;
  cursor: pointer;
  text-transform: uppercase;
  box-shadow: 0 6px 0px #cda800, 0 8px 15px rgba(0,0,0,0.3);
  transition: all 0.1s ease-in-out;
}

#spinButton:hover:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 4px 0px #cda800, 0 6px 10px rgba(0,0,0,0.3);
}

#spinButton:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 2px 0px #cda800, 0 4px 5px rgba(0,0,0,0.4);
}

#spinButton:disabled {
  cursor: not-allowed;
  opacity: 0.7;
  background-color: #a78800;
  box-shadow: 0 4px 0px #886e00, 0 6px 10px rgba(0,0,0,0.3);
  transform: translateY(2px);
}

.win-announcement {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    vertical-align: middle;
}

.popup-icon {
    width: 1.2em; /* Scales with font size */
    height: 1.2em;
}

.prize-popup {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: var(--bg-light);
  border: 4px solid var(--color-yellow);
  border-radius: 15px;
  padding: 40px;
  text-align: center;
  z-index: 10;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}

.prize-popup:not(.hidden) {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.prize-popup.hidden {
    display: none;
}

#prizeText {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 700;
  color: var(--text-color);
  text-shadow: 2px 2px 0px rgba(0,0,0,0.2);
}

#closePopup {
  font-family: var(--font-family);
  font-size: 1.2rem;
  color: var(--bg-dark);
  background-color: var(--color-green);
  border: none;
  border-radius: 10px;
  padding: 10px 25px;
  cursor: pointer;
  box-shadow: 0 4px 0px #27a327;
  transition: all 0.1s ease;
}

#closePopup:hover {
  background-color: #38e038;
  transform: translateY(-2px);
  box-shadow: 0 6px 0px #27a327;
}

.footer-note {
  padding: 1rem;
  text-align: center;
  width: 100%;
  max-width: 700px;
  margin-top: 2rem;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  line-height: 1.5;
}

@media (max-width: 820px) {
    .game-container {
        flex-direction: column;
    }
    #winners-container {
        width: 90vw;
        max-width: 400px;
        height: 300px;
    }
    .prize-popup {
        width: 90vw;
        padding: 20px;
    }
    #prizeText {
        font-size: clamp(1.2rem, 5vw, 1.8rem);
    }
}