/* --- Global Styles & Variables --- */
:root {
  --primary-color: rgba(255, 204, 229, 0.85); /* Pastel Pink */
  --secondary-color: rgba(204, 242, 255, 0.85); /* Pastel Blue */
  --accent-color: rgba(255, 246, 204, 0.85); /* Pastel Yellow */
  --tile-color: rgba(212, 231, 212, 0.85); /* Pastel Green */
  --white-transparent: rgba(255, 255, 255, 0.85);
  --text-color: #333;
  --font-family: 'Poppins', sans-serif;
  --border-radius: 12px;
  --box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font-family);
  color: var(--text-color);
  -webkit-user-select: none; /* Safari */
  -ms-user-select: none; /* IE 10+ */
  user-select: none;
  background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA4MDAgNjAwIj48cmVjdCB3aWR0aD0iODAwIiBoZWlnaHQ9IjYwMCIgZmlsbD0iI2EwZTlmZiIvPjxjaXJjbGUgY3g9IjcwMCIgY3k9IjEwMCIgcj0iNjAiIGZpbGw9IiNmZmQ3MDAiLz48ZWxsaXBzZSBjeD0iMjAwIiBjeT0iMTUwIiByeD0iODAiIHJ5PSI1MCIgZmlsbD0id2hpdGUiIG9wYWNpdHk9IjAuOSIvPjxlbGxpcHNlIGN4PSI0NTAiIGN5PSIxMjAiIHJ4PSIxMDAiIHJ5PSI2MCIgZmlsbD0id2hpdGUiIG9wYWNpdHk9IjAuOSIvPjxwYXRoIGQ9Ik0gMCA0MDAgQyAxNTAgMzUwLCAzMDAgNDUwLCA1MDAgNDIwIFMgODAwIDUwMCwgODAwIDUwMCBWIDYwMCBIIDAgWiIgZmlsbD0iI2I0ZjJhMSIvPjxwYXRoIGQ9Ik0gMCA0ODAgQyAyMDAgNDUwLCA0MDAgNTIwLCA2MDAgNDkwIFMgODAwIDU1MCwgODAwIDU1MCBWIDYwMCBIIDAgWiIgZmlsbD0iIzc5ZDc3OSIvPjwhLS0gVHJlZSAxIChyaWdodCBzaWRlKSAtLT48cmVjdCB4PSI1ODAiIHk9IjM5MCIgd2lkdGg9IjIwIiBoZWlnaHQ9IjcwIiBmaWxsPSIjOEI1QTJCIi8+PGNpcmNsZSBjeD0iNTkwIiBjeT0iMzYwIiByPSI1NSIgZmlsbD0iIzNDQjM3MSIvPjwhLS0gVHJlZSAyIChsZWZ0IHNpZGUpIC0tPjxyZWN0IHg9IjE1MCIgeT0iMzYwIiB3aWR0aD0iMjUiIGhlaWdodD0iOTAiIGZpbGw9IiM4QjVBMkIiLz48Y2lyY2xlIGN4PSIxNjIiIGN5PSIzMzAiIHI9IjcwIiBmaWxsPSIjMkU4QjU3Ii8+PC9zdmc+');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

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

.btn {
  padding: 12px 24px;
  font-size: 1.2rem;
  font-family: var(--font-family);
  font-weight: 600;
  background-color: var(--primary-color);
  border: 2px solid var(--text-color);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: transform 0.2s, background-color 0.2s;
  box-shadow: var(--box-shadow);
}

.btn:hover {
  transform: translateY(-2px);
  background-color: rgba(255, 179, 217, 0.95);
}

/* --- Screen Management --- */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  padding: 20px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

.screen.active {
  display: flex;
}

/* --- Config Screen --- */
.config-box {
  background-color: var(--secondary-color);
  padding: 40px;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.config-box h1 {
  font-size: 2.5rem;
  font-weight: 700;
}

.form-group {
  font-size: 1.2rem;
}

.form-group label {
  margin-right: 10px;
}

.form-group input, .form-group select {
  padding: 8px;
  font-size: 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--text-color);
  font-family: var(--font-family);
}

/* --- Spelling Game Screen --- */
#player-indicator {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 1.5rem;
    font-weight: 600;
    background-color: var(--accent-color);
    padding: 10px 15px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.spelling-game-area {
    display: flex;
    align-items: center;
    gap: 40px;
}

#image-container {
    font-size: 10rem; /* Large emoji */
    width: 160px;
    height: 160px;
    background-color: var(--white-transparent);
    padding: 10px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    display: flex;
    justify-content: center;
    align-items: center;
}

#image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

#word-container {
    display: flex;
    gap: 10px;
}

.letter-box {
    width: 80px;
    height: 100px;
    border: 3px solid var(--text-color);
    border-radius: var(--border-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3.5rem;
    font-weight: 600;
    background-color: var(--white-transparent);
}

.letter-box.empty {
    background-color: var(--secondary-color);
    border-style: dashed;
}

.letter-box.correct {
    background-color: rgba(170, 255, 170, 0.9);
    animation: bounce 0.5s ease;
}

#letter-tiles-container {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.letter-tile {
    width: 70px;
    height: 70px;
    background-color: var(--tile-color);
    border: 2px solid var(--text-color);
    border-radius: var(--border-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    font-weight: 600;
    cursor: grab;
    box-shadow: var(--box-shadow);
    transition: transform 0.2s;
}

.letter-tile:hover {
    transform: scale(1.1);
}

.letter-tile.dragging {
    opacity: 0.5;
    cursor: grabbing;
    z-index: 100;
}

#feedback-message {
    position: absolute;
    bottom: 30px;
    padding: 15px 30px;
    font-size: 1.8rem;
    font-weight: 600;
    border-radius: var(--border-radius);
    transition: opacity 0.5s, transform 0.5s;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

#feedback-message.correct, #feedback-message.incorrect {
    opacity: 1;
    transform: translateY(0);
}

#feedback-message.correct {
    background-color: rgba(170, 255, 170, 0.9);
}

#feedback-message.incorrect {
    background-color: rgba(255, 170, 170, 0.9);
    animation: shake 0.5s;
}

/* --- Memory Game Screen --- */
#memory-screen {
    justify-content: flex-start;
}
.memory-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    margin-bottom: 20px;
}
#memory-player-indicator, #memory-score-container {
    font-size: 1.5rem;
    font-weight: 600;
    background-color: var(--white-transparent);
    padding: 10px 15px;
    border-radius: var(--border-radius);
}
#memory-score-container {
    display: flex;
    gap: 20px;
}
#memory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
    width: 100%;
    max-width: 900px;
    perspective: 1000px;
}

.memory-card {
    height: 120px;
    background-color: transparent;
    cursor: pointer;
    border-radius: var(--border-radius);
}

.memory-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    box-shadow: var(--box-shadow);
    border-radius: var(--border-radius);
}

.memory-card.flipped .memory-card-inner {
    transform: rotateY(180deg);
}

.memory-card.matched {
    opacity: 0.5;
    pointer-events: none;
}

.memory-card-front, .memory-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: var(--border-radius);
    display: flex;
    justify-content: center;
    align-items: center;
}

.memory-card-front {
    background-color: var(--primary-color);
    border: 2px solid var(--text-color);
}

.memory-card-back {
    background-color: var(--accent-color);
    transform: rotateY(180deg);
    font-size: 4rem;
    padding: 5px;
}

.memory-card-back img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* --- Summary Screen --- */
.summary-box {
  background-color: var(--secondary-color);
  padding: 40px;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.summary-box h1 {
  font-size: 2.5rem;
  font-weight: 700;
}
#final-scores p {
  font-size: 1.5rem;
}

/* --- Orientation Warning --- */
#orientation-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    color: white;
    z-index: 1000;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 1.5rem;
    flex-direction: column;
}

@media (orientation: portrait) {
    #orientation-warning {
        display: flex;
    }
    #app-container {
        display: none;
    }
}


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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
