/* ---------- Aesthetic + layout ---------- */
:root{
    --pastel-purple: #9851a0;
    --pastel-pink: #935874;
    --muted: #8f7a9e;
    --accent: #6f2e82;
}

* { box-sizing: border-box; }

body{
    margin: 0;
    font-family: 'Poppins', 'Gill Sans', Calibri, 'Trebuchet MS', sans-serif;
    background: linear-gradient(180deg, #653058 0%, #c76b90 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Topbar */
.topbar {
    width: 100%;
    padding: 20px;
    display:flex;
    gap: 20px;
    justify-content: space-between;
    align-items: center;
    max-width: 1000px;
}

/* cute button */
.cute-btn {
    background: linear-gradient(180deg, #a17fad, #f7d6f9);
    border: none;
    padding: 10px 18px;
    border-radius: 22px;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(130, 80, 150, 0.18);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cute-btn:hover { transform: translateY(-6px); box-shadow: 0 12px 26px rgba(130,80,150,0.22); }
.cute-btn:active { transform: translateY(-2px); }

/* Main layout */
.container{
    display: flex;
    gap: 24px;
    max-width: 1000px;
    width: 100%;
    padding: 10px;
    align-items: start;
}

/* HUD (left) */
.hud {
    width: 230px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-items: center;
}
.scoreboard {
    width: 100%;
    background: rgba(255,255,255,0.6);
    padding: 12px;
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(120, 60, 160, 0.08);
}
.score { display:flex; gap:10px; align-items:center; justify-content:center; font-weight:600; color:#5b365e;}
.mini-chibi { width:34px; height:34px; border-radius:50%; object-fit:cover; box-shadow: 0 4px 10px rgba(0,0,0,0.12); }

/* Game area (center) */
.game-area {
    flex: 1;
    display:flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    position: relative;
}

/* Winner text */
.winnerText {
    min-height: 28px;
    color: var(--accent);
    font-weight: 800;
    letter-spacing: 1px;
}

/* Board styling: using flex-wrap to keep your same grid system, but nicer visuals */
#board{
    height: 540px;
    width: 630px;
    background: linear-gradient(180deg, rgba(186, 109, 178, 0.85), rgba(230,210,255,0.6));
    border: 10px solid rgba(90,10,62,0.8);
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    border-radius: 24px;
    box-shadow: 0 12px 30px rgba(120, 40, 120, 0.12);
}

/* Tile style (you insisted on class "title") */
.title {
    height: 70px;
    width: 70px;
    margin: 5px;
    background-color: rgb(130, 129, 129);
    border-radius: 50%;
    border: 5px solid rgb(60, 5, 41);
    display: inline-block;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    transform-origin: center;
}

/* drop animation effect */
.title.drop {
    animation: dropAnim 300ms ease;
}
@keyframes dropAnim {
    from { transform: translateY(-60px); opacity: 0.6; }
    to   { transform: translateY(0); opacity: 1; }
}

/* pieces colors */
.purple-piece {
    background: linear-gradient(180deg,#9b59ff,#6f2e82);
    box-shadow: inset 0 -6px 12px rgba(0,0,0,0.12);
}

.pink-piece {
    background: linear-gradient(180deg,#ffb4d6,#ff76b8);
    box-shadow: inset 0 -6px 12px rgba(0,0,0,0.12);
}

/* highlight winning four */
.title.win {
    box-shadow: 0 0 18px 6px rgba(255, 210, 80, 0.18), 0 8px 30px rgba(255, 180, 50, 0.12);
    transform: scale(1.06);
}

/* chibi popup */
.chibiPopup {
    position: absolute;
    top: 8%;
    left: 50%;
    transform: translateX(-50%);
    width: 220px;
    transition: transform 0.25s ease;
    z-index: 40;
}
.chibiPopup.hidden { display:none; }

/* small ui row */
.ui-row { margin-top: 8px; display:flex; gap:8px; }

/* footer */
.footer { margin: 20px; color: #8b6e96; }

/* Turn display */
.turnDisplay { background: rgba(216, 110, 167, 0.7); padding:8px 12px; border-radius:12px; font-weight:700; color: #5b365e; }

/* responsive */
@media (max-width: 760px) {
    #board { width: 90vw; height: calc(90vw * 0.857); } /* keep approx ratio */
    .container { flex-direction: column; align-items:center; }
    .hud { width: 95%; order:2; }
}
/* INTRO SCREEN */
.intro-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, #8a3fa7, #d58ada);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 999;
}

.big-title {
    font-size: 6rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 8px 20px rgba(0,0,0,0.3);
    opacity: 1;
    transition: transform 1s ease, top 1s ease, font-size 1s ease, opacity 0.6s ease;
}

.big-title.shrink {
    position: absolute;
    top: 20px;
    font-size: 2.4rem;
    transform: translateY(0);
}

.start-btn {
    margin-top: 40px;
    padding: 14px 24px;
    background: linear-gradient(180deg,#d5a6e6,#fff0ff);
    border-radius: 24px;
    border: none;
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 28px rgba(0,0,0,0.22);
    transition: all 0.3s ease;
}

.start-btn:hover {
    transform: translateY(-6px);
}

.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Your CSS here — unchanged except adding intro screens */


.intro-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg,#653058 0%, #c76b90 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 30px;
    z-index: 200;
}

.intro-title {
    font-size: 5rem;
    color: white;
    animation: titleShrink 2s forwards;
}

@keyframes titleShrink {
    0% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.instructions-screen {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 180;
}

.instructions-box {
    background: white;
    padding: 30px;
    width: 350px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
}

.hidden { 
    display:none !important; 
}
.chibi {
    width: 150px;        /* bigger */
    height: auto;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
}

.left-chibi {
    left: -160px;        /* outside left edge */
}

.right-chibi {
    right: -160px;       /* outside right edge */
}
/* -- Particles -- */
.particle {
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff, rgba(255,255,255,0.9) 10%, rgba(255,200,255,0.6) 40%, transparent 70%);
  box-shadow: 0 6px 18px rgba(120, 40, 120, 0.18), inset 0 -4px 8px rgba(255,255,255,0.15);
  z-index: 9999;
}

/* larger side chibis and placement relative to the .game-area */
.chibi {
  width: 170px;
  height: auto;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 240ms ease;
  z-index: 40;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,0.18));
}

.left-chibi {
  left: calc(-170px - 24px); /* sits to left outside board */
}

.right-chibi {
  right: calc(-170px - 24px); /* sits to right outside board */
}

/* ensure center popup still looks fine */
.chibiPopup {
  width: 260px;
  z-index: 50;
}
.tile.highlighted {
    outline: 3px solid #ffffffaa;
    outline-offset: -2px;
}

.keyboard-preview {
    position: absolute;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 50;
    transform: translateY(-80px);
    transition: transform 0.15s ease, left 0.15s ease;
}

.keyboard-preview.purple {
    background: #a066ff;
    box-shadow: 0 0 12px #d2b2ff;
}

.keyboard-preview.pink {
    background: #ff7ccf;
    box-shadow: 0 0 12px #ffc9eb;
}

.keyboard-preview.hidden {
    opacity: 0;
}

.title.highlighted {
    outline: 3px solid white;
    border-radius: 50%;
}
.end-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 500;
}

.end-overlay.hidden {
    display: none;
}

.end-box {
    background: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 320px;
    box-shadow: 0 0 20px rgba(0,0,0,0.4);
}

.end-winner {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 15px;
    color: var(--pastel-purple);
}

.end-loser {
    font-size: 1.2rem;
    margin-top: 15px;
    color: var(--pastel-pink);
}

.end-chibi {
    width: 120px;
    margin: 15px 0;
}





