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

body, html {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #000;
  color: #fff;
  position: fixed;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

.flex {
  display: flex;
}

/* Join Screen */
#joinscreen {
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#joinform {
  width: 90%;
  max-width: 400px;
  background: #000;
  color: #fff;
  padding: 40px;
  border-radius: 8px;
  border: 2px solid #fff;
  transition: all 0.3s ease;
}

#joinform:hover {
  border-color: #ccc;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255, 255, 255, 0.1);
}

#joinform legend {
  font-size: 2.5rem;
  font-weight: 300;
  margin-bottom: 30px;
  text-align: center;
  color: #fff;
  letter-spacing: 2px;
  text-transform: lowercase;
}

#joinform .form-group {
  margin-bottom: 20px;
}

#joinform label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #fff;
}

#joinform input {
  width: 100%;
  padding: 15px;
  border: 2px solid #fff;
  background: #000;
  color: #fff;
  font-size: 16px;
  border-radius: 4px;
  outline: none;
  transition: all 0.3s ease;
}

#joinform input:focus {
  border-color: #ccc;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
  transform: scale(1.02);
}

#joinform input:hover {
  border-color: #ccc;
}

#joinform input::placeholder {
  color: #666;
}

#joinform button {
  width: 100%;
  padding: 15px;
  background: #fff;
  color: #000;
  border: 2px solid #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#joinform button:hover {
  background: #000;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.2);
}

/* Waiting Screen */
#waitingscreen {
  display: none;
  width: 100%;
  height: 100%;
  background: #000;
  justify-content: center;
  align-items: center;
}

.waiting-content {
  text-align: center;
  color: #fff;
}

.waiting-content h2 {
  font-size: 2.5rem;
  margin-bottom: 30px;
  font-weight: 300;
  letter-spacing: 1px;
}

.waiting-content p {
  font-size: 1.2rem;
  margin-top: 20px;
  opacity: 0.8;
}

.spinner {
  border: 2px solid #333;
  border-top: 2px solid #fff;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Chat Room */
#chatroom {
  display: none;
  width: 100%;
  height: 100%;
  background: #000;
  flex-direction: column;
}

#auth-section {
  text-align: center;
  padding: 40px;
  background: #000;
  border-radius: 8px;
  border: 2px solid #fff;
  margin: 20px;
  max-width: 400px;
  transition: all 0.3s ease;
}

#auth-section:hover {
  border-color: #ccc;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255, 255, 255, 0.1);
}

.auth-content h2 {
  color: #fff;
  margin-bottom: 30px;
  font-size: 2.5rem;
  font-weight: 300;
  letter-spacing: 2px;
  text-transform: lowercase;
}

.auth-content p {
  color: #fff;
  margin-bottom: 30px;
  font-size: 1.2rem;
  opacity: 0.8;
  font-weight: 300;
}

.floating-attribution {
  position: fixed;
  bottom: 20px;
  right: 20px;
  font-size: 1.1rem;
  color: #888;
  font-style: italic;
  opacity: 0.9;
  z-index: 1000;
  pointer-events: none;
  font-weight: 500;
}

#login-btn {
  width: 100%;
  padding: 15px 30px;
  background: #fff;
  color: #000;
  border: 2px solid #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#login-btn:hover {
  background: #000;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.2);
}

#skip-btn {
  width: 100%;
  padding: 15px 30px;
  background: transparent;
  color: #fff;
  border: 2px solid #666;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 15px;
}

#skip-btn:hover {
  background: #666;
  color: #fff;
  border-color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 102, 102, 0.2);
}

#protocol-header {
  background: #000;
  color: #fff;
  padding: 25px 20px;
  text-align: center;
  border-bottom: 2px solid #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 120px;
}

#protocol-info {
  max-width: 900px;
  width: 100%;
}

#protocol-phase {
  margin: 0 0 15px 0;
  font-size: 2.2rem;
  font-weight: 400;
  letter-spacing: 1px;
  text-transform: uppercase;
}

#protocol-instruction {
  margin: 0 0 15px 0;
  font-size: 1.4rem;
  color: #ccc;
  line-height: 1.4;
  max-width: 800px;
  font-weight: 300;
}

/* Hide protocol instruction during preparation and explanation phases */
#protocol-header.explanation-phase #protocol-instruction {
  display: none;
}

/* Hide protocol instruction for all preparation phases */
#protocol-instruction {
  display: none;
}

/* Show protocol instruction only for interaction phases */
#protocol-header:not(.explanation-phase) #protocol-instruction {
  display: block;
}

#protocol-timer {
  font-size: 1.8rem;
  font-weight: 500;
  color: #fff;
  background: #333;
  padding: 8px 16px;
  border-radius: 20px;
  display: inline-block;
  border: 2px solid #fff;
  min-width: 100px;
}

/* Hide timer for "Contact Information Sharing" phase */
#protocol-header[data-phase="Contact Information Sharing"] #protocol-timer {
  display: none;
}

#main-content {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

#videostreams {
  flex: 1;
  height: 100%;
  position: relative;
  background: #000;
}

/* Activity Panels */
.activity-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  color: #fff;
  display: none;
  z-index: 500;
}

/* Text Chat */
#textchat {
  display: flex;
  flex-direction: column;
  padding: 20px;
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  border: 2px solid #fff;
  padding: 20px;
  margin-bottom: 20px;
  background: #000;
  border-radius: 8px;
}

.chat-message {
  margin-bottom: 15px;
  padding: 15px;
  border-left: 4px solid #fff;
  background: #111;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.chat-message:hover {
  background: #222;
  transform: translateX(5px);
}

.chat-message .username {
  font-weight: 600;
  color: #fff;
  margin-bottom: 5px;
  display: block;
}

#chat-input-container {
  display: flex;
  gap: 10px;
}

#chat-input {
  flex: 1;
  padding: 15px;
  border: 2px solid #fff;
  background: #000;
  color: #fff;
  font-size: 16px;
  outline: none;
  border-radius: 4px;
  transition: all 0.3s ease;
}

#chat-input:focus {
  border-color: #ccc;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

#chat-input::placeholder {
  color: #666;
}

#chat-send {
  padding: 15px 25px;
  background: #fff;
  color: #000;
  border: 2px solid #fff;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition: all 0.3s ease;
  border-radius: 4px;
  text-transform: uppercase;
}

#chat-send:hover {
  background: #000;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.2);
}

/* Canvas Panel */
#canvas-panel {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#collaborative-canvas {
  border: 2px solid #fff;
  background: #fff;
  cursor: crosshair;
  margin-bottom: 20px;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  transition: all 0.3s ease;
}

#collaborative-canvas:hover {
  border-color: #ccc;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

#canvas-tools {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

#canvas-tools input, #canvas-tools button {
  padding: 12px 18px;
  border: 2px solid #fff;
  background: #fff;
  color: #000;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  border-radius: 4px;
  transition: all 0.3s ease;
  text-transform: uppercase;
}

#canvas-tools button:hover, #canvas-tools input:hover {
  background: #ccc;
  color: #000;
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(255, 255, 255, 0.2);
}

/* Piano Panel */
#piano-panel {
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow-x: auto;
}

#piano-controls {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  padding: 15px;
  background: #111;
  border: 2px solid #fff;
  border-radius: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.control-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}

.control-group label {
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#piano-controls input[type="range"] {
  width: 80px;
  height: 6px;
  background: #333;
  outline: none;
  border-radius: 3px;
  cursor: pointer;
}

#piano-controls input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

#piano-controls input[type="range"]::-webkit-slider-thumb:hover {
  background: #ccc;
  transform: scale(1.1);
}

#piano-controls select {
  padding: 8px 12px;
  background: #000;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

#piano-controls select:hover {
  background: #fff;
  color: #000;
}

#piano-keys {
  display: flex;
  border: 2px solid #fff;
  overflow: hidden;
  min-width: 600px;
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.piano-key {
  width: 50px;
  height: 200px;
  border-right: 1px solid #666;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-weight: 600;
  user-select: none;
  transition: all 0.1s ease;
  padding-bottom: 10px;
}

.piano-key.white {
  background: #fff;
  color: #000;
}

.piano-key.black {
  background: #000;
  color: #fff;
  width: 30px;
  height: 120px;
  margin-left: -15px;
  margin-right: -15px;
  z-index: 2;
  position: relative;
  border: 1px solid #fff;
}

.piano-key:hover, .piano-key.active {
  background: #666;
  color: #fff;
  transform: translateY(2px);
}

.piano-key.black:hover, .piano-key.black.active {
  background: #333;
  transform: translateY(2px);
}

/* Audio Only Interface */
#audio-only-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 600;
}

.audio-visual {
  text-align: center;
  color: #fff;
}

.audio-icon {
  font-size: 5rem;
  margin-bottom: 30px;
  animation: pulse 2s infinite;
  opacity: 0.9;
}

.audio-text {
  font-size: 2.5rem;
  font-weight: 300;
  margin-bottom: 15px;
  letter-spacing: 1px;
}

.audio-description {
  font-size: 1.4rem;
  opacity: 0.8;
  font-weight: 300;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}

/* Controls */
#controls {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1000;
}

#swapbutton {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  border: 2px solid #fff;
  background: #000;
  color: #fff;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#swapbutton:hover {
  background: #fff;
  color: #000;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.2);
}

/* Video Elements */
#localVideo {
  position: absolute;
  bottom: 20px;
  left: 20px;
  width: 250px;
  height: 180px;
  border: 2px solid #fff;
  z-index: 100;
  object-fit: cover;
  border-radius: 8px;
  transition: all 0.3s ease;
}

#localVideo:hover {
  border-color: #ccc;
  transform: scale(1.02);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

#remotevideos {
  display: flex;
  width: 100%;
  min-height: 100%;
  flex-direction: row;
  flex-wrap: unset;
  justify-content: center;
  align-items: center;
}

.remotevideo {
  outline: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  display: block;
  border-radius: 8px;
}

/* Enhanced animations for explanation phases */
#protocol-header.explanation-phase {
  animation: fadeInScale 0.8s ease;
}

@keyframes fadeInScale {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Mobile touch support for canvas */
#collaborative-canvas {
  touch-action: none;
}

/* Improved mobile form controls */
input, button, select, textarea {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border-radius: 4px;
}

/* Better mobile button sizing */
button {
  min-height: 44px;
  min-width: 44px;
}

/* Prevent zoom on input focus on iOS */
input[type="text"], input[type="number"], input[type="color"], input[type="range"] {
  font-size: 16px;
}

/* Mobile-specific optimizations */
@supports (-webkit-appearance: none) {
  input[type="range"] {
    -webkit-appearance: none;
    height: 8px;
    border-radius: 4px;
    background: #333;
    outline: none;
  }
  
  input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    border: 2px solid #000;
  }
}

/* Improve mobile scrolling */
* {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* Remove tap highlight on mobile */
* {
  -webkit-tap-highlight-color: transparent;
  tap-highlight-color: transparent;
}

/* Fix mobile input styling */
input, textarea, select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border-radius: 8px;
}

/* Mobile-first responsive design */
@media (max-width: 768px) {
  body {
    font-size: 16px;
    line-height: 1.5;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
  }
  
  * {
    box-sizing: border-box;
  }

  /* Better mobile form */
  #joinform {
    padding: 30px 20px;
    margin: 20px;
    width: calc(100% - 40px);
    max-width: none;
  }
  
  #joinform legend {
    font-size: 2.2rem;
    margin-bottom: 25px;
  }
  
  #joinform input {
    padding: 18px;
    font-size: 18px;
    border-radius: 8px;
  }
  
  #joinform button {
    padding: 18px;
    font-size: 18px;
    border-radius: 8px;
    font-weight: 700;
  }
  
  /* Protocol header mobile optimization */
  #protocol-header {
    padding: 15px 10px;
    min-height: 80px;
  }
  
  #protocol-phase {
    font-size: 1.6rem;
    margin-bottom: 10px;
    line-height: 1.2;
  }
  
  #protocol-timer {
    font-size: 1.2rem;
    padding: 8px 16px;
  }

  /* Instruction overlay mobile optimization */
  #instruction-content {
    padding: 40px 25px;
    width: 95%;
    margin: 20px;
  }
  
  #instruction-text {
    font-size: 1.6rem;
    line-height: 1.4;
  }
  
  .waiting-content h2 {
    font-size: 2rem;
    margin-bottom: 20px;
  }
  
  .waiting-content p {
    font-size: 1.1rem;
    padding: 0 20px;
  }
  
  /* Mobile video adjustments */
  #localVideo {
    width: 120px;
    height: 80px;
    bottom: 15px;
    left: 15px;
    border-radius: 12px;
  }
  
  #controls {
    top: 15px;
    right: 15px;
  }
  
  #swapbutton {
    padding: 12px 16px;
    font-size: 14px;
    border-radius: 8px;
    font-weight: 600;
  }
  
  /* Enhanced text chat for mobile */
  #textchat {
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    width: 100vw;
    position: relative;
  }
  
  #chat-messages {
    flex: 1;
    padding: 20px;
    margin: 15px 15px 0 15px;
    font-size: 16px;
    line-height: 1.5;
    border-radius: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: calc(100vh - 120px);
  }
  
  .chat-message {
    margin-bottom: 18px;
    padding: 16px;
    border-radius: 12px;
    border-left-width: 4px;
    font-size: 16px;
    line-height: 1.4;
  }
  
  .chat-message .username {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  
  #chat-input-container {
    padding: 15px;
    gap: 12px;
    background: #111;
    border-top: 2px solid #333;
    position: sticky;
    bottom: 0;
    width: 100%;
    display: flex;
    flex-shrink: 0;
    z-index: 1000;
  }
  
  #chat-input {
    flex: 1;
    padding: 16px;
    font-size: 16px;
    border-radius: 12px;
    line-height: 1.4;
    min-height: 48px;
  }
  
  #chat-send {
    padding: 16px 20px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 12px;
    min-width: 80px;
    min-height: 48px;
    flex-shrink: 0;
  }
  
  /* Canvas mobile optimization */
  #canvas-panel {
    padding: 15px;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: 100vw;
    position: relative;
  }
  
  #collaborative-canvas {
    width: calc(100vw - 30px);
    height: calc(65vh);
    max-width: none;
    border-radius: 12px;
    margin-bottom: 20px;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }
  
  #canvas-tools {
    padding: 15px;
    background: #fff;
    border: 2px solid #fff;
    border-radius: 12px;
    gap: 15px;
    justify-content: space-around;
    flex-wrap: wrap;
    position: sticky;
    bottom: 0;
    width: calc(100vw - 30px);
  }
  
  #canvas-tools input[type="color"] {
    width: 60px;
    height: 50px;
    border-radius: 12px;
    border: 3px solid #000;
    background: #fff;
    min-height: 48px;
    min-width: 48px;
  }
  
  #canvas-tools input[type="range"] {
    flex: 1;
    min-width: 120px;
    height: 8px;
    background: #000;
  }
  
  #canvas-tools button {
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 8px;
    min-width: 80px;
    min-height: 48px;
    background: #000;
    color: #fff;
    border: 2px solid #000;
  }
  
  /* Piano mobile optimization */
  #piano-panel {
    padding: 15px 10px;
    height: 100vh;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  
  #piano-controls {
    gap: 12px;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 12px;
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .control-group {
    min-width: 90px;
    gap: 10px;
  }
  
  .control-group label {
    font-size: 12px;
    font-weight: 700;
  }
  
  #piano-controls input[type="range"] {
    width: 80px;
    height: 6px;
  }
  
  #piano-controls select {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
  }
  
  #piano-keys {
    min-width: calc(100vw - 20px);
    border-radius: 12px;
    height: 220px;
    display: flex;
    align-items: flex-end;
  }
  
  .piano-key {
    width: 45px;
    height: 200px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 0 0 8px 8px;
  }
  
  .piano-key.black {
    width: 28px;
    height: 130px;
    margin-left: -14px;
    margin-right: -14px;
    font-size: 12px;
    border-radius: 0 0 6px 6px;
  }
  
  /* Audio interface mobile */
  .audio-icon {
    font-size: 4.5rem;
    margin-bottom: 25px;
  }
  
  .audio-text {
    font-size: 2.2rem;
    margin-bottom: 15px;
  }
  
  .audio-description {
    font-size: 1.3rem;
    padding: 0 30px;
    line-height: 1.4;
  }
}

@media (max-width: 480px) {
  /* Extra small mobile devices */
  #joinform {
    padding: 25px 20px;
    margin: 15px;
    width: calc(100% - 30px);
  }
  
  #joinform legend {
    font-size: 1.9rem;
    margin-bottom: 20px;
  }
  
  #joinform input, #joinform button {
    padding: 16px;
    font-size: 17px;
  }
  
  /* Compact protocol header */
  #protocol-header {
    padding: 12px 8px;
    min-height: 70px;
  }
  
  #protocol-phase {
    font-size: 1.4rem;
    margin-bottom: 8px;
  }
  
  #protocol-timer {
    font-size: 1.1rem;
    padding: 8px 14px;
  }

  /* Compact instruction overlay */
  #instruction-content {
    padding: 30px 20px;
    width: 95%;
    margin: 15px;
  }
  
  #instruction-text {
    font-size: 1.4rem;
    line-height: 1.3;
  }
  
  .waiting-content h2 {
    font-size: 1.8rem;
  }
  
  .waiting-content p {
    font-size: 1rem;
    padding: 0 25px;
  }
  
  /* Smaller video on tiny screens */
  #localVideo {
    width: 100px;
    height: 65px;
    bottom: 10px;
    left: 10px;
  }
  
  #swapbutton {
    padding: 10px 14px;
    font-size: 13px;
  }
  
  /* Optimized text chat for small screens */
  #chat-messages {
    margin: 10px 10px 0 10px;
    padding: 15px;
    font-size: 15px;
    max-height: calc(100vh - 110px);
  }
  
  .chat-message {
    padding: 14px;
    font-size: 15px;
    margin-bottom: 15px;
  }
  
  .chat-message .username {
    font-size: 13px;
  }
  
  #chat-input-container {
    padding: 12px;
    position: sticky;
    bottom: 0;
    background: #111;
    border-top: 2px solid #333;
  }
  
  #chat-input, #chat-send {
    padding: 14px;
    font-size: 15px;
    min-height: 48px;
  }
  
  /* Compact canvas */
  #collaborative-canvas {
    width: calc(100vw - 20px);
    height: calc(60vh);
  }
  
  #canvas-tools {
    padding: 12px;
    gap: 12px;
    background: #fff;
    border: 2px solid #fff;
    position: sticky;
    bottom: 0;
  }
  
  #canvas-tools input[type="color"] {
    width: 50px;
    height: 45px;
    border: 2px solid #000;
    min-height: 48px;
    min-width: 48px;
  }
  
  #canvas-tools button {
    padding: 10px 15px;
    font-size: 13px;
    min-width: 70px;
    min-height: 48px;
    background: #000;
    color: #fff;
    border: 2px solid #000;
  }
  
  /* Compact piano */
  #piano-keys {
    height: 200px;
  }
  
  .piano-key {
    width: 40px;
    height: 180px;
    font-size: 13px;
  }
  
  .piano-key.black {
    width: 25px;
    height: 115px;
    margin-left: -12px;
    margin-right: -12px;
    font-size: 11px;
  }
  
  #piano-controls {
    padding: 12px;
    gap: 10px;
  }
  
  .control-group {
    min-width: 75px;
  }
  
  .control-group label {
    font-size: 11px;
  }
  
  #piano-controls input[type="range"] {
    width: 70px;
  }
  
  #piano-controls select {
    padding: 6px 10px;
    font-size: 11px;
  }
  
  /* Audio interface for small screens */
  .audio-icon {
    font-size: 4rem;
  }
  
  .audio-text {
    font-size: 2rem;
  }
  
  .audio-description {
    font-size: 1.2rem;
    padding: 0 20px;
  }
  
  /* Mobile attribution positioning */
  .floating-attribution {
    bottom: 15px;
    right: 15px;
    font-size: 0.9rem;
  }
}

/* Enhanced touch interactions */
@media (pointer: coarse) {
  button, .piano-key, #canvas-tools input {
    min-height: 48px;
    min-width: 48px;
  }
  
  .piano-key {
    touch-action: manipulation;
  }
  
  #collaborative-canvas {
    touch-action: none;
  }
  
  input[type="range"] {
    min-height: 44px;
  }
  
  /* Larger tap targets for better mobile UX */
  #chat-send {
    min-width: 80px;
    min-height: 48px;
  }
  
  #swapbutton {
    min-height: 44px;
    min-width: 44px;
  }
}

/* Instruction Overlay */
#instruction-overlay {
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
  z-index: 1000;
}

#instruction-content {
  max-width: 800px;
  width: 90%;
  text-align: center;
  padding: 60px 40px;
  background: #111;
  border: 3px solid #fff;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(255, 255, 255, 0.1);
}

#instruction-text {
  font-size: 2.2rem;
  line-height: 1.5;
  color: #fff;
  font-weight: 300;
  letter-spacing: 0.5px;
  margin: 0;
}

/* Contact Panel */
#contact-panel {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

#contact-content {
  max-width: 500px;
  width: 100%;
}

#contact-content h2 {
  margin-bottom: 20px;
  font-size: 2rem;
  color: #fff;
  font-weight: 300;
  letter-spacing: 1px;
}

#contact-content p {
  margin-bottom: 15px;
  font-size: 1.2rem;
  color: #ddd;
  line-height: 1.6;
  font-weight: 300;
}

#contact-form {
  background: rgba(255, 255, 255, 0.05);
  padding: 35px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  margin: 30px 0;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.contact-field {
  margin-bottom: 20px;
  text-align: left;
}

.contact-field label {
  display: block;
  margin-bottom: 8px;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

.contact-field input,
.contact-field textarea {
  width: 100%;
  padding: 15px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border-radius: 8px;
  font-size: 16px;
  transition: all 0.3s ease;
  box-sizing: border-box;
  backdrop-filter: blur(5px);
}

.contact-field input:focus,
.contact-field textarea:focus {
  border-color: #fff;
  outline: none;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.8);
  transform: translateY(-1px);
}

.contact-field textarea {
  resize: vertical;
  min-height: 80px;
}

.contact-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 25px;
}

.contact-buttons button {
  padding: 15px 25px;
  font-size: 16px;
  font-weight: 600;
  border: 2px solid #fff;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  min-width: 120px;
}

#contact-share {
  background: #4CAF50;
  color: #fff;
  border-color: #4CAF50;
}

#contact-share:hover {
  background: #45a049;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.3);
}

#contact-skip {
  background: transparent;
  color: #fff;
  border-color: #666;
}

#contact-skip:hover {
  background: #666;
  color: #fff;
  border-color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 102, 102, 0.3);
}

#contact-result {
  background: #111;
  padding: 30px;
  border-radius: 8px;
  border: 2px solid #fff;
  margin: 20px 0;
}

#contact-message {
  font-size: 1.2rem;
  margin-bottom: 20px;
}

.partner-contact-info {
  background: #222;
  padding: 20px;
  border-radius: 4px;
  text-align: left;
  margin-top: 15px;
}

.partner-contact-info p {
  margin-bottom: 10px;
  color: #fff;
  font-size: 1rem;
}

.partner-contact-info strong {
  color: #4CAF50;
}

/* Prevent text selection on interactive elements */
.piano-key, button, #canvas-tools input {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Improve scrolling performance */
#chat-messages, #piano-panel {
  -webkit-overflow-scrolling: touch;
  overflow-scrolling: touch;
}

/* Hide address bar on mobile browsers */
@media screen and (max-width: 768px) {
  body {
    min-height: 100vh;
    min-height: -webkit-fill-available;
  }
  
  html {
    height: -webkit-fill-available;
  }
  
  #chatroom, .activity-panel {
    height: 100vh;
    height: -webkit-fill-available;
  }
}

/* Tablet Landscape */
@media (min-width: 769px) and (max-width: 1024px) {
  #protocol-instruction {
    font-size: 1.6rem;
  }
  
  #localVideo {
    width: 280px;
    height: 200px;
  }
}

/* Large Desktop */
@media (min-width: 1200px) {
  #joinform {
    max-width: 500px;
    padding: 50px;
  }
  
  #protocol-instruction {
    font-size: 2rem;
  }
  
  #localVideo {
    width: 320px;
    height: 240px;
  }
  
  #collaborative-canvas {
    width: 900px;
    height: 600px;
  }
  
  #protocol-phase {
    font-size: 3.5rem;
  }
}
