:root {
  --bg-color: #050505;
  --key-bg: #1a1a1c;
  --key-border: #444;
  --key-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  --key-hover-bg: #28282d;

  /* Layer Colors */
  --text-l0: #f0f0f0; /* Base Layer: White/Light Gray */
  --text-l1: #00e5ff; /* Layer 1: Neon Cyan/Blue */
  --text-l2: #ff2a55; /* Layer 2: Neon Pink/Red */

  /* Dimensions - adjust scale based on screen size */
  --key-w: 64px;
  --key-h: 64px;
  --key-gap: 6px;
  --key-radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  background-color: var(--bg-color);
  color: #fff;
  font-family: "Inter", "M PLUS Rounded 1c", sans-serif;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow-x: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px; /* ヘッダーとキーボードの距離を近づける (元: 40px) */
  padding: 40px 20px 20px 20px;
}

header {
  text-align: center;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

header p {
  font-size: 0.9rem;
  color: #888;
  margin-bottom: 20px;
}

.save-button {
  background: var(--key-bg);
  color: #fff;
  border: 1px solid var(--key-border);
  padding: 10px 20px;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.save-button:hover {
  background: var(--key-hover-bg);
  border-color: #666;
  transform: translateY(-2px);
}

.text-layer1 {
  color: var(--text-l1);
  font-weight: 600;
}
.text-layer2 {
  color: var(--text-l2);
  font-weight: 600;
}

.keyboard {
  display: flex;
  gap: 80px; /* Space between left and right hands */
  padding: 60px 20px 80px 20px; /* Increased vertical padding to prevent PNG cut off */
}

.half {
  display: flex;
  flex-direction: column;
  align-items: center; /* Thumb cluster under columns */
  gap: 20px;
}

.columns-container {
  display: flex;
  gap: var(--key-gap);
  align-items: flex-end; /* Columns can stagger from bottom or top */
}

/* Base key column */
.col {
  display: flex;
  flex-direction: column;
  gap: var(--key-gap);
}

/* Example staggered columns */
/* Center columns are usually higher up (negative translate) */
.left-half .col:nth-child(3),
.left-half .col:nth-child(4),
.right-half .col:nth-child(4),
.right-half .col:nth-child(3) {
  transform: translateY(-8px);
}

/* Inner extra columns (2 keys) should be vertically centered relative to 3 key columns */
.col.inner-col {
  /* 
    A 3-key column height is approx 3*64 + 2*6 = 204px
    A 2-key column height is approx 2*64 + 1*6 = 134px
    Difference = 70px. To center it, push it down by 35px from flex-end (which is bottom).
    In this flex-end alignment, standard columns are at the bottom.
    So translating down by 35px brings the 2-key col "up" from the bottom to the center.
    Since align-items is flex-end, we actually want a negative translate or margin-bottom.
  */
  margin-bottom: calc(var(--key-h) / 2 + var(--key-gap) / 2);
}

.key {
  position: relative;
  width: var(--key-w);
  height: var(--key-h);
  background: var(--key-bg);
  border: 1px solid var(--key-border);
  border-radius: var(--key-radius);
  box-shadow: var(--key-shadow);
  transition: all 0.2s ease;
  user-select: none;
  display: flex;
  justify-content: center;
  align-items: center;
}

.key:hover {
  transform: translateY(-2px);
  background: var(--key-hover-bg);
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.05);
  border-color: #666;
  z-index: 10;
}

/* Modifiers / Special sizes */
.key.mod {
  font-size: 0.85rem;
}
.key.sp-w1-5 {
  width: calc(var(--key-w) * 1.5 + var(--key-gap) / 2);
}
.key.sp-h1-5 {
  height: calc(var(--key-h) * 1.25);
}

/* Special borders for layers (toggled by JS) */
.key.border-l1 {
  border-color: var(--text-l1);
  box-shadow: 0 0 15px rgba(0, 229, 255, 0.3), inset 0 0 10px rgba(0, 229, 255, 0.1);
}

.key.border-l2 {
  border-color: var(--text-l2);
  box-shadow: 0 0 15px rgba(255, 42, 85, 0.3), inset 0 0 10px rgba(255, 42, 85, 0.1);
}

/* Thumb clusters */
.thumb-cluster {
  display: flex;
  gap: var(--key-gap);
}

.left-thumb {
  transform: rotate(-10deg);
  transform-origin: top right;
  margin-left: auto; /* align towards center */
}

.right-thumb {
  transform: rotate(10deg);
  transform-origin: top left;
  margin-right: auto;
}

/* Inward rotation for inner keys if desired - for now keep them flat */

/* Text Layers */
.l0, .l1, .l2 {
  position: absolute;
  min-width: 14px;
  min-height: 16px;
  outline: none;
  border: 1px dashed transparent;
  transition: all 0.2s;
  cursor: text;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 4px;
}

.l0:focus, .l1:focus, .l2:focus,
.l0:empty:hover, .l1:empty:hover, .l2:empty:hover {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.1);
}

.l0 {
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-l0);
}

.l1 {
  bottom: 8px;
  left: 8px;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-l1);
}

.l2 {
  bottom: 8px;
  right: 8px;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-l2);
}

/* For keys with only main label (centered) */
.key.centered .l0 {
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.9rem;
}
