:root {
    --bg: #f5f5f7;
    --bg-card: #ffffff;
    --accent: #e94560;
    --accent-hover: #ff6b6b;
    --text: #1d1d1f;
    --text-muted: #6e6e73;
    --success: #34c759;
    --out: #8e8e93;
}

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

body {
    font-family: 'Prompt', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1rem;
    -webkit-tap-highlight-color: transparent;
}

#app {
    max-width: 420px;
    margin: 0 auto;
    min-height: 100vh;
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 2rem 1rem;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.hero {
    text-align: center;
    margin-bottom: 3rem;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #ff9a9e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.rejoin-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e5ea;
    width: 100%;
}

.rejoin-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.form-rejoin {
    display: flex;
    gap: 0.5rem;
}

.form-rejoin input {
    flex: 1;
}

.btn-outline {
    padding: 1rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
}

.btn-outline:hover {
    background: rgba(233, 69, 96, 0.08);
}

.btn {
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    font-family: inherit;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover, .btn-primary:active {
    background: var(--accent-hover);
    transform: scale(1.02);
}

.btn-secondary {
    background: #fff;
    color: var(--accent);
    border: 2px solid var(--accent);
}

.btn-secondary:hover, .btn-secondary:active {
    background: rgba(233, 69, 96, 0.08);
}

.btn-danger {
    background: #dc3545;
    color: white;
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-end {
    background: #6c757d;
    color: #fff;
    margin-top: 0.5rem;
}

.btn-end:hover {
    background: #5a6268;
}

.btn-leave {
    margin-top: 1rem;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid #e5e5ea;
}

.btn-leave:hover {
    background: #f5f5f7;
    color: var(--text);
}

.btn-warning {
    background: #fd7e14;
    color: #fff;
}

.btn-warning:hover {
    background: #e96b00;
}

form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

input[type="text"] {
    padding: 1rem 1.25rem;
    font-size: 1.1rem;
    font-family: inherit;
    border: 2px solid #e5e5ea;
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    transition: border-color 0.2s;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

input::placeholder {
    color: var(--text-muted);
}

h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    margin-bottom: 1.5rem;
    padding: 0.75rem 1rem;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.room-header-info {
    flex: 1;
}

.btn-scores {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
}

.btn-scores:hover {
    background: rgba(233, 69, 96, 0.08);
}

.scores-popup {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1100;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.scores-popup.show {
    display: flex;
}

.scores-popup-content {
    background: #fff;
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    max-width: 320px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.scores-popup-content h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.scores-popup-list {
    text-align: left;
    margin-bottom: 1rem;
    max-height: 240px;
    overflow-y: auto;
}

.scores-popup-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    background: #f5f5f7;
    border-radius: 8px;
    margin-bottom: 0.4rem;
}

.scores-popup-item .score-name {
    font-weight: 600;
}

.scores-popup-item .score-value {
    color: var(--accent);
    font-weight: 700;
}

.room-code {
    font-size: 1.1rem;
}

.room-code strong {
    color: var(--accent);
    font-size: 1.3rem;
    letter-spacing: 0.2em;
}

.player-count {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.players-list {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.player-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: #fff;
    border-radius: 12px;
    border: 2px solid transparent;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    transition: all 0.2s;
}

.player-card.is-me {
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.08);
}

.player-card.is-out {
    opacity: 0.6;
    background: #f2f2f7;
}

.player-card .word {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
}

.player-card .word.hidden {
    font-size: 1.5rem;
    letter-spacing: 0.3em;
    color: var(--text-muted);
}

.player-card .name {
    font-weight: 600;
    margin-right: 0.8rem;
}

.player-card .player-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    margin-right: 1rem;
}

.player-card .badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    background: var(--accent);
    border-radius: 6px;
    margin-left: 0.5rem;
}

.room-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.game-over {
    text-align: center;
    padding: 2rem;
}

.game-over h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.game-over p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.game-over-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 1rem 1.5rem;
    background: #fff;
    border: 1px solid var(--accent);
    border-radius: 12px;
    color: var(--text);
    font-size: 0.95rem;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    max-width: 90%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error {
    border-color: #dc3545;
}
