@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --background: #f5f4ed;
  --sidebar: #f0eee8;
  --surface: #fcfbf7;
  --border: #e4e2da;
  --text-primary: #383631;
  --text-secondary: #7a7874;
  --primary: #607d8b;
  --primary-hover: #546e7a;
}

body {
  font-family:
    'Inter',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  background-color: var(--background);
  color: var(--text-primary);
  margin: 0;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: calc(100vh - 48px);
  box-sizing: border-box;
}

#app {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 0;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  width: 100%;
}

header h1 {
  margin: 0;
  font-size: 1.5em;
  font-weight: 600;
}

#session-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9em;
  flex-wrap: nowrap;
}

#session-info a {
  color: var(--primary);
  text-decoration: none;
}
#session-info a:hover {
  text-decoration: underline;
}

#qr-container {
  position: relative;
  padding: 2px;
  display: flex;
  align-items: center;
}

#qr-code {
  width: 28px;
  height: 28px;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: white;
  padding: 2px;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  box-sizing: content-box;
}

#qr-code:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 4px rgba(96, 125, 139, 0.2);
}

/* QR Modal Styles */
#qr-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
}

#qr-modal-content {
  position: relative;
  background: white;
  padding: 32px 32px 24px 32px;
  border-radius: 12px;
  max-width: 90vw;
  max-height: 90vh;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

#qr-code-large {
  width: 300px;
  height: 300px;
  display: block;
  margin: 0 auto;
}

#qr-close-btn {
  position: absolute;
  top: -12px;
  right: -12px;
  background: var(--surface);
  border: 2px solid var(--border);
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 0;
  margin: 0;
  line-height: 1;
  text-align: center;
}

#qr-close-btn:hover {
  background: var(--text-primary);
  color: white;
  border-color: var(--text-primary);
  transform: scale(1.05);
}

#bookmarklet-container {
  position: relative;
  padding: 2px;
  display: flex;
  align-items: center;
}

#bookmarklet-btn {
  width: 28px;
  height: 28px;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  padding: 2px;
  transition:
    border-color 0.2s,
    box-shadow 0.2s,
    background-color 0.2s;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  color: var(--text-secondary);
  box-sizing: content-box;
}

#bookmarklet-btn:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 4px rgba(96, 125, 139, 0.2);
  background-color: var(--sidebar);
  color: var(--text-primary);
}

/* Bookmarklet Modal Styles */
#bookmarklet-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
}

#bookmarklet-modal-content {
  position: relative;
  background: var(--surface);
  padding: 24px;
  border-radius: 8px;
  max-width: 600px;
  max-height: 90vh;
  width: 90vw;
  overflow-y: auto;
  border: 1px solid var(--border);
}

#bookmarklet-modal-content h3 {
  margin: 0 0 20px 0;
  color: var(--text-primary);
  font-size: 1.4em;
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.02em;
}

#bookmarklet-modal-content h4 {
  margin: 0 0 12px 0;
  color: var(--text-primary);
  font-size: 1.1em;
  font-weight: 600;
  letter-spacing: -0.01em;
}

#bookmarklet-modal-content p {
  margin: 0 0 20px 0;
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: 0.95em;
  text-align: center;
}

#bookmarklet-link-container {
  margin: 16px 0;
  padding: 12px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
}

#bookmarklet-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--primary);
  border-radius: 4px;
  display: inline-block;
  transition: background-color 0.2s;
}

#bookmarklet-link:hover {
  background: var(--primary);
  color: white;
}

#bookmarklet-code-container {
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#bookmarklet-code {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 0.8em;
  background: var(--background);
  color: var(--text-primary);
  resize: vertical;
  box-sizing: border-box;
}

#copy-bookmarklet-btn {
  align-self: flex-end;
  padding: 8px 16px;
  font-size: 0.9em;
  background: var(--primary);
  color: white;
  border: 1px solid var(--primary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

#copy-bookmarklet-btn:hover {
  background: var(--text-primary);
  border-color: var(--text-primary);
  transform: translateY(-1px);
}

#bookmarklet-instructions {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

#bookmarklet-instructions ol {
  margin: 12px 0;
  padding-left: 24px;
  color: var(--text-secondary);
  line-height: 1.7;
}

#bookmarklet-instructions ol li {
  margin-bottom: 10px;
  font-size: 0.95em;
}

#bookmarklet-instructions strong {
  color: var(--text-primary);
  font-weight: 600;
}

#bookmarklet-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--surface);
  border: 2px solid var(--border);
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 0;
  margin: 0;
  line-height: 1;
  text-align: center;
}

#bookmarklet-close-btn:hover {
  background: var(--text-primary);
  color: white;
  border-color: var(--text-primary);
  transform: scale(1.05);
}

.container {
  background: var(--surface);
  padding: 24px;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.hidden {
  display: none !important;
}

#user-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px;
}

#user-setup h2 {
  margin: 0;
  font-weight: 500;
  text-align: center;
}

#user-setup input {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
  font-size: 1em;
  width: 280px;
  max-width: 100%;
  box-sizing: border-box;
}
#user-setup input:focus {
  outline: 2px solid var(--primary);
  border-color: var(--primary);
}

.button-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

button {
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: 6px;
  background-color: var(--primary);
  color: white;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 500;
  transition:
    background-color 0.2s,
    border-color 0.2s,
    color 0.2s;
}

button.secondary {
  background-color: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

button.secondary:hover {
  background-color: var(--sidebar);
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

button:hover {
  background-color: var(--primary-hover);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

#poker-room {
  display: grid;
  grid-template-areas:
    'participants voting'
    'participants controls';
  grid-template-columns: 250px 1fr;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 24px;
  min-height: 0;
  overflow: hidden;
}

#participants-section {
  grid-area: participants;
  min-height: 0;
  overflow-y: auto;
}
#voting-section {
  grid-area: voting;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#controls-section {
  grid-area: controls;
}

.container h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.1em;
  font-weight: 600;
  color: var(--text-primary);
}

#participants-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#participants-list li {
  padding: 12px;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--background);
  border: 1px solid var(--border);
  font-size: 0.95em;
}

.participant-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-grow: 1;
}

.kick-btn {
  background-color: var(--text-secondary);
  color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  margin-left: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: all 0.2s;
  opacity: 0.7;
  text-align: center;
  font-family: monospace;
}

.kick-btn:hover {
  background-color: var(--text-primary);
  border-color: var(--text-primary);
  opacity: 1;
  transform: scale(1.1);
}

#participants-list .vote-status {
  font-weight: 600;
  font-size: 1.1em;
}

#participants-list .voted {
  color: var(--primary);
}

#participants-list .waiting {
  color: var(--text-secondary);
  font-weight: 500;
}

#cards-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-content: flex-start;
  /* 5 cards per row: (70px width + 2px border) * 5 cards + 12px gap * 4 gaps */
  max-width: 408px;
  margin: 0 auto;
}

.card {
  width: 70px;
  height: 100px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.8em;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface);
  transition:
    transform 0.15s,
    box-shadow 0.15s,
    border-color 0.15s;
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
}

.card.selected {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary-hover);
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

#cards-container.disabled .card {
  cursor: not-allowed;
  opacity: 0.6;
}

#cards-container.disabled .card:hover {
  transform: none;
  border-color: var(--border);
  box-shadow: none;
}

#cards-container.disabled .card.selected {
  transform: none;
  box-shadow: none;
}

#controls-section {
  display: flex;
  gap: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  align-items: flex-start;
}

#controls-section .buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#controls-section .buttons h2 {
  margin-bottom: 4px;
}

#suggestion-container {
  text-align: center;
  flex-grow: 1;
}

#suggestion-value {
  font-size: 2.5em;
  font-weight: 700;
  color: var(--primary);
  background-color: var(--background);
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  min-height: 50px;
}

#suggestion-value.long-text {
  font-size: 1.5em;
  padding-top: 30px;
  padding-bottom: 30px;
}

#reveal-btn {
  background-color: var(--primary);
}
#reveal-btn:hover {
  background-color: var(--primary-hover);
}

#reset-btn {
  background-color: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
#reset-btn:hover {
  background-color: var(--sidebar);
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

#copy-url-btn {
  background-color: var(--sidebar);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
#copy-url-btn:hover {
  background-color: var(--border);
  color: var(--text-primary);
}

#copy-container {
  position: relative;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  background-color: var(--sidebar);
  border: 1px solid var(--border);
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  min-height: 20px;
}

#copy-container:hover {
  background-color: var(--border);
}

#copy-feedback {
  margin-left: 8px;
  font-weight: 600;
  color: var(--primary);
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
  body {
    padding: 12px;
  }

  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  #poker-room {
    grid-template-areas:
      'participants'
      'voting'
      'controls';
    grid-template-columns: 1fr;
  }

  #user-setup {
    padding: 24px;
  }

  #controls-section {
    flex-direction: column;
    align-items: stretch;
  }

  #suggestion-container {
    width: 100%;
  }

  #cards-container {
    /* 5 cards per row: (60px width + 2px border) * 5 cards + 12px gap * 4 gaps */
    max-width: 358px;
  }

  .card {
    width: 60px;
    height: 90px;
    font-size: 1.5em;
  }

  #bookmarklet-modal-content {
    width: 95vw;
    padding: 16px;
  }

  #bookmarklet-code {
    font-size: 0.7em;
    min-height: 100px;
  }
}
