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

body {
    background: #fde4ec;
    color: #b04a72;
    font-family: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

.hidden {
    display: none !important;
}

.screen {
    min-height: 100vh;
    max-width: 480px;
    margin: 0 auto;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
}

.title {
    font-size: 34px;
    text-align: center;
    line-height: 1.2;
}

.subtitle {
    font-size: 17px;
    text-align: center;
    color: #c76b91;
}

/* --- Buttons --- */

.btn {
    background: #f7a8c4;
    color: white;
    border: none;
    border-radius: 16px;
    padding: 14px 32px;
    font-family: inherit;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(232, 138, 173, 0.35);
    transition: background 0.2s, scale 0.15s;
}

.btn:hover {
    background: #ee8cb0;
}

.btn:active {
    scale: 0.96;
}

/* --- Name input --- */

.stack-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.text-input {
    width: 100%;
    height: 58px;
    padding: 0 16px;
    background: white;
    color: #b04a72;
    border: 2px solid #f7c3d6;
    border-radius: 16px;
    font-family: inherit;
    font-size: 22px; /* 16px or more stops iPhones zooming in */
    font-weight: bold;
    text-align: center;
}

.text-input::placeholder {
    color: #e9b3c8;
}

.text-input:focus {
    outline: none;
    border-color: #f7a8c4;
}

.error-text {
    min-height: 22px;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}


.firebase-status {
    position: fixed;
    bottom: 12px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 13px;
    color: #c76b91;
}

/* --- Rooms --- */

.btn.wide {
    width: 100%;
}

.btn.btn-light {
    background: white;
    color: #b04a72;
    border: 2px solid #f7a8c4;
    box-shadow: none;
}

.divider {
    font-size: 15px;
    font-weight: bold;
    color: #e0a0bb;
}

.code-input {
    text-transform: uppercase;
    letter-spacing: 0.3em;
}

.room-code {
    font-size: 56px;
    font-weight: bold;
    letter-spacing: 0.2em;
    padding: 14px 28px 14px 40px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 24px rgba(176, 74, 114, 0.2);
}

.waiting {
    font-size: 18px;
    font-weight: bold;
}

.dots::after {
    content: "";
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%   { content: ""; }
    25%  { content: "."; }
    50%  { content: ".."; }
    75%  { content: "..."; }
}

/* --- Menu top bar --- */

.screen.menu {
    padding-top: 90px;
}

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    max-width: 480px;
    margin: 0 auto;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
}

.connected {
    font-size: 16px;
}

.name-pill {
    background: white;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(176, 74, 114, 0.15);
}

/* --- Game menu --- */

.game-list {
    width: 100%;
    max-width: 280px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.game-card {
    appearance: none;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    background: white;
    color: #b04a72;
    border: 2px solid #f7c3d6;
    border-radius: 18px;
    font-family: inherit;
    font-size: 20px;
    font-weight: bold;
    justify-content: center;
    text-align: center;    cursor: pointer;
    box-shadow: 0 8px 20px rgba(232, 138, 173, 0.2);
    transition: border-color 0.2s, scale 0.15s;
}

.game-card:hover {
    border-color: #f7a8c4;
}

.game-card:active {
    scale: 0.97;
}

.game-emoji {
    font-size: 30px;
}

/* --- Game screens --- */

.screen.game-screen {
    gap: 20px;
}

.turn-status {
    min-height: 30px;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
}

/* --- Tic-tac-toe --- */

.ttt-board {
    width: min(300px, 80vw);
    aspect-ratio: 1 / 1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr)); /* all rows the same height */
    gap: 10px;
}

.ttt-cell {
    appearance: none;
    min-width: 0;
    min-height: 0;
    padding: 0;
    background: white;
    border: 2px solid #f7c3d6;
    border-radius: 16px;
    font-size: 36px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.ttt-cell:focus {
    outline: none; /* no blue outline after tapping */
}
.ttt-cell.filled span {
    animation: pieceIn 0.25s ease;
}

.ttt-cell.win {
    background: #f7a8c4;
    border-color: #f7a8c4;
}

@keyframes pieceIn {
    from { opacity: 0; scale: 0.5; }
    to   { opacity: 1; scale: 1; }
}

/* --- Connect four --- */

.c4-board {
    width: min(340px, 92vw);
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
    background: #f7a8c4;
    border-radius: 18px;
    box-shadow: 0 10px 24px rgba(176, 74, 114, 0.25);
}

.c4-cell {
    appearance: none;
    position: relative;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #fde4ec; /* empty hole */
    cursor: pointer;
}

.c4-cell:focus {
    outline: none;
}

.c4-disc {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}

/* Disc colours: host = pink, guest = baby blue */
.c4-disc.host,
.disc-inline.host {
    background: #ef6f9f;
}

.c4-disc.guest,
.disc-inline.guest {
    background: #8fbdf2;
}

/* The winning four get a white ring */
.c4-disc.win {
    box-shadow: inset 0 0 0 4px white;
}

/* The newest disc falls into place */
.c4-disc.drop {
    animation: discDrop 0.35s ease-in;
}

@keyframes discDrop {
    from { transform: translateY(calc(var(--fall) * -1 * (100% + 6px))); }
    to   { transform: translateY(0); }
}

/* Small coloured dot in "u are ●" */
.disc-inline {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    vertical-align: -3px;
}

/* --- How in sync are we --- */

.sync-play,
.sync-results,
.sync-write,
.sync-answer {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sync-results {
    align-items: center;
    gap: 8px;
}

.sync-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sync-progress {
    font-size: 14px;
    font-weight: bold;
}

.progress-track {
    height: 10px;
    background: white;
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0;
    background: #f7a8c4;
    border-radius: 999px;
    transition: width 0.4s ease;
}

.text-input.sync-input {
    height: 52px;
    font-size: 18px;
}

.sync-question {
    font-size: 24px;
    line-height: 1.25;
    text-align: center;
}

.sync-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sync-option {
    appearance: none;
    background: white;
    color: #b04a72;
    border: 2px solid #f7c3d6;
    border-radius: 16px;
    padding: 14px 18px;
    font-family: inherit;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.sync-option:focus {
    outline: none;
}

.sync-option.picked {
    background: #f7a8c4;
    border-color: #f7a8c4;
    color: white;
}

.sync-option.locked {
    cursor: default;
}

.sync-reveal {
    background: white;
    border-radius: 16px;
    padding: 14px 18px;
    font-size: 18px;
    font-weight: bold;
    line-height: 1.7;
    text-align: center;
    box-shadow: 0 8px 20px rgba(232, 138, 173, 0.2);
}

.sync-percent {
    font-size: 72px;
    font-weight: bold;
    line-height: 1;
}

/* --- Heart burst when you match --- */

.burst-heart {
    position: fixed;
    left: 50%;
    top: 50%;
    font-size: 26px;
    pointer-events: none;
    z-index: 20;
    animation: burst 0.9s ease-out forwards;
}

@keyframes burst {
    from { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
    to   { transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1.2); opacity: 0; }
}

.sync-result {
    font-size: 18px;
    font-weight: bold;
    text-align: center;
}