/* SVG Icon Helpers */
.icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: middle;
}

.icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #7e22ce 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.top-nav {
    width: 100%;
    max-width: 800px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 12px 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    display: flex;
    gap: 15px;
    justify-content: center;
}

.nav-item {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
    padding: 8px 20px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.nav-item:hover {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.1);
}

.nav-item.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.content-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    width: 100%;
}

.phone-container {
    max-width: 400px;
    width: 100%;
    height: 800px;
    background: #000;
    border-radius: 40px;
    box-shadow: 0 0 0 12px #1c1c1e, 0 20px 60px rgba(0,0,0,0.8);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.status-bar {
    background: #1c1c1e;
    color: #fff;
    padding: 8px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.time {
    font-weight: 600;
}

.signal-icons {
    display: flex;
    gap: 5px;
    align-items: center;
}

.header-bar {
    background: #1c1c1e;
    color: #fff;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #2c2c2e;
}

.back-btn {
    color: #0a84ff;
    font-size: 17px;
    cursor: pointer;
}

.contact-info {
    flex: 1;
    text-align: center;
}

.contact-name {
    font-weight: 600;
    font-size: 17px;
}

.contact-status {
    font-size: 12px;
    color: #98989d;
}

.phone-screen {
    flex: 1;
    background: #000;
    overflow-y: auto;
    position: relative;
}

.intro-screen, .chat-screen, .observer-screen, .complete-screen {
    display: none;
    height: 100%;
}

.intro-screen.active, .chat-screen.active, .observer-screen.active, .complete-screen.active {
    display: flex;
    flex-direction: column;
}

.intro-content {
    flex: 1;
    padding: 30px 20px;
    color: #fff;
    overflow-y: auto;
}

.intro-content h1 {
    font-size: 28px;
    margin-bottom: 15px;
    text-align: center;
}

.intro-content p {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 15px;
    color: #e5e5e7;
}

.intro-content strong {
    color: #0a84ff;
}

.start-btn {
    background: #0a84ff;
    color: white;
    border: none;
    padding: 16px;
    font-size: 17px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    margin: 20px;
}

.start-btn:active {
    opacity: 0.7;
}

.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 17px;
    line-height: 1.4;
    position: relative;
    animation: slideIn 0.3s ease-out;
}

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

.message.received {
    background: #2c2c2e;
    color: #fff;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.sent {
    background: #0a84ff;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.system {
    background: #3a3a3c;
    color: #98989d;
    align-self: center;
    max-width: 90%;
    text-align: center;
    font-size: 14px;
    border-radius: 12px;
}

.read-receipt {
    font-size: 11px;
    color: #98989d;
    margin-top: 3px;
    margin-right: 5px;
    text-align: right;
    align-self: flex-end;
}

.read-receipt i {
    margin-right: 3px;
}

.symbols {
    font-size: 28px;
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
}

.symbols .icon {
    font-size: 28px;
    width: 28px;
    height: 28px;
}

.pattern-drawer {
    background: #1c1c1e;
    border-top: 1px solid #2c2c2e;
    padding: 12px;
    height: 180px;
    overflow-y: auto;
}

.pattern-header {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #98989d;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pattern-header i {
    font-size: 16px;
}

.pattern-rule {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    margin-bottom: 6px;
    background: #2c2c2e;
    border-radius: 8px;
    gap: 10px;
}

.pattern-rule .input-symbol {
    font-size: 24px;
    color: #ff9f0a;
    flex: 1;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pattern-rule .input-symbol .icon {
    width: 24px;
    height: 24px;
}

.pattern-rule .arrow {
    color: #98989d;
    font-size: 18px;
}

.pattern-rule .output-symbol {
    font-size: 24px;
    color: #0a84ff;
    flex: 1;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pattern-rule .output-symbol .icon {
    width: 24px;
    height: 24px;
}

.input-area {
    background: #1c1c1e;
    border-top: 1px solid #2c2c2e;
    padding: 10px;
}

.input-prompt {
    color: #98989d;
    font-size: 13px;
    text-align: center;
    padding: 6px;
    margin-bottom: 8px;
}

.symbol-keyboard {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.symbol-key {
    background: #2c2c2e;
    color: #fff;
    border: 2px solid #2c2c2e;
    padding: 16px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    user-select: none;
}

.symbol-key .icon {
    width: 24px;
    height: 24px;
}

.symbol-key:active {
    transform: scale(0.95);
    opacity: 0.7;
}

.symbol-key.selected {
    border-color: #0a84ff;
    background: rgba(10, 132, 255, 0.2);
}

.backspace-key {
    background: #3a3a3c;
    color: #ff453a;
    border: 2px solid #3a3a3c;
    padding: 16px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    user-select: none;
}

.backspace-key:active {
    transform: scale(0.95);
    opacity: 0.7;
}

.response-display {
    background: #2c2c2e;
    border: 2px solid #3a3a3c;
    border-radius: 10px;
    padding: 12px;
    min-height: 50px;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    font-size: 26px;
    color: #fff;
}

.response-display .icon {
    width: 26px;
    height: 26px;
}

.response-display.empty {
    color: #5a5a5c;
    font-size: 15px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
}

.keyboard-actions {
    display: flex;
    gap: 8px;
}

.clear-btn {
    background: #3a3a3c;
    color: #ff453a;
    border: none;
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    flex: 1;
}

.clear-btn:active {
    opacity: 0.7;
}

.send-btn {
    background: #0a84ff;
    color: white;
    border: none;
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    flex: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.send-btn:not(:disabled):active {
    opacity: 0.7;
}

.complete-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.complete-header {
    color: #fff;
    text-align: center;
    margin-bottom: 20px;
}

.complete-header h2 {
    font-size: 24px;
    margin-bottom: 10px;
}

.complete-header p {
    color: #98989d;
    font-size: 15px;
    line-height: 1.5;
}

.perspective-section {
    margin-bottom: 30px;
}

.perspective-label {
    text-align: center;
    margin-bottom: 15px;
    padding: 15px;
    background: rgba(10, 132, 255, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(10, 132, 255, 0.3);
}

.perspective-label h3 {
    color: #0a84ff;
    font-size: 20px;
    margin-bottom: 5px;
}

.perspective-label p {
    color: #98989d;
    font-size: 14px;
}

.phase-continue {
    text-align: center;
    margin: 30px 0;
}

.conversation-reveal {
    background: #1c1c1e;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
}

.reveal-exchange {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #2c2c2e;
    display: flex;
    flex-direction: column;
}

.reveal-exchange:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.reveal-message {
    padding: 10px 12px;
    border-radius: 14px;
    margin-bottom: 8px;
}

.reveal-message.them {
    background: #2c2c2e;
    display: none;
}

.reveal-message.you {
    background: #0a84ff;
    margin-left: auto;
    max-width: 85%;
    display: none;
}

.reveal-message.you .reveal-translation {
    color: #fff;
}

.reveal-symbols {
    font-size: 18px;
    display: none;
    gap: 8px;
    color: #fff;
    margin-bottom: 5px;
    justify-content: center;
    opacity: 0;
}

.reveal-symbols.show {
    display: flex;
}

.reveal-symbols .icon {
    width: 18px;
    height: 18px;
}

.reveal-translation {
    font-size: 15px;
    color: #98989d;
    font-style: italic;
    display: none;
    opacity: 0;
}

.reveal-translation.show {
    display: block;
}

/* English reveal styles (Phase 2) */
.english-reveal {
    display: block !important;
    opacity: 0;
}

.english-reveal .english-text {
    display: block !important;
    opacity: 0;
}

.english-reveal.show .english-text {
    opacity: 1;
    animation: fadeIn 0.5s ease-out forwards;
}

/* Animation styles for conversation reveal */
.reveal-exchange {
    opacity: 0;
}

.reveal-exchange.animate {
    animation: fadeIn 0.3s ease-out forwards;
}

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

.reveal-symbols.show {
    opacity: 1;
}

.reveal-translation.show {
    opacity: 1;
}

/* Pixelate crossfade effect */
.pixelate-out {
    animation: pixelateOut 0.3s ease-out forwards;
}

.pixelate-in {
    animation: pixelateIn 0.3s ease-out forwards;
}

@keyframes pixelateOut {
    0% {
        opacity: 1;
        filter: blur(0px);
    }
    50% {
        filter: blur(3px);
    }
    100% {
        opacity: 0;
        filter: blur(5px);
    }
}

@keyframes pixelateIn {
    0% {
        opacity: 0;
        filter: blur(5px);
    }
    50% {
        filter: blur(3px);
    }
    100% {
        opacity: 1;
        filter: blur(0px);
    }
}

/* Slide out left animation */
.slide-out-left {
    animation: slideOutLeft 0.5s ease-in forwards;
}

@keyframes slideOutLeft {
    0% {
        opacity: 1;
        transform: translateX(0);
    }
    100% {
        opacity: 0;
        transform: translateX(-100px);
    }
}

/* Fade in final animation */
.fade-in-final {
    animation: fadeInFinal 0.5s ease-out forwards;
}

@keyframes fadeInFinal {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

.typing-indicator {
    display: none;
    gap: 4px;
    padding: 12px 16px;
    opacity: 0;
}

.typing-indicator.show {
    display: flex;
    animation: fadeIn 0.3s ease-out forwards;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-6px);
    }
}

.reveal-message.you .reveal-translation {
    text-align: left;
}

.read-receipt-reveal {
    font-size: 11px;
    color: #98989d;
    margin-top: 3px;
    margin-right: 5px;
    text-align: right;
    opacity: 0;
}

.read-receipt-reveal.show {
    animation: fadeIn 0.3s ease-out forwards;
}

.reflection-box {
    background: #3a3a3c;
    border-radius: 12px;
    padding: 20px;
    border-left: 4px solid #ff9f0a;
    display: none;
}

.complete-screen.active .reflection-box {
    animation: fadeIn 0.5s ease-out forwards;
}

.reflection-box h3 {
    color: #ff9f0a;
    font-size: 18px;
    margin-bottom: 12px;
}

.reflection-box p {
    color: #e5e5e7;
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 10px;
}

.reflection-box strong {
    color: #fff;
}

.restart-btn {
    background: #2c2c2e;
    color: #0a84ff;
    border: none;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    margin-top: 15px;
    width: 100%;
    display: none;
}

.complete-screen.active .restart-btn {
    animation: fadeIn 0.5s ease-out forwards;
}

/* Observer screen (Part B) styles */
.observer-screen {
    display: none;
    flex-direction: column;
    height: 100%;
}

.observer-screen.active {
    display: flex;
}

.observer-messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.observer-message {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 16px;
    line-height: 1.4;
    animation: slideIn 0.3s ease-out;
}

.observer-message.them {
    background: #2c2c2e;
    color: #fff;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.observer-message.you {
    background: #0a84ff;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.observer-input-area {
    padding: 20px;
    background: #1c1c1e;
    border-top: 1px solid #2c2c2e;
}

.observer-prompt {
    color: #98989d;
    font-size: 14px;
    margin-bottom: 12px;
    text-align: center;
}

.choice-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.choice-btn {
    background: #2c2c2e;
    color: #fff;
    border: 2px solid #3a3a3c;
    padding: 14px 20px;
    font-size: 16px;
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.choice-btn:hover {
    background: #3a3a3c;
    border-color: #0a84ff;
}

.choice-btn:active {
    opacity: 0.7;
}

.choice-btn.selected {
    background: #0a84ff;
    border-color: #0a84ff;
}

/* Transition screen styles */
.transition-screen, .transition-screen-b-to-a {
    display: none;
    flex-direction: column;
    height: 100%;
    justify-content: center;
    align-items: center;
    padding: 40px;
    text-align: center;
}

.transition-screen.active, .transition-screen-b-to-a.active {
    display: flex;
}

.transition-content {
    color: #fff;
}

.transition-content h2 {
    font-size: 28px;
    margin-bottom: 20px;
}

.transition-content p {
    font-size: 18px;
    line-height: 1.6;
    color: #e5e5e7;
    margin-bottom: 30px;
}

.continue-btn {
    background: #0a84ff;
    color: white;
    border: none;
    padding: 16px 40px;
    font-size: 17px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
}

.continue-btn:active {
    opacity: 0.7;
}

/* Silver phone variant */
.phone-container.silver {
    box-shadow: 0 0 0 12px #c0c0c0, 0 20px 60px rgba(0,0,0,0.8);
}

.restart-btn:active {
    opacity: 0.7;
}

@media (max-width: 400px) {
    .phone-container {
        border-radius: 0;
        max-width: 100%;
        height: 100vh;
        box-shadow: none;
    }
}
