* {
  box-sizing: border-box;
  user-select: none;
}

body {
  background: #1e1e24;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  padding: 12px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ポケコン本体筐体（コンテナクエリ対応） */
.pokecon-container {
  background: linear-gradient(145deg, #323539, #1f2124);
  border-radius: 16px;
  padding: clamp(10px, 2.5vw, 20px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6),
    inset 0 1px 2px rgba(255, 255, 255, 0.2);
  width: 100%;
  max-width: 780px;
  border: 2px solid #151618;
  container-type: inline-size;
  /* 横幅に応じた相対スケーリングを有効化 */
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #d1d5db;
  font-weight: bold;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.header .logo {
  font-size: clamp(0.7rem, 2cqw, 1rem);
}

.header .logo span {
  font-size: clamp(0.55rem, 1.5cqw, 0.8rem);
  color: #9ca3af;
  margin-left: 6px;
}

.header .sub-logo {
  font-size: clamp(0.55rem, 1.5cqw, 0.75rem);
  color: #e5e7eb;
}

/* 液晶画面領域（アスペクト比固定＆伸縮） */
.lcd-wrapper {
  background: #111214;
  padding: 2.5%;
  border-radius: 8px;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.8);
  margin-bottom: 14px;
}

.lcd-screen {
  background: #8da177;
  border-radius: 4px;
  padding: 2%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.15);
  border: 1px solid #758862;
  gap: 8px;
}

#lcd {
  width: 100%;
  height: auto;
  aspect-ratio: 144 / 48;
  /* 3:1の液晶比率を維持して自動拡大縮小 */
  image-rendering: pixelated;
  max-width: 576px;
}

.lcd-status {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: clamp(0.5rem, 1.4cqw, 0.7rem);
  font-weight: bold;
  color: #48543c;
  flex-shrink: 0;
}

.lcd-status span.active {
  color: #121c0a;
}

/* キーボード領域 */
.keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.main-keys {
  display: flex;
  gap: 12px;
}

.qwerty-section {
  flex: 2;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.numpad-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.key-row {
  display: flex;
  gap: 4px;
  width: 100%;
}

/* ボタンの可変サイズ化 */
.key {
  flex: 1 1 0;
  min-width: 0;
  /* はみ出し防止 */
  background: linear-gradient(180deg, #4b5056, #33363a);
  color: #f3f4f6;
  border: 1px solid #222427;
  border-radius: 4px;
  height: clamp(26px, 5.5cqw, 36px);
  font-size: clamp(0.5rem, 1.4cqw, 0.75rem);
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 3px 0 #18191b, 0 4px 5px rgba(0, 0, 0, 0.4);
  transition: all 0.05s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  white-space: nowrap;
}

.key:active,
.key.is-pressed {
  transform: translateY(3px);
  box-shadow: 0 0 0 #18191b, inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* 特定キーの個別スタイル */
.key.fn-orange {
  background: linear-gradient(180deg, #d97706, #b45309);
  border-color: #78350f;
  box-shadow: 0 3px 0 #78350f;
}

.key.sys-key {
  background: linear-gradient(180deg, #475569, #334155);
}

.key.danger {
  background: linear-gradient(180deg, #dc2626, #991b1b);
  box-shadow: 0 3px 0 #450a0a;
}

.key.space {
  flex: 3 1 0;
}

.key.enter {
  background: linear-gradient(180deg, #2563eb, #1d4ed8);
  box-shadow: 0 3px 0 #1e3a8a;
  flex: 2 1 0;
}

.key.num {
  background: linear-gradient(180deg, #d1d5db, #9ca3af);
  color: #111827;
  box-shadow: 0 3px 0 #4b5563;
}

.key.sym {
  background: linear-gradient(180deg, #6366f1, #4f46e5);
  color: #e0e7ff;
  box-shadow: 0 3px 0 #3730a3;
  font-size: clamp(0.6rem, 1.6cqw, 0.85rem);
}

.sym-row {
  margin-bottom: 4px;
}

/* スマホ等幅狭画面での自動レイアウト調整 */
@media (max-width: 600px) {
  .main-keys {
    flex-direction: column;
    /* 画面幅が狭い場合はテンキーを下に配置 */
  }
}
