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

html, body {
  background: #000000;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

body {
  color: #fff;
  font-family: "Courier New", monospace;
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 20px;
}

#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  flex-shrink: 0;
  gap: 20px;
}

h1 {
  font-size: 1.5rem;
  letter-spacing: 0.3em;
  color: #ffffff;
  text-transform: uppercase;
  opacity: 0.9;
  margin: 0;
}

#options {
  display: flex;
  gap: 10px;
  align-items: center;
}

.info-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  min-width: unset;
  transition: opacity 0.2s;
  position: relative;
}

.info-btn:hover {
  opacity: 0.7;
}

.info-btn::before {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(100% + 8px);
  background: #ffffff22;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: "Courier New", monospace;
  letter-spacing: 0.05em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 10;
}

.info-btn:hover::before {
  opacity: 1;
}

.select-wrapper {
  position: relative;
  display: inline-block;
}

select {
  background: #000000;
  color: #ffffff;
  border: 1px solid #ffffff;
  font-family: "Courier New", monospace;
  font-size: 0.75rem;
  padding: 6px 10px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  outline: none;
}

.select-wrapper::before {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(100% + 8px);
  background: #ffffff22;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: "Courier New", monospace;
  letter-spacing: 0.05em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 10;
}

.select-wrapper:hover::before {
  opacity: 1;
}

select:hover {
  background: #111111;
}

select option {
  background: #000000;
  color: #ffffff;
  padding: 4px;
}

#grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 20px;
  flex: 1;
  width: 100%;
  min-height: 0;
}

.lamp-container {
  width: 100%;
  height: 100%;
  background: #303030;
  border-radius: 8px;
  overflow: hidden;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#bottom-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 20px;
}

#footer {
  background: #000000;
  border: 1px solid #ffffff;
  color: #ffffff;
  font-family: "Courier New", monospace;
  font-size: 0.7rem;
  padding: 8px 12px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  order: 2;
  margin-left: auto;
}

#controls {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  flex-shrink: 1;
  min-width: 0;
  max-width: 100%;
  order: 1;
}

.button-wrapper {
  position: relative;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  height: 40px;
  min-width: 0;
  max-width: 100%;
}

button {
  background: transparent;
  border: 1px solid #ffffff;
  color: #cccccc;
  font-family: inherit;
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  padding: 8px 24px;
  cursor: pointer;
  text-transform: uppercase;
  transition: background 0.2s, color 0.2s;
  min-width: 180px;
  height: 36px;
}

button:hover {
  background: #ffffff11;
  color: #fff;
}

button:active {
  background: #ffffff22;
}

#keys {
  width: 100%;
  max-width: 700px;
  height: 40px;
  min-width: 0;
}

.key-row {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: #cccccc;
  background: #ffffff08;
  padding: 6px 12px;
  border-left: 2px solid #ffffff;
  word-break: break-all;
  opacity: 0;
  animation: fadeIn 0.4s forwards;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.copy-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.2s;
  position: relative;
}

.copy-icon:hover {
  opacity: 1;
}

.copy-icon::before {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  top: -35px;
  background: #ffffff22;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: "Courier New", monospace;
  letter-spacing: 0.05em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.copy-icon:hover::before {
  opacity: 1;
}

@keyframes fadeIn {
  to { opacity: 1; }
}

#toast {
  position: absolute;
  left: calc(100% + 15px);
  top: 50%;
  transform: translateY(-50%);
  background: #ffffff22;
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  white-space: nowrap;
}

#toast.show {
  opacity: 1;
}

.modal {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: #000000;
  border: 2px solid #ffffff;
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 30px;
  max-width: 100%;
  max-height: 100%;
}

.close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  background: transparent;
  border: 1px solid #ffffff;
  color: #ffffff;
  font-size: 1.5rem;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  min-width: unset;
  transition: background 0.2s;
  line-height: 1;
  font-family: Arial, sans-serif;
  letter-spacing: 0;
  text-align: center;
}

.close-btn:hover {
  background: #ffffff22;
}

.modal-header {
  margin-bottom: 30px;
}

.toggle {
  display: flex;
  gap: 0;
  border: 1px solid #ffffff;
  width: fit-content;
}

.toggle-btn {
  background: transparent;
  border: none;
  border-right: 1px solid #ffffff;
  color: #ffffff;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  padding: 8px 16px;
  cursor: pointer;
  min-width: unset;
  transition: background 0.2s;
}

.toggle-btn:last-child {
  border-right: none;
}

.toggle-btn:hover {
  background: #ffffff11;
}

.toggle-btn.active {
  background: #ffffff;
  color: #000000;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  color: #ffffff;
  font-family: "Courier New", monospace;
  font-size: 1rem;
  line-height: 1.8;
  letter-spacing: 0.02em;
}

.explanation {
  display: none;
  margin: 0;
}

.explanation.active {
  display: block;
}
