@font-face {
    font-family: 'custom';
    src: url('fonts/custom.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

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

:root {
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
    overscroll-behavior-y: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    /* Safari-safe background with fallback */
    background-color: #000000;
    background-image: 
        linear-gradient(135deg, #0a0a0a 0%, #000000 50%, #0a0a0a 100%);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    color: #e0ffe0;
    overflow-x: hidden;
    /* iOS-specific optimizations */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    /* Neon glow effects */
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
    position: relative;
}

/* Safari-compatible grid overlay - simplified */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Safari-safe gradient */
    background: 
        linear-gradient(rgba(0, 255, 136, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 136, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: -1;
    pointer-events: none;
}

/* Safari-compatible neon particles - simplified */
body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Safari-safe radial gradients */
    background: 
        radial-gradient(circle at 20% 30%, rgba(0, 255, 136, 0.3), transparent),
        radial-gradient(circle at 80% 70%, rgba(0, 255, 136, 0.2), transparent);
    z-index: -1;
    pointer-events: none;
    opacity: 0.6;
}

/* Safari fallback for complex animations */
@supports not (animation: gridMove) {
    body::before {
        animation: none;
    }
}

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

/* Rest of your styles remain exactly the same */
h2 {
    text-align: center;
    color: #00ff88;
    margin: 15px 0;
    font-weight: 200;
    font-size: 3rem;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.7);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    max-width: 90%;
  font-family: 'custom';
}

h3 {
    color: #00ff88;
    margin: 20px 0 10px 0;
    font-weight: 600;
    font-size: 1.3rem;
    font-family: monospace;
}

p {
    margin-bottom: 15px;
    font-size: 1rem;
    color: #cccccc;
    line-height: 1.6;
    text-align: left;
    font-family: monospace;
}

#user-info, #chat-container {
    width: 100%;
    background: transparent;
    padding: 16px;
    margin: 0;
    box-shadow: none;
    border-radius: 0;
    text-align: center;
}

#user-info {
    display: block;
}

#chat-container {
    display: none;
    flex-direction: column;
    height: 100vh;
    position: relative;
    top: 0;
    left: 0;
    width: 100%;
    background: #000000;
    z-index: 1000;
    padding: 0;
}

#messages {
    list-style: none;
    padding: 16px;
    margin: 0;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    padding-bottom: 120px;
    max-height: calc(100vh - 80px);
}

#messages li {
    padding: 12px 16px;
    border-radius: 20px;
    margin-bottom: 12px;
    max-width: fit-content;
    word-break: break-word;
    font-size: 1.1rem;
    color: #ffffff;
    line-height: 1.4;
    animation: fadeIn 0.3s ease;
}

#messages li.user {
    background: linear-gradient(135deg, #00ff88 0%, #00cc6a 100%);
    color: #000000;
    align-self: flex-end;
    margin-left: auto;
    text-align: right;
}

#messages li.partner {
    background: #2a2a2a;
    color: #ffffff;
    align-self: flex-start;
    margin-right: auto;
    text-align: left;
    border: 1px solid #333333;
}

#messages li.bold {
    font-weight: 600;
    background: transparent;
    color: #00ff88;
    text-align: center;
    margin: 8px auto;
    max-width: 100%;
    font-size: 0.9rem;
    border: solid 1px #00ff88;
}

#messages li.match-notice {
    background: linear-gradient(90deg, #43a047 0%, #66bb6a 100%);
    color: #fff;
    font-weight: bold;
    text-align: center;
    font-size: 1.1rem;
    border-radius: 12px;
    padding: 12px;
    max-width: 95%;
    margin: 10px auto;
}

#input-bar {
    position: fixed;
    bottom: var(--safe-area-inset-bottom);
    left: 0;
    width: 100%;
    padding: 16px;
    background: #000000;
    box-shadow: 0 -2px 20px rgba(0,0,0,0.8);
    z-index: 1001;
    border-top: 1px solid #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

#input-container {
    position: relative;
    flex: 1;
}

input, select {
    padding: 16px;
    border: none;
    border-radius: 12px;
    margin-bottom: 16px;
    width: 100%;
    font-size: 1.1rem;
    background: #1a1a1a;
    color: #ffffff;
    transition: all 0.2s ease;
    -webkit-appearance: none;
}

input:focus, select:focus {
    outline: none;
    background: #222222;
    box-shadow: 0 0 0 2px #00ff88;
}

label {
    font-size: 1rem;
    color: #aaaaaa;
    margin-bottom: 10px;
    display: block;
    font-weight: 500;
}

#join {
    padding: 6px;
    border: none;
    background: #00ff88;
    color: #000000;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s ease;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    -webkit-appearance: none;
}
#random {
    color: darkorange;
    font-variant: small-caps;
    font-weight: 600;
    font-size: 20px;
}

    #leave {
        min-width: 60px;
       letter-spacing: 1px;;
        font-size: 1rem;
        border-radius: 40px;
    }

#join:active, #leave:active {
    transform: scale(0.98);
}

#input {
    width: 100%;
    font-size: 1.1rem;
    padding: 16px;
    border-radius: 12px;
    background: #1a1a1a;
    color: #ffffff;
    border: none;
    margin-bottom: 0;
    -webkit-appearance: none;
}

#input:focus {
    outline: none;
    background: #222222;
    box-shadow: 0 0 0 2px #00ff88;
}

.gender-checkbox-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 15px 0 20px 0;
}

.gender-checkbox {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.gender-checkbox input[type="checkbox"] {
    display: none;
}

.gender-checkbox label {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    background: #1a1a1a;
    width: 60px;
    height: 60px;
    justify-content: center;
    font-size: 2rem;
    transition: all 0.2s ease;
    border: 2px solid #333;
    -webkit-tap-highlight-color: transparent;
    margin-bottom: 0;
}

.gender-checkbox input[type="checkbox"]:checked + label {
    background: #00ff88;
    color: #000;
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.4);
    border-color: #00cc6a;
}

.gender-checkbox .checkbox-text {
    margin-top: 8px;
    font-size: 0.9rem;
    color: #aaa;
    text-align: center;
}

.gender-checkbox input[type="checkbox"]:checked + label + .checkbox-text {
    color: #00ff88;
    font-weight: 600;
}

select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300ff88' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 18px;
}

/* Image button styles */
#sendImage {
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #00ff88 0%, #00cc6a 100%);
    color: #000;
    font-size: 1.4rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    -webkit-appearance: none;
}

#sendImage:hover {
    background: linear-gradient(135deg, #00cc6a 0%, #00aa55 100%);
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.4);
}

#sendImage:active {
    transform: scale(0.95);
}

#leave {
    padding: 14px 16px;
    border: none;
    border-radius: 12px;
    background: #ff3b30;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
    flex-shrink: 0;
    font-weight: 600;
    -webkit-appearance: none;
}

#leave:hover {
    background: #e0352b;
    transform: scale(1.05);
}

#leave:active {
    transform: scale(0.95);
}

/* Image styles in messages */
#messages li img {
    max-width: 70%;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: block;
}

#messages li.user img {
    margin-left: auto;
    margin-right: 0;
}

#messages li.partner img {
    margin-right: auto;
    margin-left: 0;
}

@media (max-width: 768px) {
    body {
        position: relative;
        overflow-x: hidden;
        padding: 15px;
    }
    
    #chat-container {
        position: fixed;
        height: 100%;
    }
    
    #messages {
        padding-bottom: 130px;
    }
    
    #input-bar {
        padding: 12px;
        gap: 8px;
    }
    
    #sendImage {
        padding: 12px;
        min-width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
    
    #leave {
        padding: 12px 14px;
        font-size: 0.9rem;
        min-width: 70px;
    }
    
    input, select, textarea {
        font-size: 16px !important;
    }
}

@media (max-width: 480px) {
    #input-bar {
        flex-wrap: nowrap;
    }
    
    #input {
        padding: 14px;
    }
    
    #sendImage {
        min-width: 40px;
        height: 40px;
        font-size: 1.2rem;
        padding: 10px;
    }
    
    #leave {
        min-width: 60px;
        font-size: 0.85rem;
        height: 40px;
    }
}

@media (max-width: 350px) {
    .gender-checkbox-container {
        gap: 15px;
    }
    
    .gender-checkbox label {
        width: 50px;
        height: 50px;
        font-size: 1.6rem;
    }
    
    #messages li {
        font-size: 1rem;
        padding: 10px 14px;
    }
    
    h2 {
        font-size: 1.5rem;
        padding: 10px;
    }
    
    #input-bar {
        padding: 10px;
        gap: 6px;
    }
}

#messages::-webkit-scrollbar {
    width: 4px;
}

#messages::-webkit-scrollbar-track {
    background: transparent;
}

#messages::-webkit-scrollbar-thumb {
    background: #00ff88;
    border-radius: 2px;
}

#messages {
    scroll-behavior: smooth;
}

h3, p {
    text-align: center;
}

#typing-indicator {
  position: absolute;
  bottom: 90px; 
  left: 10px;
  font-size: 1rem;
  font-style: italic;
  color: gray;
  display: none;
  padding: 2px 6px;
  border-radius: 6px;
}

#user-counter {
    margin-top: 10px;
    font-size: 1rem;
    color: #00ff88;
    font-weight: 600;
    font-family: monospace;
}

@media (min-width: 700px) {
  li.bold {
    max-width: 50% !important;
    margin: 10px auto !important;
  }
  li.match-notice {
    max-width: fit-content !important;
    margin: 0 auto !important;
  }
}

 #messages li.match-notice {
        background: linear-gradient(90deg, #43a047 0%, #66bb6a 100%);
        color: #fff;
        font-weight: bold;
        text-align: center;
        font-size: 1.1rem;
        border-radius: 12px;
        padding: 12px;
      }
      /* Initial visibility fix */
      #chat-container {
        display: none;
      }
      #user-info {
        display: block;
      }
      #input-container {
        position: relative;
        flex: 1;
      }
      #input {
        width: 100%;
        padding-right: 50px;
        box-sizing: border-box;
      }
