@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Lexend:wght@400;500;600;700&display=swap');

:root {
  --primary: #3b82f6;
  --primary-glow: rgba(59, 130, 246, 0.4);
  --secondary: #8b5cf6;
  --accent: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  
  --bg-color: #0f172a;
  --card-bg: rgba(30, 41, 59, 0.8);
  --card-border: rgba(51, 65, 85, 0.6);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  --glass-blur: blur(12px);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: 'Inter', "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  background-color: var(--bg-color);
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding: 1.5rem 2rem;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  font-family: 'Lexend', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-main);
}

.brand span {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

nav {
  display: flex;
  gap: 1.5rem;
}

nav a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  transition: all 0.2s;
  font-size: 0.95rem;
}

nav a:hover, nav a.active {
  color: var(--primary);
}

main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
  width: 100%;
}

.hero {
  text-align: center;
  margin-bottom: 4rem;
}

.hero h1 {
  font-family: 'Lexend', sans-serif;
  font-size: 3rem;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.hero p {
  font-size: 1.25rem;
  color: var(--text-muted);
  max-width: 800px;
  margin: 0 auto;
}

/* Tool Card Styles */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin-bottom: 5rem;
}

.tool-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 1.5rem;
  padding: 2.5rem;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.tool-card:hover {
  transform: translateY(-8px);
  border-color: var(--primary);
  box-shadow: 0 0 30px var(--primary-glow);
}

.tool-icon {
  font-size: 3rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tool-card h3 {
  font-size: 1.5rem;
  font-family: 'Lexend', sans-serif;
}

.tool-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: #2563eb;
  box-shadow: 0 0 15px var(--primary-glow);
}

/* Diagnostic UI Elements */
.test-container {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 2rem;
  padding: 2rem;
  margin-bottom: 3rem;
  box-shadow: var(--shadow-lg);
}

.status-bar {
  display: flex;
  gap: 2rem;
  margin-bottom: 2rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 1rem;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-item .label {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-item .value {
  font-weight: 700;
  font-family: 'Lexend', sans-serif;
}

/* Speed Test Specific */
.speed-gauge-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.speed-gauge {
  width: 100%;
  padding-bottom: 100%;
  border-radius: 50%;
  background: conic-gradient(from 180deg, #1e293b 0%, var(--primary) var(--percentage, 0%), #1e293b var(--percentage, 0%));
  position: relative;
  transition: --percentage 0.5s ease;
}

.speed-gauge::after {
  content: "";
  position: absolute;
  top: 10%;
  left: 10%;
  right: 10%;
  bottom: 10%;
  background: var(--bg-color);
  border-radius: 50%;
}

.speed-val-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 10;
}

.speed-val-display .unit {
  font-size: 1.25rem;
  color: var(--text-muted);
  display: block;
}

.speed-val-display .number {
  font-size: 4rem;
  font-weight: 800;
  font-family: 'Lexend', sans-serif;
  color: var(--text-main);
  line-height: 1;
}

.speed-results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-top: 3rem;
  width: 100%;
}

.speed-result-card {
  background: rgba(0,0,0,0.2);
  padding: 1.5rem;
  border-radius: 1rem;
  text-align: center;
  border: 1px solid var(--card-border);
}

.speed-result-card .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  display: block;
}

.speed-result-card .value {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: 'Lexend', sans-serif;
}

.speed-result-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 15px var(--primary-glow);
}

@property --percentage {
  syntax: '<percentage>';
  inherits: false;
  initial-value: 0%;
}

/* Keyboard Specific */
.keyboard-layout {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  user-select: none;
}

.kb-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.kb-key {
  min-width: 3.5rem;
  height: 3.5rem;
  background: #1e293b;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid #334155;
  color: var(--text-muted);
  transition: all 0.1s;
}

.kb-key.active {
  background: var(--primary);
  color: white;
  transform: scale(0.95);
  box-shadow: 0 0 15px var(--primary-glow);
}

.kb-key.pressed {
  color: var(--accent);
  border-color: var(--accent);
}

/* SEO Sections */
.seo-section {
  background: rgba(15, 23, 42, 0.4);
  border-radius: 2rem;
  padding: 4rem 2rem;
  margin-top: 4rem;
}

.seo-content {
  max-width: 900px;
  margin: 0 auto;
}

.seo-content h2 {
  font-size: 2.25rem;
  margin-bottom: 2rem;
  font-family: 'Lexend', sans-serif;
  background: linear-gradient(to right, #fff, var(--text-muted));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.seo-content p, .seo-content ul {
  margin-bottom: 1.5rem;
  color: var(--text-muted);
}

.seo-content h3 {
  margin: 2.5rem 0 1rem;
  font-size: 1.5rem;
  color: var(--text-main);
}

.faq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-top: 3rem;
}

.faq-item h4 {
  color: var(--primary);
  margin-bottom: 0.5rem;
}

footer {
  padding: 4rem 2rem;
  border-top: 1px solid var(--card-border);
  background: var(--bg-color);
  margin-top: auto;
}

.footer-nav {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.footer-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

/* Typing Test Specific */
#target-text span {
  transition: all 0.2s;
  padding: 0 1px;
  border-radius: 4px;
}

.typing-correct {
  color: var(--text-main) !important;
  background: rgba(16, 185, 129, 0.2) !important;
}

.typing-error {
  color: var(--danger) !important;
  background: rgba(239, 68, 68, 0.2) !important;
  text-decoration: underline wavy var(--danger);
}

.typing-display-outer {
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.4);
}

#result-overlay {
  animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
  from { opacity: 0; backdrop-filter: blur(0); }
  to { opacity: 1; backdrop-filter: blur(12px); }
}

@media (max-width: 768px) {
  .hero h1 { font-size: 2.25rem; }
  .kb-key { min-width: 2.5rem; height: 2.5rem; font-size: 0.7rem; }
  .status-bar { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
}
