/* Meter Position Styles */
#meterPosition {
    width: 10px;
    height: 100%;
    background-color: #4CAF50;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 0.25rem;
    transition: left 0.3s ease;
}

/* Scale Step Styles */
.scale-step {
    width: 2px;
    height: 100%;
    background-color: #999;
    position: relative;
}

.scale-step:first-child,
.scale-step:last-child {
    width: 0px;
}

/* Scrollbar Hide Utility */
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

#usedWords {
    position: relative;
    min-height: 200px;
    height: auto;
    width: 100%;
    padding: 20px;
    margin-bottom: 40px;
    overflow: visible;
}

#usedWords .word-item {
    position: absolute;
}

.word-item {
    position: absolute;
    padding: 0.75rem 1.25rem;
    border-radius: 1.25rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
    transform-origin: center;
    z-index: 1;
    white-space: nowrap;
}

.word-item.latest {
    z-index: 2;
    animation: pulse 1.5s ease-in-out;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

.word-item.player {
    background-color: var(--player-color);
    color: var(--player-text-color);
}

.word-item.ai {
    background-color: var(--ai-color);
    color: var(--ai-text-color);
}

.word-item.opponent {
    background-color: var(--ai-color);
    color: var(--ai-text-color);
}

.word-item.player:hover {
    background-color: #bbdefb;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.word-item.ai:hover {
    background-color: #ffcdd2;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.word-item.opponent:hover {
    background-color: #ffcdd2;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.word-item.player.latest {
    background-color: #1565c0;
    color: white;
    border: 2px solid #0d47a1;
    box-shadow: 0 4px 8px rgba(21, 101, 192, 0.3);
    animation: pulse 2s infinite;
    z-index: 5;
}

.word-item.ai.latest {
    background-color: #c62828;
    color: white;
    border: 2px solid #b71c1c;
    box-shadow: 0 4px 8px rgba(198, 40, 40, 0.3);
    animation: pulse 2s infinite;
    z-index: 5;
}

.word-item.opponent.latest {
    background-color: #c62828;
    color: white;
    border: 2px solid #b71c1c;
    box-shadow: 0 4px 8px rgba(198, 40, 40, 0.3);
    animation: pulse 2s infinite;
    z-index: 5;
}

/* Word size variations based on recency */
.word-item.size-large {
    font-size: 1.25rem;
}

.word-item.size-medium {
    font-size: 1rem;
}

.word-item.size-small {
    font-size: 0.85rem;
}

/* Relatedness badge for word cloud */
.relatedness-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #4b5563;
    color: white;
    border-radius: 9999px;
    font-size: 0.65rem;
    padding: 2px 5px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.word-item:hover .relatedness-badge {
    opacity: 1;
}

/* Knot animation keyframes */
@keyframes wiggle-left {

    0%,
    100% {
        transform: rotate(-3deg);
    }

    50% {
        transform: rotate(3deg);
    }
}

@keyframes wiggle-right {

    0%,
    100% {
        transform: rotate(3deg);
    }

    50% {
        transform: rotate(-3deg);
    }
}

/* Add styles for the knot based on advantage */
.rope-knot.player-advantage {
    filter: drop-shadow(0 0 5px rgba(59, 130, 246, 0.5));
}

.rope-knot.ai-advantage {
    filter: drop-shadow(0 0 5px rgba(239, 68, 68, 0.5));
}

/* Rope and Knot Styles */
#ropeContainer {
    overflow: visible;
}

.rope-texture {
    height: 100%;
    width: 100%;
    background-image: repeating-linear-gradient(90deg,
            rgba(120, 53, 15, 0.6) 0px,
            rgba(120, 53, 15, 0.6) 3px,
            rgba(180, 83, 9, 0.6) 3px,
            rgba(180, 83, 9, 0.6) 6px);
}

.scale-marker {
    width: 2px;
    height: 16px;
    background-color: rgba(0, 0, 0, 0.2);
    position: relative;
    border-radius: 1px;
}

.scale-marker:first-child,
.scale-marker:last-child {
    height: 20px;
    width: 3px;
    background-color: rgba(0, 0, 0, 0.4);
}

.rope-knot {
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
    transition: transform 0.2s ease;
}

.rope-knot:hover {
    transform: scale(1.1);
}
/* Popup Styles */
.popup-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 50;
    align-items: center;
    justify-content: center;
}

.popup-overlay:not(.hidden) {
    display: flex;
}

.popup-content {
    background-color: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    position: relative;
    width: 100%;
    max-width: 32rem;
    margin: 1rem;
    max-height: 80vh;
    overflow-y: auto;
}

.close-button {
    position: absolute;
    top: 0.5rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    transition: color 0.2s;
}

.close-button:hover {
    color: #000;
}
.popup-overlay.hidden {
    display: none;
}

.popup-content {
    max-width: 90%;
    margin: 20px;
}

.close-button {
    cursor: pointer;
    z-index: 1;
}

.close-button:hover {
    opacity: 0.8;
}

/* Update the meterPosition styles */
#meterPosition {
    width: auto;
    height: auto;
    background-color: transparent;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    transition: left 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Word bubbles animation */
@keyframes pop-in {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    70% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.word-item {
    animation: pop-in 0.3s forwards;
}

/* Improve the word items */
.word-item {
    position: absolute;
    padding: 0.75rem 1.25rem;
    border-radius: 1.25rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
    transform-origin: center;
    z-index: 1;
}

.word-item.player {
    background-color: #e3f2fd;
    color: #1565c0;
    border: 1px solid #90caf9;
}

.word-item.player:hover {
    background-color: #bbdefb;
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.word-item.ai {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

.word-item.ai:hover {
    background-color: #ffcdd2;
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.word-item.player.latest {
    background-color: #1565c0;
    color: white;
    border: 2px solid #0d47a1;
    box-shadow: 0 4px 10px rgba(21, 101, 192, 0.4);
    animation: pulse 2s infinite;
}

.word-item.ai.latest {
    background-color: #c62828;
    color: white;
    border: 2px solid #b71c1c;
    box-shadow: 0 4px 10px rgba(198, 40, 40, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    }

    50% {
        box-shadow: 0 8px 15px rgba(0, 0, 0, 0.6);
    }

    100% {
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    }
}

/* Improve the input and buttons */
#wordInput {
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

#wordInput:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

button {
    position: relative;
    overflow: hidden;
}

button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%, -50%);
    transform-origin: 50% 50%;
}

button:focus:not(:active)::after {
    animation: ripple 0.6s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }

    100% {
        transform: scale(20, 20);
        opacity: 0;
    }
}

/* Add a round counter display */
.round-counter {
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #f9fafb;
    padding: 8px 0;
    text-align: center;
    font-weight: bold;
    border-bottom: 1px solid #e5e7eb;
    z-index: 10;
    margin-bottom: 10px;
}

/* Add a round separator */
.round-separator {
    width: 100%;
    text-align: center;
    margin: 8px 0;
    font-size: 0.85rem;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
}

.round-separator::before,
.round-separator::after {
    content: "";
    flex: 1;
    border-bottom: 1px dashed #d1d5db;
    margin: 0 10px;
}

/* Word history section title */
.word-history-title {
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 1rem;
    color: #374151;
}

/* Word pair container */
.word-pair {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
    width: 100%;
}

/* Relatedness explanation section */
#relatednessExplanation {
    transition: all 0.3s ease;
    overflow: hidden;
}

#relatednessExplanation.hidden {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
    opacity: 0;
}

#playerWordDisplay, #aiWordDisplay {
    font-size: 1.25rem;
    margin: 0.5rem 0;
}

#playerRelatednessScore, #aiRelatednessScore {
    font-size: 1.25rem;
    margin: 0.5rem 0;
}

/* Mobile Responsiveness Improvements */
@media (max-width: 640px) {
    #usedWords {
        min-height: 250px;
    }
    
    .word-item {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .word-item.latest {
        font-size: 1rem;
    }
    
    /* Increase touch target size */
    .close-button {
        font-size: 2rem;
        padding: 0.5rem;
    }
    
    /* Improve popup on mobile */
    .popup-content {
        padding: 1rem;
        width: 95%;
        max-height: 85vh;
    }
}

/* Improve word cloud visibility */
.word-item {
    position: absolute;
    padding: 0.75rem 1.25rem;
    border-radius: 1.25rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
    transform-origin: center;
    z-index: 1;
    white-space: nowrap;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Improve touch feedback */
.word-item:active {
    transform: scale(0.95);
    transition: transform 0.1s;
}

/* Improve input field for mobile */
#wordInput {
    font-size: 16px; /* Prevents iOS zoom on focus */
    -webkit-appearance: none;
    appearance: none;
}

/* Improve buttons for touch */
button {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px; /* Minimum touch target size */
}

/* Improve the relatedness comparison for mobile */
#relatednessComparison {
    transition: all 0.3s ease;
}

#relatednessComparison > div {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
}

#relatednessComparison > div > div {
    flex: 1;
    min-width: 140px;
    max-width: 100%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

#relatednessComparison > div > div:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#playerWordDisplay, #aiWordDisplay {
    font-size: 1.25rem;
    margin: 0.25rem 0;
    word-break: break-word;
    hyphens: auto;
}

#playerRelatednessScore, #aiRelatednessScore {
    font-size: 1.25rem;
    margin: 0.25rem 0;
}

@media (max-width: 400px) {
    #relatednessComparison > div > div {
        padding: 0.5rem;
    }
    
    #playerWordDisplay, #aiWordDisplay,
    #playerRelatednessScore, #aiRelatednessScore {
        font-size: 1.1rem;
    }
}

/* Improve word cloud container for mobile */
@media (max-width: 640px) {
    #usedWords {
        min-height: 300px;
    }
}
/* Name gate */
.gate-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 800px at 50% 40%, rgba(59,130,246,.25), rgba(99,102,241,.25), rgba(0,0,0,.6));
  backdrop-filter: blur(4px);
  z-index: 50;
}
.gate-card {
  width: 90%;
  max-width: 540px;
  border-radius: 20px;
  background: white;
  box-shadow: 0 20px 40px rgba(0,0,0,.25);
  overflow: hidden;
  animation: gate-in .25s ease-out;
}
.gate-hero {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: white;
  padding: 24px;
  text-align: center;
}
.gate-avatar {
  width: 72px;
  height: 72px;
  border-radius: 9999px;
  margin: 0 auto 10px;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
}
.gate-title { font-size: 20px; font-weight: 700; }
.gate-subtitle { font-size: 13px; opacity: .9; }
.gate-body { padding: 20px; }
.gate-input {
  width: 100%;
  border: 2px solid #c7d2fe;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
}
.gate-input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.2); }
.gate-error { margin-top: 8px; font-size: 12px; color: #ef4444; }
.gate-actions { display: flex; gap: 8px; margin-top: 14px; }
.gate-primary { flex: 1; background: #2563eb; color: white; border: 0; padding: 10px 14px; border-radius: 12px; }
.gate-secondary { background: #111827; color: white; border: 0; padding: 10px 14px; border-radius: 12px; }
.gate-tertiary { background: #e5e7eb; color: #111827; border: 0; padding: 10px 14px; border-radius: 12px; }
@keyframes gate-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes gate-shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-3px); } 40% { transform: translateX(3px); } 60% { transform: translateX(-2px); } 80% { transform: translateX(2px); } }

/* Inline name alert in Room Controls */
.name-alert {
  border-color: #ef4444 !important;
  background-color: #fee2e2 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
  animation: gate-shake .25s;
}
.avatar-alert {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.35);
}