body {
  font-family: "Segoe UI", sans-serif;
  margin: 0;
  padding: 0;
  background: #f5f7fa;
  color: #333;
}

header {
  text-align: center;
  padding: 2rem 1rem 1rem;
  background-color: #2c3e50;
  color: white;
  position: relative;
}

h1 {
  margin: 0;
  font-size: 2rem;
}

.tabs {
  display: flex;
  justify-content: center;
  background-color: #ecf0f1;
  padding: 0.5rem;
}

.tab-button {
  padding: 0.5rem 1rem;
  margin: 0 0.5rem;
  border: none;
  background-color: #bdc3c7;
  color: #2c3e50;
  cursor: pointer;
  font-size: 1rem;
  border-radius: 5px;
  transition: background-color 0.3s ease;
}

.tab-button.active {
  background-color: #3498db;
  color: white;
}

.tab-content {
  display: none;
  max-width: 800px;
  margin: 2rem auto;
  padding: 1.5rem;
  background-color: white;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.tab-content.active {
  display: block;
}

textarea {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  resize: vertical;
  margin-bottom: 1rem;
  box-sizing: border-box;
}

button {
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  border-radius: 6px;
  border: none;
  background-color: #3498db;
  color: white;
  cursor: pointer;
  transition: background-color 0.3s ease;
  margin-top: 0.5rem;
}

button:hover {
  background-color: #2980b9;
}

.glyph-output {
  margin-top: 1rem;
  padding: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.glyph-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 60px);
  gap: 10px;
  justify-content: center;
  margin: 1rem 0;
}

.glyph-grid img,
.glyph-output img {
  width: 60px;
  height: 60px;
  cursor: pointer;
  border: 1px solid #ccc;
  border-radius: 6px;
  background-color: #fff;
  padding: 4px;
  box-sizing: border-box;
}

.space-button {
  width: 60px;
  height: 60px;
  cursor: pointer;
  border: 1px solid #ccc;
  border-radius: 6px;
  background-color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #666;
  font-weight: 500;
  transition: all 0.2s ease;
  padding: 4px;
  box-sizing: border-box;
}

.space-button:hover {
  background-color: #e9ecef;
  border-color: #adb5bd;
  color: #495057;
}

.output-text {
  text-align: center;
  font-size: 1.25rem;
  margin: 1rem 0;
  font-weight: bold;
  border: 1px solid #ccc;
  border-radius: 8px;
  background-color: #f8f9fa;
  padding: 1rem;
  min-height: 2rem;
  word-wrap: break-word;
  box-sizing: border-box;
}

.learn-content {
  line-height: 1.6;
  font-size: 1rem;
}

footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.9rem;
  background-color: #ecf0f1;
  margin-top: 2rem;
}

.alphabet-reference {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 15px;
  margin-top: 2rem;
  padding: 1rem;
  background-color: #f8f9fa;
  border-radius: 8px;
}

.reference-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.reference-letter {
  font-size: 1.2rem;
  font-weight: bold;
  color: #2c3e50;
}

.reference-glyph {
  width: 50px;
  height: 50px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: white;
  padding: 3px;
}

.cipher-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.cipher-glyph {
  width: 60px;
  height: 60px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background-color: #fff;
  padding: 4px;
}

.cipher-letter {
  font-size: 0.9rem;
  color: #666;
  font-weight: 500;
}

.glyph-selector {
  margin: 1rem 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.glyph-selector label {
  font-size: 0.9rem;
  font-weight: 500;
  color: #333;
}

.glyph-selector select {
  padding: 5px 10px;
  font-size: 0.9rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: #fff;
  color: #333;
  cursor: pointer;
}

.glyph-selector select:hover {
  background-color: #f0f0f0;
  border-color: #999;
}

.controls-row {
  display: flex;
  gap: 2rem;
  margin: 1rem 0;
  align-items: center;
  flex-wrap: wrap;
}

.space-toggle {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.toggle-switch {
  display: flex;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s ease;
}

.toggle-switch:hover {
  border-color: #3498db;
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.15);
}

.toggle-option {
  padding: 8px 16px;
  font-size: 0.9rem;
  border: none;
  background-color: transparent;
  color: #6c757d;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  min-width: 60px;
  margin: 0;
  outline: none;
}

.toggle-option:hover:not(.active) {
  background-color: #e9ecef;
  color: #495057;
}

.toggle-option.active {
  background-color: #3498db;
  color: white;
  font-weight: 600;
}

.toggle-option:first-child {
  border-top-left-radius: 7px;
  border-bottom-left-radius: 7px;
}

.toggle-option:last-child {
  border-top-right-radius: 7px;
  border-bottom-right-radius: 7px;
}

.mode-indicator {
  font-size: 0.85rem;
  color: #6c757d;
  padding: 6px 12px;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 6px;
}

.mode-indicator span {
  font-weight: 500;
}

.cipher-space {
  width: 30px;
  height: 60px;
  flex-shrink: 0;
}

.warning-message {
  display: none;
  margin-top: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
  border-radius: 4px;
  font-size: 0.9rem;
}

.reference-item.highlight {
  background-color: #ffeaa7;
  border-radius: 8px;
  transform: scale(1.1);
  transition: all 0.3s ease;
  box-shadow: 0 0 10px rgba(255, 193, 7, 0.6);
}

.reference-item.highlight-recent {
  background-color: #ffb3b3;
  border-radius: 8px;
  transform: scale(1.15);
  transition: all 0.3s ease;
  box-shadow: 0 0 15px rgba(255, 0, 0, 0.6);
  border: 2px solid #ff6666;
}

.reference-item {
  transition: all 0.3s ease;
}

.result-container {
  position: relative;
}

.result-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  margin-top: 1rem;
  position: relative;
}

.copy-toast {
  position: absolute;
  left: 50%;
  top: 50px;
  transform: translateX(-50%);
  background-color: #28a745;
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.copy-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(5px);
}

.learning-section {
  margin-bottom: 3rem;
  padding: 1.5rem;
  background-color: #f8f9fa;
  border-radius: 12px;
  border-left: 4px solid #3498db;
}

.learning-section h3 {
  color: #2c3e50;
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.4rem;
}

.learning-section h4 {
  color: #34495e;
  margin-top: 1.5rem;
  margin-bottom: 0.8rem;
  font-size: 1.1rem;
}

.key-mapping-container {
  margin: 1.5rem 0;
  text-align: center;
}

.key-mapping-selector {
  margin-bottom: 1rem;
}

.key-mapping-selector label {
  font-size: 1rem;
  font-weight: 500;
  color: #333;
  margin-right: 10px;
}

.key-mapping-selector select {
  padding: 8px 12px;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background-color: #fff;
  color: #333;
  cursor: pointer;
}

.key-mapping-display {
  background-color: white;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 0.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.key-mapping-display img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
}

.tips-highlight {
  background-color: #e3f2fd;
  border: 1px solid #2196f3;
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1.5rem;
}

.tips-highlight h4 {
  color: #1976d2;
  margin-top: 0;
}

.learn-content ul {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.learn-content ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.learn-content li {
  margin: 0.5rem 0;
  line-height: 1.6;
}

.reading-guide {
  background-color: white;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1rem 0;
}

.reading-guide h5 {
  color: #2c3e50;
  font-size: 1.1rem;
  margin-top: 1.5rem;
  margin-bottom: 0.8rem;
  font-weight: 600;
}

.reading-guide h5:first-child {
  margin-top: 0;
}

.reading-guide p {
  margin: 0.8rem 0;
  line-height: 1.6;
}

.reading-guide ul {
  margin: 0.5rem 0 1rem 0;
  padding-left: 2rem;
}

.reading-guide li {
  margin: 0.4rem 0;
  line-height: 1.5;
}

/* ヘルプボタン */
.help-button {
  position: absolute;
  top: 2rem;
  right: calc((100vw - 800px) / 2 - 60px);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid white;
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

@media (max-width: 860px) {
  .help-button {
    right: 1rem;
  }
}

.help-button:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* モーダル */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s ease;
}

.modal.show {
  display: block;
}

.modal-content {
  background-color: #fefefe;
  margin: 5% auto;
  padding: 0;
  border: 1px solid #888;
  width: 80%;
  max-width: 700px;
  max-height: 80vh;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s ease;
}

.modal-header {
  background-color: #2c3e50;
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.close-button {
  color: white;
  font-size: 2rem;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.3s ease;
  line-height: 1;
}

.close-button:hover,
.close-button:focus {
  color: #f1c40f;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.help-section {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #e9ecef;
}

.help-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.help-section h3 {
  color: #2c3e50;
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.help-section ol,
.help-section ul {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.help-section li {
  margin: 0.5rem 0;
  line-height: 1.6;
}

.help-section ul ul {
  margin-top: 0.3rem;
  margin-bottom: 0.3rem;
}

/* アニメーション */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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