:root {
  color-scheme: light;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f3f4f6;
  color: #1f2937;
}

html,
body {
  min-width: 0;
  width: 100%;
  overflow-x: auto;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(12px, 2vw, 24px);
}

#disqus_thread {
  width: 100%;
  max-width: 1000px;
  margin-top: clamp(24px, 3vw, 32px);
}

.container {
  width: auto;
  max-width: none;
  min-width: 0;
  background: #ffffff;
  padding: clamp(10px, 3vw, 24px);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

h1 {
  margin-top: 0;
  font-size: clamp(18px, 5vw, 28px);
  text-align: center;
  margin-bottom: clamp(15px, 3vw, 30px);
}

.input-section {
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2vw, 18px);
  margin-bottom: clamp(15px, 3vw, 30px);
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(10px, 2vw, 15px);
  width: 100%;
  min-width: 0;
}

.input-group {
  display: grid;
  gap: clamp(3px, 1vw, 6px);
}

.input-group label {
  font-size: clamp(12px, 2vw, 14px);
  font-weight: 600;
  color: #374151;
}

.input-group input,
.input-group select {
  padding: clamp(6px, 1.5vw, 8px) clamp(8px, 1.5vw, 10px);
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: clamp(10px, 2vw, 14px);
  font-family: inherit;
  min-width: 0;
}

.input-group select {
  cursor: pointer;
}

button {
  padding: clamp(8px, 1.5vw, 10px) clamp(15px, 3vw, 24px);
  font-size: clamp(13px, 2.5vw, 16px);
  font-weight: 600;
  color: #ffffff;
  background: #3b82f6;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

button {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  white-space: normal;
  min-height: 0;
}

button:hover {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.message {
  text-align: center;
  font-size: clamp(12px, 2.5vw, 15px);
  font-weight: 600;
  color: #3b82f6;
  margin-bottom: clamp(12px, 2vw, 20px);
  min-height: 18px;
}

.message.error {
  color: #ef4444;
}

/* 교실 레이아웃 */
.classroom {
  position: relative;
  background: #fafafa;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  padding: clamp(12px, 3vw, 25px) clamp(8px, 2vw, 15px);
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 2vw, 15px);
  width: auto;
  max-width: none;
  min-width: 0;
  overflow-x: auto;
}

/* 칠판 */
.blackboard {
  background: #1f2937;
  color: #ffffff;
  text-align: center;
  padding: clamp(10px, 2vw, 15px);
  font-size: clamp(14px, 3vw, 18px);
  font-weight: 700;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  order: -1;
}

/* 자리 배치 영역 */
.seating-area {
  display: grid;
  grid-auto-rows: auto;
  gap: clamp(5px, 1.5vw, 10px);
  min-width: 0;
  width: auto;
  overflow-x: auto;
}

.seat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 1.5vw, 12px);
  min-width: 0;
  width: auto;
}

.seat-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2px, 1vw, 5px);
  aspect-ratio: 4 / 1;
  min-width: 0;
  min-height: 0;
}

.seat-card {
  border: 1px solid #9ca3af;
  border-radius: 3px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1px, 1vw, 4px);
  font-size: clamp(6px, 1.5vw, 12px);
  font-weight: 600;
  text-align: center;
  color: #1f2937;
  overflow: hidden;
  word-break: break-word;
  line-height: 1.1;
  transition: transform 0.15s ease;
  min-height: 0;
  min-width: 0;
}

.seat-card.male {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1e3a8a;
}

.seat-card.female {
  background: #fce7f3;
  border-color: #ec4899;
  color: #831843;
}

.seat-card.empty {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #9ca3af;
}

/* Mobile (portrait) responsive fixes */
@media (max-width: 600px) {
  body {
    align-items: flex-start;
    padding: 6px;
  }

  .container {
    padding: clamp(10px, 2vw, 18px);
    max-width: 100%;
    width: 100%;
    max-height: calc(100vh - 12px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  h1 {
    font-size: clamp(16px, 4vw, 20px);
    margin-bottom: clamp(12px, 2vw, 18px);
  }

  .input-grid {
    grid-template-columns: 1fr;
  }

  .classroom {
    padding: clamp(8px, 2vw, 12px) clamp(6px, 1.5vw, 10px);
  }

  .seating-area {
    display: grid;
    grid-auto-rows: auto;
    grid-template-rows: none;
    gap: clamp(5px, 1.5vw, 8px);
  }

  .seat-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(6px, 1.5vw, 10px);
  }

  .seat-pair {
    grid-template-columns: 1fr 1fr;
    gap: clamp(2px, 1vw, 5px);
    aspect-ratio: 5 / 1;
  }

  .seat-card {
    font-size: clamp(8px, 2vw, 12px);
    padding: clamp(2px, 0.8vw, 5px);
    min-height: clamp(18px, 5vw, 30px);
    min-width: 0;
  }
}

