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

:root {
  --bg-gradient-start: #667eea;
  --bg-gradient-end: #764ba2;
  --container-bg: white;
  --text-color: #333;
  --text-color-light: #555;
  --border-color: #ddd;
  --input-bg: white;
  --result-bg: #f8f9fa;
  --result-border: #e9ecef;
  --utc-time-bg: rgba(255, 255, 255, 0.95);
  --utc-time-color: #667eea;
  --utc-time-border: #667eea;
  --button-bg: #667eea;
  --button-text: white;
  --button-hover: #5568d3;
}

body.dark-mode {
  --bg-gradient-start: #1a1a2e;
  --bg-gradient-end: #16213e;
  --container-bg: #1e1e2e;
  --text-color: #e0e0e0;
  --text-color-light: #b0b0b0;
  --border-color: #444;
  --input-bg: #2a2a3e;
  --result-bg: #252535;
  --result-border: #333;
  --utc-time-bg: rgba(30, 30, 46, 0.95);
  --utc-time-color: #8b9aff;
  --utc-time-border: #8b9aff;
  --button-bg: #4a5fc7;
  --button-text: #e0e0e0;
  --button-hover: #5a6fd7;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  min-height: 100vh;
  padding: 20px;
  padding-top: 70px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.3s ease;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  background: var(--container-bg);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transition: background 0.3s ease;
}

.utc-time-fixed {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--utc-time-color);
  font-size: 1.2em;
  font-weight: bold;
  padding: 10px;
  background: var(--utc-time-bg);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  font-family: 'Courier New', monospace;
  border-bottom: 2px solid var(--utc-time-border);
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.dark-mode-toggle {
  position: fixed;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--container-bg);
  color: var(--text-color);
  font-size: 20px;
  cursor: pointer;
  z-index: 1001;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  transition: background 0.3s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dark-mode-toggle:hover {
  transform: scale(1.1);
}

.dark-mode-toggle:active {
  transform: scale(0.95);
}

.header-with-reset {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-bottom: 30px;
  position: relative;
}

h1 {
  text-align: center;
  color: var(--text-color);
  margin: 0;
  font-size: 2em;
  transition: color 0.3s ease;
  flex: 1;
}

.reset-btn {
  padding: 4px 10px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  font-weight: normal;
  cursor: pointer;
  transition: background 0.3s, transform 0.2s;
  white-space: nowrap;
}

.reset-btn:hover {
  background: #c82333;
  transform: translateY(-1px);
}

.reset-btn:active {
  transform: translateY(0);
  background: #bd2130;
}

.settings-btn {
  padding: 8px;
  background: transparent;
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.settings-btn:hover {
  background: var(--input-bg);
  border-color: var(--button-bg);
  transform: translateY(-50%) scale(1.05);
}

.settings-btn:active {
  transform: translateY(-50%) scale(0.95);
}

.settings-btn svg {
  width: 20px;
  height: 20px;
  fill: var(--text-color);
  transition: fill 0.3s ease;
}

.mode-selector {
  display: flex;
  gap: 10px;
  margin-bottom: 30px;
  justify-content: center;
}

.mode-btn {
  padding: 12px 24px;
  border: 2px solid #667eea;
  background: var(--container-bg);
  color: #667eea;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.3s ease;
}

.mode-btn:hover {
  background: var(--input-bg);
}

body.dark-mode .mode-btn {
  border-color: #8b9aff;
  color: #8b9aff;
}

body.dark-mode .mode-btn:hover {
  background: var(--result-bg);
}

.mode-btn.active {
  background: #667eea;
  color: white;
}

body.dark-mode .mode-btn.active {
  background: #8b9aff;
  color: #1e1e2e;
}

.attack-form {
  margin-bottom: 30px;
}

.attack-form h2 {
  color: var(--text-color);
  margin-bottom: 20px;
  font-size: 1.5em;
  transition: color 0.3s ease;
}

.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-color-light);
  font-weight: 500;
  transition: color 0.3s ease;
}

.utc-time-diff {
  margin-left: 8px;
  font-size: 13px;
  font-weight: normal;
  color: var(--text-color-light);
  opacity: 0.8;
}

.input-group input,
.input-group select {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.3s ease, background 0.3s ease, color 0.3s ease;
  background: var(--input-bg);
  color: var(--text-color);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.input-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

body.dark-mode .input-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23e0e0e0' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

.input-group input:focus,
.input-group select:focus {
  outline: none;
  border-color: #667eea;
}

.name-custom-input {
  margin-top: 10px;
}

.utc-time-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.utc-time-control input {
  flex: 1;
  margin: 0;
}

.utc-inc-dec-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  background: var(--button-bg);
  color: var(--button-text);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.3s, transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.utc-inc-dec-btn:hover {
  background: var(--button-hover);
  transform: scale(1.05);
}

.utc-inc-dec-btn:active {
  transform: scale(0.95);
}

.utc-time-buttons {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.utc-time-btn {
  flex: 1;
  padding: 8px 12px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.3s, transform 0.2s;
}

.utc-time-btn:hover {
  background: #5568d3;
  transform: translateY(-1px);
}

.utc-time-btn:active {
  transform: translateY(0);
  background: #4a5bc4;
}

.calc-btn {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.calc-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.calc-btn:active {
  transform: translateY(0);
}

.result-area {
  margin-top: 30px;
  padding-top: 30px;
  border-top: 2px solid var(--border-color);
  transition: border-color 0.3s ease;
}

.version-info {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  text-align: center;
  color: var(--text-color);
  opacity: 0.6;
  font-size: 0.9em;
  transition: color 0.3s ease, border-color 0.3s ease;
}

.version-info p {
  margin: 0;
}

.result-area h2 {
  color: var(--text-color);
  margin-bottom: 15px;
  transition: color 0.3s ease;
}

.result-content {
  background: var(--result-bg);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 15px;
  border: 2px solid var(--result-border);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.result-content pre {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-color);
  transition: color 0.3s ease;
}

.copy-btn {
  width: 100%;
  padding: 15px;
  background: #28a745;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.3s, transform 0.2s;
}

.copy-btn:hover {
  background: #218838;
  transform: translateY(-2px);
}

.copy-btn:active {
  transform: translateY(0);
}

.copy-message {
  margin-top: 10px;
  text-align: center;
  color: #28a745;
  font-weight: bold;
  min-height: 24px;
}

/* タブレット対応（768px以下） */
@media (max-width: 768px) {
  body {
    padding: 10px;
    padding-top: 60px;
  }

  .utc-time-fixed {
    font-size: 1em;
    padding: 8px;
  }

  .dark-mode-toggle {
    width: 35px;
    height: 35px;
    font-size: 18px;
    top: 8px;
    right: 8px;
  }

  .container {
    padding: 20px;
    border-radius: 15px;
  }

  .header-with-reset {
    gap: 10px;
    margin-bottom: 20px;
  }

  h1 {
    font-size: 1.6em;
    margin-bottom: 0;
  }

  .reset-btn {
    font-size: 10px;
    padding: 3px 8px;
  }

  .settings-btn {
    width: 36px;
    height: 36px;
    font-size: 18px;
    padding: 6px;
  }

  .utc-time-fixed {
    font-size: 1em;
  }

  .mode-selector {
    gap: 8px;
    margin-bottom: 20px;
  }

  .mode-btn {
    padding: 10px 16px;
    font-size: 14px;
    flex: 1;
  }

  .attack-form h2 {
    font-size: 1.3em;
    margin-bottom: 15px;
  }

  .input-group {
    margin-bottom: 15px;
  }

  .input-group label {
    font-size: 14px;
    margin-bottom: 6px;
  }

  .input-group input,
  .input-group select {
    padding: 10px;
    font-size: 16px;
    /* iOSでズームを防ぐため16px以上 */
  }

  .calc-btn,
  .copy-btn {
    padding: 12px;
    font-size: 16px;
  }

  .utc-time-btn {
    padding: 6px 10px;
    font-size: 13px;
  }

  .utc-inc-dec-btn {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .result-content {
    padding: 15px;
  }

  .result-content pre {
    font-size: 13px;
  }
}

/* スマホ対応（480px以下） */
@media (max-width: 480px) {
  body {
    padding: 5px;
    padding-top: 55px;
  }

  .utc-time-fixed {
    font-size: 0.9em;
    padding: 6px;
  }

  .dark-mode-toggle {
    width: 32px;
    height: 32px;
    font-size: 16px;
    top: 6px;
    right: 6px;
  }

  .container {
    padding: 15px;
    border-radius: 10px;
  }

  .header-with-reset {
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
  }

  h1 {
    font-size: 1.4em;
    margin-bottom: 0;
  }

  .reset-btn {
    font-size: 9px;
    padding: 3px 6px;
  }

  .settings-btn {
    width: 32px;
    height: 32px;
    font-size: 16px;
    padding: 5px;
  }

  .utc-time-fixed {
    font-size: 0.9em;
  }

  .mode-selector {
    gap: 5px;
    margin-bottom: 15px;
  }

  .mode-btn {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 8px;
  }

  .attack-form h2 {
    font-size: 1.2em;
    margin-bottom: 12px;
  }

  .input-group {
    margin-bottom: 12px;
  }

  .input-group label {
    font-size: 13px;
    margin-bottom: 5px;
  }

  .input-group input,
  .input-group select {
    padding: 10px;
    font-size: 16px;
    border-radius: 6px;
  }

  .name-custom-input {
    margin-top: 8px;
  }

  .calc-btn,
  .copy-btn {
    padding: 12px;
    font-size: 16px;
    border-radius: 8px;
  }

  .utc-time-btn {
    padding: 6px 8px;
    font-size: 12px;
  }

  .utc-inc-dec-btn {
    width: 48px;
    height: 48px;
    font-size: 24px;
    min-width: 48px;
    min-height: 48px;
  }

  .utc-time-buttons {
    gap: 6px;
    margin-top: 6px;
  }

  .result-area {
    margin-top: 20px;
    padding-top: 20px;
  }

  .result-content {
    padding: 12px;
    border-radius: 8px;
  }

  .result-content pre {
    font-size: 12px;
    line-height: 1.5;
  }

  .copy-message {
    font-size: 14px;
  }
}

/* タッチデバイス向けの最適化 */
@media (hover: none) and (pointer: coarse) {

  .mode-btn:hover,
  .calc-btn:hover,
  .copy-btn:hover {
    transform: none;
  }

  .mode-btn:active,
  .calc-btn:active,
  .copy-btn:active {
    opacity: 0.8;
    transform: scale(0.98);
  }
}