body {
  font-family: 'Georgia', serif;
  background-color: #f5f1e5;
  color: #3b2f2f;
  margin: 0;
  padding: 2em;
  text-align: center;

  background-image:
    repeating-linear-gradient(
      0deg,
      #f5f1e5 0,
      #f5f1e5 2px,
      #f3f0dc 3px,
      #f5f1e5 4px
    ),
    repeating-linear-gradient(
      90deg,
      #f5f1e5 0,
      #f5f1e5 2px,
      #f3f0dc 3px,
      #f5f1e5 4px
    ),
    repeating-linear-gradient(
      45deg,
      rgba(0,0,0,0.03) 0,
      rgba(0,0,0,0.03) 1px,
      transparent 1.5px,
      transparent 4px
    );
  background-blend-mode: multiply;
  background-size: 12px 12px, 12px 12px, 16px 16px;
}

header {
  background-color: #6a1b1a;
  color: #fff;
  width: 100%;
  position: relative;
  top: 0;
  left: 0;
  margin: 0;
  padding: 1em 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  border-top: 8px solid #a37150;
  border-bottom: 8px solid #a37150;
  animation: headerWave 8s ease-in-out infinite;
  clip-path: polygon(
    0% 0%, 100% 0%, 100% 90%, 95% 100%, 5% 100%, 0% 90%
  );

  background-image: 
    repeating-linear-gradient(
      45deg,
      #6a1b1a 0,
      #6a1b1a 10px,
      #7e261f 10px,
      #7e261f 15px
    ),
    repeating-linear-gradient(
      -45deg,
      rgba(255,255,255,0.1) 0,
      rgba(255,255,255,0.1) 2px,
      transparent 3px,
      transparent 10px
    );
  background-blend-mode: multiply;
}


@keyframes headerWave {
  0%, 100% {
    clip-path: polygon(
      0% 0%, 100% 0%, 100% 90%, 95% 100%, 5% 100%, 0% 90%
    );
  }
  50% {
    clip-path: polygon(
      0% 0%, 100% 0%, 100% 92%, 97% 102%, 3% 102%, 0% 92%
    );
  }
}

.header-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1em;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: floatUpDown 6s ease-in-out infinite;
}

@keyframes floatUpDown {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.header-inner h1 {
  margin: 0;
  font-size: 2.2em;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-shadow: 2px 2px 4px #4a2c20;
  animation: glowAinu 4s ease-in-out infinite alternate;
  font-family: 'Georgia', serif;
}

@keyframes glowAinu {
  0% {
    text-shadow: 0 0 5px #d9a05a, 0 0 10px #a37150;
  }
  100% {
    text-shadow: 0 0 15px #ffd9a0, 0 0 25px #a37150;
  }
}

nav {
  margin-top: 0.7em;
}

nav a {
  margin: 0 1.2em;
  color: #ffd9c0;
  text-decoration: none;
  font-weight: bold;
  transition: color 0.4s ease, transform 0.4s ease;
  position: relative;
  font-family: 'Georgia', serif;
}

nav a::before, nav a::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  border: 2px solid #ffd9c0;
  border-radius: 50%;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

nav a::before {
  left: -14px;
}

nav a::after {
  right: -14px;
}

nav a:hover {
  color: #fff;
  transform: scale(1.1);
}

nav a:hover::before,
nav a:hover::after {
  opacity: 1;
}

.subtitle {
  margin: 0.3em 0 0;
  font-size: 1em;
  color: #7b5e3c;
  font-style: italic;
  animation: subtitleFade 6s ease-in-out infinite;
}

@keyframes subtitleFade {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

#word {
  font-size: 2.6em;
  font-weight: bold;
  color: #2e1d0e;
  margin-bottom: 0.4em;
  text-shadow: 1px 1px 2px #b07a3f;
  animation: wordPulse 5s ease-in-out infinite;
  font-family: 'Georgia', serif;
  letter-spacing: 0.12em;
}

@keyframes wordPulse {
  0%, 100% { color: #2e1d0e; text-shadow: 1px 1px 2px #b07a3f; }
  50% { color: #a37d52; text-shadow: 1px 1px 10px #d9a05a; }
}

#kana {
  font-size: 1.8em;
  color: #7c4b2c;
  margin-bottom: 0.6em;
  font-family: 'Hiragino Kaku Gothic Pro', 'Yu Gothic', sans-serif;
  letter-spacing: 0.2em;
  animation: kanaWave 6s ease-in-out infinite;
}

#meaning {
  font-size: 1.4em;
  color: #4d3b33;
  margin-bottom: 1.2em;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  font-family: 'Georgia', serif;
  border-top: 2px dotted #a37d52;
  padding-top: 0.5em;
  animation: meaningGlow 8s ease-in-out infinite;
}

@keyframes meaningGlow {
  0%, 100% {
    border-color: #a37d52;
    color: #4d3b33;
  }
  50% {
    border-color: #d9a05a;
    color: #7b5e3c;
  }
}

button {
  background-color: #a37d52;
  border: none;
  padding: 0.7em 1.6em;
  font-size: 1.1em;
  color: #fff;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
  transition: background-color 0.3s ease, transform 0.3s ease;
  font-family: 'Georgia', serif;
  letter-spacing: 0.1em;
}

button:hover {
  background-color: #8a6541;
  transform: scale(1.1);
}

.dictionary-container {
  max-width: 1000px;
  margin: 2em auto;
  padding: 1em;
  animation: containerFadeIn 2s ease forwards;
}

@keyframes containerFadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.dictionary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.15em;
  background-color: #fffdf7;
  border: 2px solid #d9c8b4;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  border-radius: 12px;
  overflow: hidden;
}

.dictionary-table th,
.dictionary-table td {
  padding: 1em 1.2em;
  border-bottom: 1px solid #ddd1b8;
  text-align: left;
  transition: background-color 0.4s ease;
  font-family: 'Georgia', serif;
  color: #5c3a1e;
}

.dictionary-table th {
  background-color: #e8ddc8;
  font-weight: 700;
  letter-spacing: 0.1em;
  border-bottom: 3px solid #a37d52;
}

.dictionary-table tr:hover {
  background-color: #f9f6ee;
  cursor: pointer;
}

.search-input-container {
  max-width: 600px;
  margin: 2em auto;
  display: flex;
  justify-content: center;
  gap: 1em;
  animation: searchContainerFade 2s ease forwards;
}

@keyframes searchContainerFade {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.search-input-container input {
  padding: 0.7em;
  font-size: 1.1em;
  width: 100%;
  max-width: 400px;
  border-radius: 12px;
  border: 1.5px solid #a37d52;
  font-family: 'Georgia', serif;
  transition: border-color 0.3s ease;
}

.search-input-container input:focus {
  outline: none;
  border-color: #d9a05a;
  box-shadow: 0 0 8px #d9a05a;
}

.search-input-container button {
  padding: 0.7em 1.2em;
  font-size: 1.1em;
  cursor: pointer;
  background-color: #6a1b1a;
  color: white;
  border: none;
  border-radius: 12px;
  font-family: 'Georgia', serif;
  letter-spacing: 0.1em;
  transition: background-color 0.4s ease, transform 0.3s ease;
}

.search-input-container button:hover {
  background-color: #8a6541;
  transform: scale(1.05);
}

#levelSelector {
  padding: 0.6em 1.4em;
  font-size: 1em;
  border-radius: 12px;
  border: 2px solid #a37d52;
  background-color: #f5f1e5;
  color: #3b2f2f;
  cursor: pointer;
  margin-bottom: 1.5em;
  font-family: 'Georgia', serif;
  letter-spacing: 0.1em;
  transition: border-color 0.4s ease, background-color 0.4s ease;
}

#levelSelector:hover {
  border-color: #d9a05a;
  background-color: #e9e3d3;
}

.dropdown-container {
  padding-top: 1.5em;
}

@media (max-width: 600px) {
  body {
    padding: 1em;
  }

  .header-inner h1 {
    font-size: 1.8em;
  }

  nav a {
    font-size: 1em;
  }

  .subtitle {
    font-size: 0.9em;
  }

  #word {
    font-size: 2em;
  }

  #kana {
    font-size: 1.4em;
  }

  #meaning {
    font-size: 1.1em;
  }
}

#speakKanaBtn {
  background: none;
  border: none;
  color: #a37d52;
  font-size: 1.3em;
  font-weight: bold;
  font-family: 'Georgia', serif;
  letter-spacing: 0.12em;
  cursor: pointer;
  padding: 0.2em 0;
  margin-top: 1em;
  text-shadow: none;
  transition: color 0.3s ease, transform 0.2s ease;
  animation: glowTextBtn 3s ease-in-out infinite alternate;
  outline: none;
  box-shadow: none
}

#speakKanaBtn:hover {
  color: #d9a05a;
  transform: scale(1.05);
}

#speakKanaBtn:active {
  transform: scale(0.97);
}

#speakKanaBtn:focus {
  outline: none;
  text-decoration: underline;
  text-decoration-color: #d9a05a;
  text-underline-offset: 3px;
}

@keyframes glowTextBtn {
  0% {
    color: #a37d52;
    text-shadow: 0 0 5px #d9a05a;
  }
  100% {
    color: #d9a05a;
    text-shadow: 0 0 15px #d9a05a;
  }
}
